Skip to content

Add option to keep empty environment variable keys in normalization#634

Closed
edwardrf wants to merge 3 commits intocompose-spec:mainfrom
edwardrf:edw-keep-empty-env-opt
Closed

Add option to keep empty environment variable keys in normalization#634
edwardrf wants to merge 3 commits intocompose-spec:mainfrom
edwardrf:edw-keep-empty-env-opt

Conversation

@edwardrf
Copy link
Copy Markdown

In #589, the normalisation logic strips off any environment variables that does not have a value in config, however, i my use case, I am still interested in any empty environment variables names that has been set, which i'll resolve the value at a later stage, so I am implementing an naive option to allow me keep them during normalisation, please let me know if there is a better way of doing it. Currently, I have to load the project twice, use the one without normalisation to detect those empty environment variables.

@edwardrf edwardrf requested a review from ndeloof as a code owner May 31, 2024 20:54
@ndeloof
Copy link
Copy Markdown
Collaborator

ndeloof commented Jun 1, 2024

please clarify your use case. a key-only environment variable is resolved based on user's environment, and ignored otherwise. Why not just populate the project environment with all usable values ?

@edwardrf
Copy link
Copy Markdown
Author

edwardrf commented Jun 3, 2024

We use the key-only environment variable in 2 ways:

  1. Validation and suggestion: in our tool, we provide warning and suggestions to the user if there are anything in their compose file could be a mistake.
  2. Supply values when needed: our tool will figure out an external source for the value to be supplied at deployment time based on the users need.

The current behaviour of silently dropping them prevented us from doing either. An alternative solution is to return the dropped keys via a different way, like another return value or structured warning message.

@edwardrf
Copy link
Copy Markdown
Author

Any suggestions? I am open to an alternative approach if there is a recommendation.

@ndeloof
Copy link
Copy Markdown
Collaborator

ndeloof commented Jul 4, 2024

Actually this is a bug to remove empty variable from container environment, as empty has a special meaning to "remove" variable (see docker/compose#11962)

@ndeloof
Copy link
Copy Markdown
Collaborator

ndeloof commented Jul 8, 2024

Closing as #654 has been merged

@ndeloof ndeloof closed this Jul 8, 2024
@edwardrf
Copy link
Copy Markdown
Author

edwardrf commented Jul 8, 2024

Thank you!

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.

3 participants