Skip to content

registry: deprecate RepositoryInfo.Official field#49567

Merged
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:deprecate_repositoryinfo_official
Mar 3, 2025
Merged

registry: deprecate RepositoryInfo.Official field#49567
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:deprecate_repositoryinfo_official

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Mar 3, 2025

This field indicates whether a repository is an official image (Docker Library / Docker Official Images). This information is deducted from the image reference, and not used anywhere, other than in tests.

The RepositoryInfo and IndexInfo types were originally introduced in 568f86e, with their fields documented in 4fcb9ac.

At the time, the Official field was only used for docker push to produce a custom error message if someone would attempt to push an official image to docker hub (assuming nobody would be able to do so);

moby/api/client/commands.go

Lines 1184 to 1194 in 6870bde

// If we're not using a custom registry, we know the restrictions
// applied to repository names and can warn the user in advance.
// Custom repositories can have different rules, and we must also
// allow pushing by image ID.
if repoInfo.Official {
username := authConfig.Username
if username == "" {
username = "<user>"
}
return fmt.Errorf("You cannot push a \"root\" repository. Please rename your repository to <user>/<repo> (ex: %s/%s)", username, repoInfo.LocalName)
}

Before that commit, the condition for this error message was based on the given image reference directly; b370acd

moby/commands.go

Lines 421 to 428 in b370acd

tmp := strings.SplitN(local, "/", 2)
if len(tmp) == 1 {
return fmt.Errorf(
"Impossible to push a \"root\" repository. Please rename your repository in <user>/<repo> (ex: %s/%s)",
srv.runtime.authConfig.Username, local)
} else {
remote = local
}

This patch deprecates the field, because it's not used, and removes tests related to it.

- Human readable description for the release notes

Go SDK: `registry`: Deprecate `RepositoryInfo.Official` field

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

This field indicates whether a repository is an official image (Docker
Library / Docker Official Images). This information is deducted from the
image reference, and not used anywhere, other than in tests.

The `RepositoryInfo` and `IndexInfo` types were originally introduced in
568f86e, with their fields documented in
4fcb9ac.

At the time, the `Official` field was only used for `docker push` to produce
a custom error message if someone would attempt to push an official image
to docker hub (assuming nobody would be able to do so);
https://github.com/moby/moby/blob/6870bde5847d4484d87f91baf58edc52f575ea5d/api/client/commands.go#L1184-L1194

Before that commit, the condition for this error message was based on the
given image reference directly; b370acd
https://github.com/moby/moby/blob/b370acd679622239849b1dfbe05d61804aeb7162/commands.go#L421-L428

This patch deprecates the field, because it's not used, and removes
tests related to it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah added status/2-code-review impact/deprecation kind/refactor PR's that refactor, or clean-up code area/go-sdk impact/go-sdk Noteworthy (compatibility changes) in the Go SDK labels Mar 3, 2025
@thaJeztah thaJeztah added this to the 28.0.2 milestone Mar 3, 2025
@thaJeztah thaJeztah merged commit 960a39b into moby:master Mar 3, 2025
165 checks passed
@thaJeztah thaJeztah deleted the deprecate_repositoryinfo_official branch March 3, 2025 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/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

None yet

Development

Successfully merging this pull request may close these issues.

2 participants