Skip to content

Add E2E tests for self-referencing variable expansion in .env files #13592

Open
4RH1T3CT0R7 wants to merge 1 commit intodocker:mainfrom
4RH1T3CT0R7:fix/13591-env-self-ref-tests
Open

Add E2E tests for self-referencing variable expansion in .env files #13592
4RH1T3CT0R7 wants to merge 1 commit intodocker:mainfrom
4RH1T3CT0R7:fix/13591-env-self-ref-tests

Conversation

@4RH1T3CT0R7
Copy link

@4RH1T3CT0R7 4RH1T3CT0R7 commented Feb 13, 2026

Summary

  • Adds E2E test coverage for self-referencing variable expansion within .env files (relates to Support .env file variable expansion in compose files #13591)
  • Verifies that variables defined earlier in .env can be referenced by later entries (e.g. FULL_IMAGE=${REGISTRY_URL}/${IMAGE_NAME}:latest)
  • Verifies that OS environment overrides cascade correctly through dependent variables

Context

Issue #13591 reports that Docker Compose doesn't support variable expansion within .env files. Investigation shows that compose-go's dotenv parser already handles this correctly — parser.go processes lines sequentially, accumulating each variable into the lookup map before parsing the next line. However, the existing test TestEnvInterpolation always sets the base variable via OS env, so it never actually exercises pure .env-internal self-reference.

This PR closes the test gap by adding an explicit E2E test that relies solely on variables defined within the .env file, with no OS env assistance.

Changes

  • New fixture pkg/e2e/fixtures/environment/env-self-reference/ — .env file with chained variable references and a minimal compose.yaml that consumes them
  • New test TestEnvSelfReference with two sub-tests:
    a. Pure .env self-reference — no OS env set, asserts FULL_IMAGE: gcr.io/myproject/myapp:latest and BASE_URL: gcr.io/myproject/subpath
    b. OS env override cascade — sets REGISTRY_URL=override.io in OS env, asserts that dependent variables pick up the override

@4RH1T3CT0R7 4RH1T3CT0R7 requested a review from a team as a code owner February 13, 2026 20:26
Signed-off-by: Artem Lytkin <iprintercanon@gmail.com>
@4RH1T3CT0R7 4RH1T3CT0R7 force-pushed the fix/13591-env-self-ref-tests branch from fc9cf71 to 97856c8 Compare February 13, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant