Skip to content

api/types/system: move SecurityOpt and DecodeSecurityOptions to client mod#50825

Merged
thaJeztah merged 1 commit intomoby:masterfrom
austinvazquez:move-decode-security-opts-from-types-to-pkg
Sep 4, 2025
Merged

api/types/system: move SecurityOpt and DecodeSecurityOptions to client mod#50825
thaJeztah merged 1 commit intomoby:masterfrom
austinvazquez:move-decode-security-opts-from-types-to-pkg

Conversation

@austinvazquez
Copy link
Contributor

@austinvazquez austinvazquez commented Aug 27, 2025

- What I did
Partial of #50740

This change moves the system.SecurityOpt and system.KeyValue types into the client along with the reference implementation of system.DecodeSecurityOptions into the pkg/security package. This functionality is used by Docker clients like CLI and buildx along with the daemon backend for API 1.24 support of security options in system info responses.

- How I did it

- How to verify it

- Human readable description for the release notes

api/types/system: move `SecurityOpt` and `DecodeSecurityOptions` to client module

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

@austinvazquez austinvazquez added this to the 29.0.0 milestone Aug 27, 2025
@austinvazquez austinvazquez self-assigned this Aug 27, 2025
@austinvazquez austinvazquez added area/api API impact/api kind/refactor PR's that refactor, or clean-up code release-blocker PRs we want to block a release on labels Aug 27, 2025
@thaJeztah
Copy link
Member

The functionality is used by Docker clients like CLI and buildx along with Docker backend daemon for API 1.24 support of security options in system info responses.

We should probably have a look at some of this; for the CLI, it looks like it's purely for presenting docker info; not sure how buildx uses it. It's slightly odd that we have an API response that gets unmarshaled to a type defined in the API that's.. not strictly the type that it returns 🤔 (even wondering if there should be some unmarshal on the system.Info 🤔

(no good answers here, just thinking out loud)

@austinvazquez
Copy link
Contributor Author

The functionality is used by Docker clients like CLI and buildx along with Docker backend daemon for API 1.24 support of security options in system info responses.

We should probably have a look at some of this; for the CLI, it looks like it's purely for presenting docker info; not sure how buildx uses it. It's slightly odd that we have an API response that gets unmarshaled to a type defined in the API that's.. not strictly the type that it returns 🤔 (even wondering if there should be some unmarshal on the system.Info 🤔

(no good answers here, just thinking out loud)

+1, I wasn't sure about this one. So tried something out thinking others would give feedback for a better idea.

From https://github.com/docker/buildx/blob/177b9809583d03ea4af637c170716c739f7e4762/driver/docker-container/driver.go#L198, it looks like buildx uses it to detect if a container needs to be created with host userns mode.

@austinvazquez
Copy link
Contributor Author

@thaJeztah , some options that come to mind after some thought. Thoughts?

  1. Info.DecodeSecurityOptions so the function is at least on a type defined in the package. Positives: Minimal user changes. (Can even deprecate and stair step users to upgrade) Negatives: Really just ignores the problem.
  2. Make it client's responsibility to parse. Positives: Known users are Docker CLI and Buildx so pretty easy to make those changes. Negatives: Throwing responsibility over the wall.
  3. API change to have the type of SecurityOptions be the type users actually want. (Is this possible without being a breaking change?)

@austinvazquez austinvazquez moved this from New to Open in 🔦 Maintainer spotlight Aug 28, 2025
@austinvazquez austinvazquez force-pushed the move-decode-security-opts-from-types-to-pkg branch from b205c49 to 4379e51 Compare September 3, 2025 14:48
@austinvazquez austinvazquez changed the title api/types/system: move DecodeSecurityOptions to pkg api/types/system: move DecodeSecurityOptions to client mod Sep 3, 2025
@austinvazquez austinvazquez force-pushed the move-decode-security-opts-from-types-to-pkg branch 2 times, most recently from 8584c5c to 421990b Compare September 3, 2025 17:48
… to client

This change moves the `system.SecurityOpt` type and `system.DecodeSecurityOptions` function to the client and adds a set of unit tests to capture current implementation. This change also create a set of daemon backend copies for usage.

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
@austinvazquez austinvazquez force-pushed the move-decode-security-opts-from-types-to-pkg branch from 421990b to e2e9f36 Compare September 3, 2025 17:49
@austinvazquez austinvazquez changed the title api/types/system: move DecodeSecurityOptions to client mod api/types/system: move SecurityOpt and DecodeSecurityOptions to client mod Sep 3, 2025
@austinvazquez austinvazquez marked this pull request as ready for review September 3, 2025 17:58
@austinvazquez
Copy link
Contributor Author

Offline discussion with @thaJeztah and @corhere on this. The thought is to move the functionality into the client (and therefore also a copy into the backend) separating the shape of the data from the semantics of how it is used.

As follow-up work, it would be nice to make secopts in the API return as unmarshalled type but that should be looked at seperately.

@thaJeztah
Copy link
Member

Thanks! Overall, this LGTM; one quick comment before we continue;

As follow-up work, it would be nice to make secopts in the API return as unmarshalled type but that should be looked at seperately.

The only thing I'm considering is if we want to use the existing SecurityOpt struct for that (in which case possibly we should keep it in the API module), or if we want to design that format "from scratch" and define a new type once we do work on that.

@austinvazquez @corhere any thoughts?

Perhaps it's fine to do "from scratch"; the current type isn't overly creative, so perhaps that's the best option, but 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.

actually; let me already LGTM

(good to merge, pending the comment above)

@akerouanton
Copy link
Member

The only thing I'm considering is if we want to use the existing SecurityOpt struct for that (in which case possibly we should keep it in the API module), or if we want to design that format "from scratch" and define a new type once we do work on that.

Perhaps it's fine to do "from scratch"; the current type isn't overly creative, so perhaps that's the best option, but just in case 😅

I think it's fine to merge as is and reconsider what we want to do with Info.SecurityOptions later on. At least, with the type moved out of the api module, we're free to invent something else, maybe with the same name, and shape it however we want.

@thaJeztah
Copy link
Member

Thanks @akerouanton

OK; let's bring this in 👍

@thaJeztah thaJeztah merged commit 8e946ee into moby:master Sep 4, 2025
259 of 260 checks passed
@austinvazquez austinvazquez deleted the move-decode-security-opts-from-types-to-pkg branch September 4, 2025 12:11
@austinvazquez
Copy link
Contributor Author

I think it's fine to merge as is and reconsider what we want to do with Info.SecurityOptions later on. At least, with the type moved out of the api module, we're free to invent something else, maybe with the same name, and shape it however we want.

Yep, aligned with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API impact/api kind/refactor PR's that refactor, or clean-up code release-blocker PRs we want to block a release on

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants