CustomCF runs a 'cf' command with a custom environment and given arguments.
(cfEnv CFEnv, args ...string)
| 44 | |
| 45 | // CustomCF runs a 'cf' command with a custom environment and given arguments. |
| 46 | func CustomCF(cfEnv CFEnv, args ...string) *Session { |
| 47 | command := exec.Command("cf", args...) |
| 48 | if cfEnv.Stdin != nil { |
| 49 | command.Stdin = cfEnv.Stdin |
| 50 | } |
| 51 | if cfEnv.WorkingDirectory != "" { |
| 52 | command.Dir = cfEnv.WorkingDirectory |
| 53 | } |
| 54 | |
| 55 | if cfEnv.EnvVars != nil { |
| 56 | env := os.Environ() |
| 57 | for key, val := range cfEnv.EnvVars { |
| 58 | env = AddOrReplaceEnvironment(env, key, val) |
| 59 | } |
| 60 | command.Env = env |
| 61 | } |
| 62 | |
| 63 | WriteCommand("", cfEnv.EnvVars, args) |
| 64 | session, err := Start( |
| 65 | command, |
| 66 | NewPrefixedWriter(DebugOutPrefix, GinkgoWriter), |
| 67 | NewPrefixedWriter(DebugErrPrefix, GinkgoWriter)) |
| 68 | Expect(err).NotTo(HaveOccurred()) |
| 69 | return session |
| 70 | } |
| 71 | |
| 72 | // DebugCustomCF runs a 'cf' command with a custom environment and given |
| 73 | // arguments, with CF_LOG_LEVEL set to 'debug'. |