internal/registry: ParseRepositoryInfo: remove unused error return

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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2025-07-25 23:50:41 +02:00
parent f0030712e9
commit 86b5b528a6
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
9 changed files with 12 additions and 16 deletions

View File

@ -105,7 +105,7 @@ To push the complete multi-platform image, remove the --platform flag.
}
// Resolve the Repository name from fqn to RepositoryInfo
repoInfo, _ := registry.ParseRepositoryInfo(ref)
repoInfo := registry.ParseRepositoryInfo(ref)
// Resolve the Auth config relevant for this server
authConfig := command.ResolveAuthConfig(dockerCli.ConfigFile(), repoInfo.Index)

View File

@ -66,8 +66,7 @@ func buildPullConfig(ctx context.Context, dockerCli command.Cli, opts pluginOpti
return client.PluginInstallOptions{}, err
}
repoInfo, _ := registry.ParseRepositoryInfo(ref)
repoInfo := registry.ParseRepositoryInfo(ref)
remote := ref.String()
_, isCanonical := ref.(reference.Canonical)

View File

@ -49,7 +49,7 @@ func runPush(ctx context.Context, dockerCli command.Cli, opts pushOptions) error
named = reference.TagNameOnly(named)
repoInfo, _ := registry.ParseRepositoryInfo(named)
repoInfo := registry.ParseRepositoryInfo(named)
authConfig := command.ResolveAuthConfig(dockerCli.ConfigFile(), repoInfo.Index)
encodedAuth, err := registrytypes.EncodeAuthConfig(authConfig)
if err != nil {

View File

@ -51,7 +51,7 @@ func resolveServiceImageDigestContentTrust(dockerCli command.Cli, service *swarm
}
func trustedResolveDigest(cli command.Cli, ref reference.NamedTagged) (reference.Canonical, error) {
repoInfo, _ := registry.ParseRepositoryInfo(ref)
repoInfo := registry.ParseRepositoryInfo(ref)
authConfig := command.ResolveAuthConfig(cli.ConfigFile(), repoInfo.Index)
notaryRepo, err := trust.GetNotaryRepository(cli.In(), cli.Out(), command.UserAgent(), repoInfo, &authConfig, "pull")

View File

@ -34,7 +34,7 @@ func (r repositoryEndpoint) BaseURL() string {
func newDefaultRepositoryEndpoint(ref reference.Named, insecure bool) (repositoryEndpoint, error) {
repoName := reference.TrimNamed(ref)
repoInfo, _ := registry.ParseRepositoryInfo(ref)
repoInfo := registry.ParseRepositoryInfo(ref)
indexInfo := repoInfo.Index
endpoint, err := getDefaultEndpoint(ref, !indexInfo.Secure)

View File

@ -221,7 +221,7 @@ func (c *client) iterateEndpoints(ctx context.Context, namedRef reference.Named,
}
repoName := reference.TrimNamed(namedRef)
repoInfo, _ := registry.ParseRepositoryInfo(namedRef)
repoInfo := registry.ParseRepositoryInfo(namedRef)
indexInfo := repoInfo.Index
confirmedTLSRegistries := make(map[string]bool)
@ -285,7 +285,7 @@ func allEndpoints(namedRef reference.Named, insecure bool) ([]registry.APIEndpoi
if err != nil {
return nil, err
}
repoInfo, _ := registry.ParseRepositoryInfo(namedRef)
repoInfo := registry.ParseRepositoryInfo(namedRef)
endpoints, err := registryService.Endpoints(context.TODO(), reference.Domain(repoInfo.Name))
logrus.Debugf("endpoints for %s: %v", namedRef, endpoints)
return endpoints, err

View File

@ -321,7 +321,7 @@ func GetImageReferencesAndAuth(ctx context.Context,
}
// Resolve the Repository name from fqn to RepositoryInfo
repoInfo, _ := registry.ParseRepositoryInfo(ref)
repoInfo := registry.ParseRepositoryInfo(ref)
authConfig := authResolver(ctx, repoInfo.Index)
return ImageRefAndAuth{
original: imgName,

View File

@ -254,9 +254,7 @@ func validateHostPort(s string) error {
// ParseRepositoryInfo performs the breakdown of a repository name into a
// [RepositoryInfo], but lacks registry configuration.
//
// It is used by the Docker cli to interact with registry-related endpoints.
func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
func ParseRepositoryInfo(reposName reference.Named) *RepositoryInfo {
indexName := normalizeIndexName(reference.Domain(reposName))
if indexName == IndexName {
return &RepositoryInfo{
@ -266,7 +264,7 @@ func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
Secure: true,
Official: true,
},
}, nil
}
}
return &RepositoryInfo{
@ -275,7 +273,7 @@ func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
Name: indexName,
Secure: !isInsecure(indexName),
},
}, nil
}
}
// isInsecure is used to detect whether a registry domain or IP-address is allowed

View File

@ -269,8 +269,7 @@ func TestParseRepositoryInfo(t *testing.T) {
named, err := reference.ParseNormalizedNamed(reposName)
assert.NilError(t, err)
repoInfo, err := ParseRepositoryInfo(named)
assert.NilError(t, err)
repoInfo := ParseRepositoryInfo(named)
assert.Check(t, is.DeepEqual(repoInfo.Index, expected.Index))
assert.Check(t, is.Equal(reference.Path(repoInfo.Name), expected.RemoteName))