Skip to content

Commit

Permalink
Fix .env and --envfile priorities
Browse files Browse the repository at this point in the history
Signed-off-by: Ulysses Souza <[email protected]>
  • Loading branch information
ulyssessouza committed Jul 13, 2022
1 parent 58dcfcd commit a2b7f51
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/e2e/compose_environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ func TestEnvPriority(t *testing.T) {
assert.Equal(t, strings.TrimSpace(res.Stdout()), "shell-run")
})

// No Compose file & no env variable but override env file
// 1. Compose file
// 2. Shell environment variables
// 3. Environment file <-- Result expected
// 4. Dockerfile
// 5. Variable is not defined
t.Run("override env file from compose", func(t *testing.T) {
res := c.RunDockerComposeCmd("-f", "./fixtures/environment/env-priority/compose-with-env-file.yaml",
"--project-directory", projectDir,
"run", "--rm", "-e", "WHEREAMI", "env-compose-priority")
assert.Equal(t, strings.TrimSpace(res.Stdout()), "override")
})

// No Compose file & no env variable but override env file
// 1. Compose file
// 2. Shell environment variables
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
env-compose-priority:
image: env-compose-priority
build:
context: .
env_file:
- .env.override

0 comments on commit a2b7f51

Please sign in to comment.