BaseEnvironment provides the minimal environment variables used across all Docker / Compose commands.
()
| 264 | // BaseEnvironment provides the minimal environment variables used across all |
| 265 | // Docker / Compose commands. |
| 266 | func (c *CLI) BaseEnvironment() []string { |
| 267 | env := []string{ |
| 268 | "HOME=" + c.HomeDir, |
| 269 | "USER=" + os.Getenv("USER"), |
| 270 | "DOCKER_CONFIG=" + c.ConfigDir, |
| 271 | "KUBECONFIG=invalid", |
| 272 | "PATH=" + os.Getenv("PATH"), |
| 273 | } |
| 274 | dockerContextEnv, ok := os.LookupEnv("DOCKER_CONTEXT") |
| 275 | if ok { |
| 276 | env = append(env, "DOCKER_CONTEXT="+dockerContextEnv) |
| 277 | } |
| 278 | |
| 279 | if coverdir, ok := os.LookupEnv("GOCOVERDIR"); ok { |
| 280 | _, filename, _, _ := runtime.Caller(0) |
| 281 | root := filepath.Join(filepath.Dir(filename), "..", "..") |
| 282 | coverdir = filepath.Join(root, coverdir) |
| 283 | env = append(env, fmt.Sprintf("GOCOVERDIR=%s", coverdir)) |
| 284 | } |
| 285 | return env |
| 286 | } |
| 287 | |
| 288 | // NewCmd creates a cmd object configured with the test environment set |
| 289 | func (c *CLI) NewCmd(command string, args ...string) icmd.Cmd { |
no test coverage detected