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

deprecate pkg/parsers.ParseKeyValueOpt and move internal #49177

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Dec 30, 2024

deprecate pkg/parsers.ParseKeyValueOpt and move internal

Move the utility to where it's used, and deprecate the implementation
in pkg/parsers.

- Description for the changelog

Go SDK: deprecate pkg/parsers.ParseKeyValueOpt

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah added status/2-code-review kind/refactor PR's that refactor, or clean-up code labels Dec 30, 2024
@thaJeztah thaJeztah added this to the 28.0.0 milestone Dec 30, 2024
@thaJeztah thaJeztah self-assigned this Dec 30, 2024
@thaJeztah thaJeztah changed the title daemon: setDefaultIsolation: remove uses of pkg/parsers deprecate pkg/parsers.ParseKeyValueOpt and move internal Dec 30, 2024
@thaJeztah thaJeztah added impact/deprecation area/go-sdk Changes affecting the Go SDK impact/go-sdk Noteworthy (compatibility changes) in the Go SDK labels Dec 30, 2024
@thaJeztah thaJeztah force-pushed the daemon_no_pkg_parsers branch from 18c1d16 to 35eeb00 Compare December 30, 2024 13:27
Comment on lines +15 to +20
valids := map[string][]string{
"key=value": {"key", "value"},
" key = value ": {"key", "value"},
"key=value1=value2": {"key", "value1=value2"},
" key = value1 = value2 ": {"key", "value1 = value2"},
}
Copy link
Member Author

Choose a reason for hiding this comment

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

In all honesty, I'm even considering removing this utility altogether, and use straight strings.Cut.

The only added value of this utility is to allow for badly formatted values that have spaces around the <key> = <value>. We don't document those as supported (but admittedly, documentation is sparse, except for some examples).

Removing the utility could break some cases where options are incorrectly formatted, but likely mostly corner-cases; perhaps a better option would be to actively invalidate those.

Copy link
Member Author

Choose a reason for hiding this comment

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

LOL, and I completely forgot I had a PR for exec-opts, also related to this;

Copy link
Contributor

Choose a reason for hiding this comment

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

On the flip side, I don't think it's a big burden to keep it for now. But I'm fine either way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, definitely not a huge burden in this case. It's sometimes the ripple-effect it can have.

In general; we've made some bad choices to be too permissive in some cases. Or at least; too permissive in the wrong place. We tried to address for possible variants to keep a slightly easier UX ("we very likely know what you meant, so let's accept that's what you meant"); that's probably fine for some cases, but for those we should've kept it "UX", normalized on the way in, and kept the API strict.

The downside of some of the choices we made is that we kept poorly formatted values; that seemed like a small burden, but also means that every place handling those values must account for them to be potentially poorly formatted;

  • compare case-insensitive
  • trim spaces (possibly multiple times)
  • in some cases, we could even have issues detecting duplicate options where no duplicates are allowed, but because they're formatted differently, we need to do the extra handling to parse before we can detect if it's a duplicate

So, yeah, where possible, I'm trying to find ways out of those situations (handling of "non-normalized" (ubuntu) vs "normalized" (docker.io/.library/ubuntu:latest) image references is another good example of that).

@thaJeztah thaJeztah force-pushed the daemon_no_pkg_parsers branch from 35eeb00 to f0c0c13 Compare January 3, 2025 12:06
@thaJeztah thaJeztah marked this pull request as draft January 3, 2025 12:06
@thaJeztah thaJeztah force-pushed the daemon_no_pkg_parsers branch from f0c0c13 to 40ce0c9 Compare January 6, 2025 17:16
@thaJeztah thaJeztah marked this pull request as ready for review January 6, 2025 17:18
@thaJeztah thaJeztah force-pushed the daemon_no_pkg_parsers branch from 40ce0c9 to 9e2aedb Compare January 8, 2025 09:30
@thaJeztah thaJeztah mentioned this pull request Jan 8, 2025
74 tasks
Move the utility to where it's used, and deprecate the implementation
in pkg/parsers.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah force-pushed the daemon_no_pkg_parsers branch from 9e2aedb to 5b18a79 Compare January 9, 2025 12:14
@thaJeztah
Copy link
Member Author

Rebased (merge conflict in imports only)

@thaJeztah thaJeztah merged commit 957f77e into moby:master Jan 9, 2025
140 checks passed
@thaJeztah thaJeztah deleted the daemon_no_pkg_parsers branch January 9, 2025 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/go-sdk Changes affecting the Go SDK impact/deprecation impact/go-sdk Noteworthy (compatibility changes) in the Go SDK kind/refactor PR's that refactor, or clean-up code status/2-code-review
Projects
Development

Successfully merging this pull request may close these issues.

2 participants