Skip to content

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Jul 29, 2025

@thaJeztah thaJeztah marked this pull request as draft July 29, 2025 20:25
@codecov-commenter
Copy link

codecov-commenter commented Jul 29, 2025

@thaJeztah thaJeztah changed the title 28.x fork registry [28.x] add internal fork of docker/docker/registry Jul 29, 2025
@thaJeztah thaJeztah added this to the 28.4.0 milestone Aug 13, 2025
@thaJeztah thaJeztah marked this pull request as ready for review August 14, 2025 13:54
@thaJeztah thaJeztah marked this pull request as draft August 14, 2025 15:59
@thaJeztah thaJeztah force-pushed the 28.x_fork_registry branch 2 times, most recently from 10cc8d4 to d9ee285 Compare August 14, 2025 19:50
This utility was only used in the CLI, but the implementation was
based on it being used on the daemon side, so included resolving
the host's IP-address, mirrors, etc.

The only reason it's used in the CLI is to provide credentials for
the registry that's being searched, so reduce it to just that.

There's more cleaning up to do in this area, so to make our lives
easier, it's implemented locally as non-exported functions; likely
to be replaced with something else.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit e504faf)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
This adds an internal fork of [github.com/docker/docker/registry], taken
at commit [moby@f651a5d]. Git history  was not preserved in this fork,
but can be found using the URLs provided.

This fork was created to remove the dependency on the "Moby" codebase,
and because the CLI only needs a subset of its features. The original
package was written specifically for use in the daemon code, and includes
functionality that cannot be used in the CLI.

[github.com/docker/docker/registry]: https://pkg.go.dev/github.com/docker/[email protected]+incompatible/registry
[moby@49306c6]: https://github.com/moby/moby/tree/49306c607b72c5bf0a8e426f5a9760fa5ef96ea0/registry

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit f6b90bc)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit 7716219)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
The CLI does not have information about mirrors, and doesn't
configure them, so we can remove these parts.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit e0b351b)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit 7cf245d)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
It's not matched anywhere, so we can just return a plain error.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit dad2e67)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
It was only used in a single place; inline it there.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit dc41365)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
now that we no longer need to account for mirrors, these were
identical, so just use a single one.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit 5322aff)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
It was written to be used as validate-func for command-line flags, which
we don't use it for (which for CLI-flags includes normalizing the value).

The validation itself didn't add much; it only checked the registry didn't
start or end with a hyphen (which would still fail when parsing).

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit 2607ba8)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
The registry.ServiceConfig struct in the API types was meant for the
registry configuration on the daemon side; it has variuos fields we
don't use, defines methods for (un)marshaling JSON, and a custom version
of `net.IPNet`, also to (un)marshal JSON.

None of that is needed, so let's change it to a local type, and implement
a constructor (as we now only have "insecure registries" to care
about).

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit 219cfc8)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit c297770)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit cd277a5)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
    internal/registry/errors.go:26:43: use-any: since Go 1.18 'interface{}' can be replaced by 'any' (revive)
    func invalidParamf(format string, args ...interface{}) error {
                                              ^
    internal/registry/registry_mock_test.go:52:51: use-any: since Go 1.18 'interface{}' can be replaced by 'any' (revive)
    func writeResponse(w http.ResponseWriter, message interface{}, code int) {
                                                      ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit f907c7a)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Removed the error return from the `ParseRepositoryInfo` function.
There are no validation steps inside `ParseRepositoryInfo` which
could cause an error, so we always returned a nil error.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit 86b5b52)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Most places only use IndexInfo (and may not even need that), so replace
the use of ParseRepositoryInfo for NewIndexInfo, and move the RepositoryInfo
type to the trust package, which uses it as part of its ImageRefAndAuth
struct.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit 21e8bbc)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah marked this pull request as ready for review August 15, 2025 17:10
@austinvazquez austinvazquez merged commit 0718529 into docker:28.x Aug 16, 2025
100 of 101 checks passed
@thaJeztah thaJeztah deleted the 28.x_fork_registry branch August 16, 2025 16:24
@thaJeztah
Copy link
Member Author

Thanks for reviewing @austinvazquez ❤️ ❤️ ❤️

I know it was quite some changes from the look of it, but hope that breaking it down into smaller commit to walk through every step taken helped verify correctness. (most parts are really just moving things around and removing bits not used).

@austinvazquez
Copy link
Contributor

+1, @thaJeztah it definitely helps me. I do try to take some time to read through them if I can even if it's backports as I usually can learn a cool thing or two. 😁

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

Successfully merging this pull request may close these issues.

3 participants