New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
marshal: correctly handle empty shell commands #298
Conversation
See docker/compose#9634 for more context/motivation |
It's possible to override an image's entrypoint for service container's by setting `service.entrypoint`. (Same applies for image's command.) In some circumstances, it's desirable to explicitly "clear" these out from the image. However, currently, if you do specify `entrypoint: ''` or `entrypoint: []`, when the config is marshaled, that gets lost because of Go default value handling. Handling this varies slightly between YAML + JSON: * YAML: implement `IsZeroer` interface to specify that only `nil` slices should be omittable & `MarshalYAML` to ensure that `nil` slices marshal as `null` rather than `[]` * JSON: do NOT use `omitempty`, meaning that the result will _always_ be present in the marshaled output, unfortunately, but it will be correct! This preserves compatibility and "pretty" serialization for YAML at the expense of some slightly subtle marshalling semantics. Signed-off-by: Milas Bowman <milas.bowman@docker.com>
Reviewers, for your sanity, view with whitespace changes ignored: https://github.com/compose-spec/compose-go/pull/298/files?diff=split&w=1 ( |
Marked this as ready for review - no changes, but I didn't hear any major concerns out-of-band with this approach |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds go to me, just waiting for @ndeloof review to be sure there isn't hidden cases we are missing
It's possible to override an image's entrypoint for service
container's by setting
service.entrypoint
. (Same applies forimage's command.)
In some circumstances, it's desirable to explicitly "clear"
these out from the image. However, currently, if you do specify
entrypoint: ''
orentrypoint: []
, when the config ismarshaled, that gets lost because of Go default value handling.
Handling this varies slightly between YAML + JSON:
IsZeroer
interface to specify that onlynil
slices should be omittable &MarshalYAML
to ensurethat
nil
slices marshal asnull
rather than[]
omitempty
, meaning that the result willalways be present in the marshaled output, unfortunately,
but it will be correct!
This preserves compatibility and "pretty" serialization for
YAML at the expense of some slightly subtle marshalling
semantics.