Skip to content

Support compose variable interpolation, .env, and --env-file - #42318

Draft
ggarzia-MSFT wants to merge 2 commits into
user/ggarzia/compose-multi-filefrom
user/ggarzia/compose-env
Draft

ggarzia-MSFT wants to merge 2 commits into
user/ggarzia/compose-multi-filefrom
user/ggarzia/compose-env

Conversation

@ggarzia-MSFT

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Adds Compose variable interpolation to WSLC. $NAME and ${NAME} in Compose file values are replaced with variables from the process environment, the project's .env file, or files passed with the new --env-file global option.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

  • Interpolation (ComposeEnvironment.cpp, in the session) runs on each document before it is validated:
    • $NAME and ${NAME} are replaced in values; keys are not interpolated.
    • $$ produces a literal $, and an unset variable produces an empty string.
    • Braced references support :-/- defaults, :+/+ alternates, and :?/? required checks. The colon forms also treat an empty value as unset.
  • Variable sources, in increasing priority:
    • Environment files, applied in order.
    • The CLI's process environment, sent as KEY=VALUE entries.
  • The CLI sends its process environment and either:
    • each --env-file value, resolved against the current directory, or
    • <project directory>\.env, when that file exists.
  • Environment file format:
    • KEY=VALUE lines, # comments, and an optional export prefix.
    • Single-quoted values are literal.
    • Double-quoted values expand escapes and references, and may span lines.
  • Value-less environment entries (KEY: in a map or KEY in a list) take the variable's value when it is set. Otherwise they are passed without a value, leaving the variable unset in the container.
  • wslc.idl: adds WSLCComposeEnvironmentFile and adds Environment and EnvironmentFiles to WSLCComposeDocumentCollection. The interface is internal.
  • Updated wslc-compose-operations.md with a new "Variables" section.

Stacked on the multi-file compose merge PR (user/ggarzia/compose-multi-file).

Validation Steps Performed

  • New tests: WSLCComposeTests::ComposeVariablesInterpolate, WSLCComposeTests::ComposeVariableErrorsRejected, WSLCCLIExecutionUnitTests::ComposeProject_EnvironmentFiles, WSLCE2EComposeLifecycleTests::WSLCE2E_Compose_InterpolatesDotEnvAndProcessVariables
  • cmake --build . -- -m (x64 Debug): passed
  • python tools\devops\validate-localization.py: passed

ggarzia-MSFT and others added 2 commits November 17, 2026 10:19
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ose-env

# Conflicts:
#	src/windows/wslc/services/ComposeService.cpp

This branch has not been deployed

No deployments
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