mirror of
https://github.com/docker/compose.git
synced 2026-08-04 14:47:40 +00:00
Merge 97856c897d into e87f7b79df
This commit is contained in:
commit
cd2fd4f717
3 changed files with 29 additions and 0 deletions
|
|
@ -205,6 +205,24 @@ func TestEnvInterpolation(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestEnvSelfReference(t *testing.T) {
|
||||
c := NewParallelCLI(t)
|
||||
|
||||
t.Run("self-referencing variables expand within env file", func(t *testing.T) {
|
||||
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/environment/env-self-reference/compose.yaml", "config")
|
||||
res.Assert(t, icmd.Expected{Out: `FULL_IMAGE: gcr.io/myproject/myapp:latest`})
|
||||
res.Assert(t, icmd.Expected{Out: `BASE_URL: gcr.io/myproject/subpath`})
|
||||
})
|
||||
|
||||
t.Run("OS env overrides base variable and cascades through references", func(t *testing.T) {
|
||||
cmd := c.NewDockerComposeCmd(t, "-f", "./fixtures/environment/env-self-reference/compose.yaml", "config")
|
||||
cmd.Env = append(cmd.Env, "REGISTRY_URL=override.io")
|
||||
res := icmd.RunCmd(cmd)
|
||||
res.Assert(t, icmd.Expected{Out: `FULL_IMAGE: override.io/myapp:latest`})
|
||||
res.Assert(t, icmd.Expected{Out: `BASE_URL: override.io/subpath`})
|
||||
})
|
||||
}
|
||||
|
||||
func TestCommentsInEnvFile(t *testing.T) {
|
||||
c := NewParallelCLI(t)
|
||||
|
||||
|
|
|
|||
4
pkg/e2e/fixtures/environment/env-self-reference/.env
Normal file
4
pkg/e2e/fixtures/environment/env-self-reference/.env
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
REGISTRY_URL=gcr.io/myproject
|
||||
IMAGE_NAME=myapp
|
||||
FULL_IMAGE=${REGISTRY_URL}/${IMAGE_NAME}:latest
|
||||
BASE_URL=${REGISTRY_URL}/subpath
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
services:
|
||||
test:
|
||||
image: bash
|
||||
environment:
|
||||
FULL_IMAGE: ${FULL_IMAGE}
|
||||
BASE_URL: ${BASE_URL}
|
||||
command: echo "ok"
|
||||
Loading…
Add table
Add a link
Reference in a new issue