compose-go
compose-go copied to clipboard
Add option to keep empty environment variable keys in normalization
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.
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 ?
We use the key-only environment variable in 2 ways:
- 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.
- 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.
Any suggestions? I am open to an alternative approach if there is a recommendation.
Actually this is a bug to remove empty variable from container environment, as empty has a special meaning to "remove" variable (see https://github.com/docker/compose/issues/11962)
Closing as https://github.com/compose-spec/compose-go/pull/654 has been merged
Thank you!