mirror of https://github.com/docker/cli.git
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:
parent
f0030712e9
commit
86b5b528a6
|
|
@ -105,7 +105,7 @@ To push the complete multi-platform image, remove the --platform flag.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve the Repository name from fqn to RepositoryInfo
|
// Resolve the Repository name from fqn to RepositoryInfo
|
||||||
repoInfo, _ := registry.ParseRepositoryInfo(ref)
|
repoInfo := registry.ParseRepositoryInfo(ref)
|
||||||
|
|
||||||
// Resolve the Auth config relevant for this server
|
// Resolve the Auth config relevant for this server
|
||||||
authConfig := command.ResolveAuthConfig(dockerCli.ConfigFile(), repoInfo.Index)
|
authConfig := command.ResolveAuthConfig(dockerCli.ConfigFile(), repoInfo.Index)
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,7 @@ func buildPullConfig(ctx context.Context, dockerCli command.Cli, opts pluginOpti
|
||||||
return client.PluginInstallOptions{}, err
|
return client.PluginInstallOptions{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
repoInfo, _ := registry.ParseRepositoryInfo(ref)
|
repoInfo := registry.ParseRepositoryInfo(ref)
|
||||||
|
|
||||||
remote := ref.String()
|
remote := ref.String()
|
||||||
|
|
||||||
_, isCanonical := ref.(reference.Canonical)
|
_, isCanonical := ref.(reference.Canonical)
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ func runPush(ctx context.Context, dockerCli command.Cli, opts pushOptions) error
|
||||||
|
|
||||||
named = reference.TagNameOnly(named)
|
named = reference.TagNameOnly(named)
|
||||||
|
|
||||||
repoInfo, _ := registry.ParseRepositoryInfo(named)
|
repoInfo := registry.ParseRepositoryInfo(named)
|
||||||
authConfig := command.ResolveAuthConfig(dockerCli.ConfigFile(), repoInfo.Index)
|
authConfig := command.ResolveAuthConfig(dockerCli.ConfigFile(), repoInfo.Index)
|
||||||
encodedAuth, err := registrytypes.EncodeAuthConfig(authConfig)
|
encodedAuth, err := registrytypes.EncodeAuthConfig(authConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ func resolveServiceImageDigestContentTrust(dockerCli command.Cli, service *swarm
|
||||||
}
|
}
|
||||||
|
|
||||||
func trustedResolveDigest(cli command.Cli, ref reference.NamedTagged) (reference.Canonical, error) {
|
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)
|
authConfig := command.ResolveAuthConfig(cli.ConfigFile(), repoInfo.Index)
|
||||||
|
|
||||||
notaryRepo, err := trust.GetNotaryRepository(cli.In(), cli.Out(), command.UserAgent(), repoInfo, &authConfig, "pull")
|
notaryRepo, err := trust.GetNotaryRepository(cli.In(), cli.Out(), command.UserAgent(), repoInfo, &authConfig, "pull")
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ func (r repositoryEndpoint) BaseURL() string {
|
||||||
|
|
||||||
func newDefaultRepositoryEndpoint(ref reference.Named, insecure bool) (repositoryEndpoint, error) {
|
func newDefaultRepositoryEndpoint(ref reference.Named, insecure bool) (repositoryEndpoint, error) {
|
||||||
repoName := reference.TrimNamed(ref)
|
repoName := reference.TrimNamed(ref)
|
||||||
repoInfo, _ := registry.ParseRepositoryInfo(ref)
|
repoInfo := registry.ParseRepositoryInfo(ref)
|
||||||
indexInfo := repoInfo.Index
|
indexInfo := repoInfo.Index
|
||||||
|
|
||||||
endpoint, err := getDefaultEndpoint(ref, !indexInfo.Secure)
|
endpoint, err := getDefaultEndpoint(ref, !indexInfo.Secure)
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,7 @@ func (c *client) iterateEndpoints(ctx context.Context, namedRef reference.Named,
|
||||||
}
|
}
|
||||||
|
|
||||||
repoName := reference.TrimNamed(namedRef)
|
repoName := reference.TrimNamed(namedRef)
|
||||||
repoInfo, _ := registry.ParseRepositoryInfo(namedRef)
|
repoInfo := registry.ParseRepositoryInfo(namedRef)
|
||||||
indexInfo := repoInfo.Index
|
indexInfo := repoInfo.Index
|
||||||
|
|
||||||
confirmedTLSRegistries := make(map[string]bool)
|
confirmedTLSRegistries := make(map[string]bool)
|
||||||
|
|
@ -285,7 +285,7 @@ func allEndpoints(namedRef reference.Named, insecure bool) ([]registry.APIEndpoi
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
repoInfo, _ := registry.ParseRepositoryInfo(namedRef)
|
repoInfo := registry.ParseRepositoryInfo(namedRef)
|
||||||
endpoints, err := registryService.Endpoints(context.TODO(), reference.Domain(repoInfo.Name))
|
endpoints, err := registryService.Endpoints(context.TODO(), reference.Domain(repoInfo.Name))
|
||||||
logrus.Debugf("endpoints for %s: %v", namedRef, endpoints)
|
logrus.Debugf("endpoints for %s: %v", namedRef, endpoints)
|
||||||
return endpoints, err
|
return endpoints, err
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,7 @@ func GetImageReferencesAndAuth(ctx context.Context,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve the Repository name from fqn to RepositoryInfo
|
// Resolve the Repository name from fqn to RepositoryInfo
|
||||||
repoInfo, _ := registry.ParseRepositoryInfo(ref)
|
repoInfo := registry.ParseRepositoryInfo(ref)
|
||||||
authConfig := authResolver(ctx, repoInfo.Index)
|
authConfig := authResolver(ctx, repoInfo.Index)
|
||||||
return ImageRefAndAuth{
|
return ImageRefAndAuth{
|
||||||
original: imgName,
|
original: imgName,
|
||||||
|
|
|
||||||
|
|
@ -254,9 +254,7 @@ func validateHostPort(s string) error {
|
||||||
|
|
||||||
// ParseRepositoryInfo performs the breakdown of a repository name into a
|
// ParseRepositoryInfo performs the breakdown of a repository name into a
|
||||||
// [RepositoryInfo], but lacks registry configuration.
|
// [RepositoryInfo], but lacks registry configuration.
|
||||||
//
|
func ParseRepositoryInfo(reposName reference.Named) *RepositoryInfo {
|
||||||
// It is used by the Docker cli to interact with registry-related endpoints.
|
|
||||||
func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
|
|
||||||
indexName := normalizeIndexName(reference.Domain(reposName))
|
indexName := normalizeIndexName(reference.Domain(reposName))
|
||||||
if indexName == IndexName {
|
if indexName == IndexName {
|
||||||
return &RepositoryInfo{
|
return &RepositoryInfo{
|
||||||
|
|
@ -266,7 +264,7 @@ func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
|
||||||
Secure: true,
|
Secure: true,
|
||||||
Official: true,
|
Official: true,
|
||||||
},
|
},
|
||||||
}, nil
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &RepositoryInfo{
|
return &RepositoryInfo{
|
||||||
|
|
@ -275,7 +273,7 @@ func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
|
||||||
Name: indexName,
|
Name: indexName,
|
||||||
Secure: !isInsecure(indexName),
|
Secure: !isInsecure(indexName),
|
||||||
},
|
},
|
||||||
}, nil
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// isInsecure is used to detect whether a registry domain or IP-address is allowed
|
// isInsecure is used to detect whether a registry domain or IP-address is allowed
|
||||||
|
|
|
||||||
|
|
@ -269,8 +269,7 @@ func TestParseRepositoryInfo(t *testing.T) {
|
||||||
named, err := reference.ParseNormalizedNamed(reposName)
|
named, err := reference.ParseNormalizedNamed(reposName)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
repoInfo, err := ParseRepositoryInfo(named)
|
repoInfo := ParseRepositoryInfo(named)
|
||||||
assert.NilError(t, err)
|
|
||||||
|
|
||||||
assert.Check(t, is.DeepEqual(repoInfo.Index, expected.Index))
|
assert.Check(t, is.DeepEqual(repoInfo.Index, expected.Index))
|
||||||
assert.Check(t, is.Equal(reference.Path(repoInfo.Name), expected.RemoteName))
|
assert.Check(t, is.Equal(reference.Path(repoInfo.Name), expected.RemoteName))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue