Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/command/image/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions cli/command/plugin/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cli/command/plugin/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cli/command/service/trust.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion cli/registry/client/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cli/registry/client/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cli/trust/trust.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 3 additions & 5 deletions internal/registry/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -266,7 +264,7 @@ func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
Secure: true,
Official: true,
},
}, nil
}
}

return &RepositoryInfo{
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions internal/registry/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Loading