Skip to content

Commit 3000dc9

Browse files
committed
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> (cherry picked from commit 86b5b52) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 6f336b4 commit 3000dc9

9 files changed

Lines changed: 12 additions & 16 deletions

File tree

cli/command/image/push.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ To push the complete multi-platform image, remove the --platform flag.
107107
}
108108

109109
// Resolve the Repository name from fqn to RepositoryInfo
110-
repoInfo, _ := registry.ParseRepositoryInfo(ref)
110+
repoInfo := registry.ParseRepositoryInfo(ref)
111111

112112
// Resolve the Auth config relevant for this server
113113
authConfig := command.ResolveAuthConfig(dockerCli.ConfigFile(), repoInfo.Index)

cli/command/plugin/install.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ func buildPullConfig(ctx context.Context, dockerCli command.Cli, opts pluginOpti
6565
return types.PluginInstallOptions{}, err
6666
}
6767

68-
repoInfo, _ := registry.ParseRepositoryInfo(ref)
69-
68+
repoInfo := registry.ParseRepositoryInfo(ref)
7069
remote := ref.String()
7170

7271
_, isCanonical := ref.(reference.Canonical)

cli/command/plugin/push.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func runPush(ctx context.Context, dockerCli command.Cli, opts pushOptions) error
4949

5050
named = reference.TagNameOnly(named)
5151

52-
repoInfo, _ := registry.ParseRepositoryInfo(named)
52+
repoInfo := registry.ParseRepositoryInfo(named)
5353
authConfig := command.ResolveAuthConfig(dockerCli.ConfigFile(), repoInfo.Index)
5454
encodedAuth, err := registrytypes.EncodeAuthConfig(authConfig)
5555
if err != nil {

cli/command/service/trust.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func resolveServiceImageDigestContentTrust(dockerCli command.Cli, service *swarm
5151
}
5252

5353
func trustedResolveDigest(cli command.Cli, ref reference.NamedTagged) (reference.Canonical, error) {
54-
repoInfo, _ := registry.ParseRepositoryInfo(ref)
54+
repoInfo := registry.ParseRepositoryInfo(ref)
5555
authConfig := command.ResolveAuthConfig(cli.ConfigFile(), repoInfo.Index)
5656

5757
notaryRepo, err := trust.GetNotaryRepository(cli.In(), cli.Out(), command.UserAgent(), repoInfo, &authConfig, "pull")

cli/registry/client/endpoint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (r repositoryEndpoint) BaseURL() string {
3434

3535
func newDefaultRepositoryEndpoint(ref reference.Named, insecure bool) (repositoryEndpoint, error) {
3636
repoName := reference.TrimNamed(ref)
37-
repoInfo, _ := registry.ParseRepositoryInfo(ref)
37+
repoInfo := registry.ParseRepositoryInfo(ref)
3838
indexInfo := repoInfo.Index
3939

4040
endpoint, err := getDefaultEndpoint(ref, !indexInfo.Secure)

cli/registry/client/fetcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func (c *client) iterateEndpoints(ctx context.Context, namedRef reference.Named,
221221
}
222222

223223
repoName := reference.TrimNamed(namedRef)
224-
repoInfo, _ := registry.ParseRepositoryInfo(namedRef)
224+
repoInfo := registry.ParseRepositoryInfo(namedRef)
225225
indexInfo := repoInfo.Index
226226

227227
confirmedTLSRegistries := make(map[string]bool)
@@ -285,7 +285,7 @@ func allEndpoints(namedRef reference.Named, insecure bool) ([]registry.APIEndpoi
285285
if err != nil {
286286
return nil, err
287287
}
288-
repoInfo, _ := registry.ParseRepositoryInfo(namedRef)
288+
repoInfo := registry.ParseRepositoryInfo(namedRef)
289289
endpoints, err := registryService.Endpoints(context.TODO(), reference.Domain(repoInfo.Name))
290290
logrus.Debugf("endpoints for %s: %v", namedRef, endpoints)
291291
return endpoints, err

cli/trust/trust.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func GetImageReferencesAndAuth(ctx context.Context,
321321
}
322322

323323
// Resolve the Repository name from fqn to RepositoryInfo
324-
repoInfo, _ := registry.ParseRepositoryInfo(ref)
324+
repoInfo := registry.ParseRepositoryInfo(ref)
325325
authConfig := authResolver(ctx, repoInfo.Index)
326326
return ImageRefAndAuth{
327327
original: imgName,

internal/registry/config.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,7 @@ func validateHostPort(s string) error {
254254

255255
// ParseRepositoryInfo performs the breakdown of a repository name into a
256256
// [RepositoryInfo], but lacks registry configuration.
257-
//
258-
// It is used by the Docker cli to interact with registry-related endpoints.
259-
func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
257+
func ParseRepositoryInfo(reposName reference.Named) *RepositoryInfo {
260258
indexName := normalizeIndexName(reference.Domain(reposName))
261259
if indexName == IndexName {
262260
return &RepositoryInfo{
@@ -266,7 +264,7 @@ func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
266264
Secure: true,
267265
Official: true,
268266
},
269-
}, nil
267+
}
270268
}
271269

272270
return &RepositoryInfo{
@@ -275,7 +273,7 @@ func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
275273
Name: indexName,
276274
Secure: !isInsecure(indexName),
277275
},
278-
}, nil
276+
}
279277
}
280278

281279
// isInsecure is used to detect whether a registry domain or IP-address is allowed

internal/registry/registry_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ func TestParseRepositoryInfo(t *testing.T) {
269269
named, err := reference.ParseNormalizedNamed(reposName)
270270
assert.NilError(t, err)
271271

272-
repoInfo, err := ParseRepositoryInfo(named)
273-
assert.NilError(t, err)
272+
repoInfo := ParseRepositoryInfo(named)
274273

275274
assert.Check(t, is.DeepEqual(repoInfo.Index, expected.Index))
276275
assert.Check(t, is.Equal(reference.Path(repoInfo.Name), expected.RemoteName))

0 commit comments

Comments
 (0)