Skip to content
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

config: use correct YAML marshal func #9712

Merged
merged 1 commit into from Aug 3, 2022
Merged

Conversation

milas
Copy link
Member

@milas milas commented Aug 3, 2022

What I did
When marshalling via CLI (compose convert / compose config), we
were using a different YAML lib, which was a fork of go-yaml,
which is what gopkg.in/yaml.v2 is based off of.

The compose-spec/compose-go lib is written with gopkg.in/yaml.v2
as a target, so I changed it to use that for marshalling the config.

The fork that was being used was sanathkr/go-yaml.
Looking through git log, this was originally introduced transitively by
old ECS/CloudFormation code (that now lives in compose-cli), so its
usage was likely the result of IDE auto-complete and not intentional.

The only change it added compared to the upstream lib was custom tag
support, which is not something we use (and regardless, since the unmarshal
is done with a different lib, it wouldn't work regardless). See go-yaml/yaml@ed9d249.

Related issue
I discovered this when working on compose-spec/compose-go#298.

(not mandatory) A picture of a cute animal, if possible in relation with what you did
a cat in a shark costume

@milas milas added kind/cleanup dependencies Pull requests that update a dependency file Docker Compose V2 labels Aug 3, 2022
@milas milas requested a review from a team August 3, 2022 16:29
@milas milas self-assigned this Aug 3, 2022
@milas
Copy link
Member Author

milas commented Aug 3, 2022

As a bonus, this shrinks the executable size by ~100KB* 🥳

* Binary is ~27MB so nobody will notice 😛

Copy link
Member

@nicksieger nicksieger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find! 😎

@thaJeztah
Copy link
Member

Had a quick peek if there was a specific reason for using this library; I see this was added as part of 7f8bb03, which originally came from docker/compose-cli@7f8bb03 (docker/compose-cli#544), but review on that PR doesn't mention a specific reason

/cc @ndeloof @rumpl (just in case)

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (not a maintainer)

go.mod Outdated Show resolved Hide resolved
The `compose-spec/compose-go` lib is written with `gopkg.in/yaml.v2`
as a target.

When marshalling via CLI (`compose convert` / `compose config`), we
were using a _different_ YAML lib, which was a fork of `go-yaml`,
which is what `gopkg.in/yaml.v2` is based off of.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
@milas
Copy link
Member Author

milas commented Aug 3, 2022

Had a quick peek if there was a specific reason for using this library; I see this was added as part of 7f8bb03, which originally came from docker/compose-cli@7f8bb03 (docker/compose-cli#544), but review on that PR doesn't mention a specific reason

Yup, I'm fairly certain it got auto-imported because it was already available as an indirect dependency at the time!

And even if we had been attempting to utilize the custom YAML tag logic it added...it wouldn't work since we weren't ever using it for unmarshaling in the compose-go code

(Sidenote: I spent like 20 mins reading about YAML tags this morning and I still don't really understand them 😵)

@milas milas enabled auto-merge (squash) August 3, 2022 20:34
@milas milas merged commit 1ee44a0 into docker:v2 Aug 3, 2022
@milas milas deleted the config-yaml-marshal branch August 4, 2022 15:36
laurentsimon pushed a commit to laurentsimon/compose that referenced this pull request Aug 10, 2022
The `compose-spec/compose-go` lib is written with `gopkg.in/yaml.v2`
as a target.

When marshalling via CLI (`compose convert` / `compose config`), we
were using a _different_ YAML lib, which was a fork of `go-yaml`,
which is what `gopkg.in/yaml.v2` is based off of.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file kind/cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants