Skip to content

Commit 6f46cd2

Browse files
committed
cli/registry/client: deprecate RepoNameForReference
This function was added in 02719bd, and used newDefaultRepositoryEndpoint to get repository info for the given image-reference. newDefaultRepositoryEndpoint uses registry.ParseRepositoryInfo under the hood, but the only information used from the result was the Name field, which is set using `reference.TrimNamed(name)`. The possible error returned was based on the domain-name of the image, and only checked for the domain to not start, or end with a hyphen ("-"). This patch removes the use of RepoNameForReference, deprecates it, and inlines the code used by it. There are no known consumers of this function, so we can consider removing it in the first possible release after this (which can be a minor release). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 1a165fd commit 6f46cd2

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

cli/command/manifest/push.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,10 @@ func buildPushRequest(manifests []types.ImageManifest, targetRef reference.Named
9999
return req, err
100100
}
101101

102-
targetRepoName, err := registryclient.RepoNameForReference(targetRef)
103-
if err != nil {
104-
return req, err
105-
}
102+
targetRepoName := reference.Path(reference.TrimNamed(targetRef))
106103

107104
for _, imageManifest := range manifests {
108-
manifestRepoName, err := registryclient.RepoNameForReference(imageManifest.Ref)
109-
if err != nil {
110-
return req, err
111-
}
112-
105+
manifestRepoName := reference.Path(reference.TrimNamed(imageManifest.Ref))
113106
repoName, _ := reference.WithName(manifestRepoName)
114107
if repoName.Name() != targetRepoName {
115108
blobs, err := buildBlobRequestList(imageManifest, repoName)

cli/registry/client/endpoint.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,11 @@ func getHTTPTransport(authConfig registrytypes.AuthConfig, endpoint registry.API
103103
return transport.NewTransport(base, modifiers...), nil
104104
}
105105

106-
// RepoNameForReference returns the repository name from a reference
106+
// RepoNameForReference returns the repository name from a reference.
107+
//
108+
// Deprecated: this function is no longer used and will be removed in the next release.
107109
func RepoNameForReference(ref reference.Named) (string, error) {
108-
// insecure is fine since this only returns the name
109-
repo, err := newDefaultRepositoryEndpoint(ref, false)
110-
if err != nil {
111-
return "", err
112-
}
113-
return repo.Name(), nil
110+
return reference.Path(reference.TrimNamed(ref)), nil
114111
}
115112

116113
type existingTokenHandler struct {

0 commit comments

Comments
 (0)