From 7e01a3a8a9fb0515296d118cb85ad062547625a8 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 24 Jul 2025 02:04:37 +0200 Subject: [PATCH] internal/registry: Service.Auth remove unused statusmessage return Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 7cf245d2f7ab5338bc325913f961f6f4aec88be6) Signed-off-by: Sebastiaan van Stijn --- cli/command/registry/login.go | 2 +- internal/registry/service.go | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cli/command/registry/login.go b/cli/command/registry/login.go index 54c3e462d6..a216908505 100644 --- a/cli/command/registry/login.go +++ b/cli/command/registry/login.go @@ -288,7 +288,7 @@ func loginClientSide(ctx context.Context, auth registrytypes.AuthConfig) (*regis return nil, err } - _, token, err := svc.Auth(ctx, &auth, command.UserAgent()) + token, err := svc.Auth(ctx, &auth, command.UserAgent()) if err != nil { return nil, err } diff --git a/internal/registry/service.go b/internal/registry/service.go index 9e1accc04c..36e95d8c63 100644 --- a/internal/registry/service.go +++ b/internal/registry/service.go @@ -33,8 +33,7 @@ func NewService(options ServiceOptions) (*Service, error) { // Auth contacts the public registry with the provided credentials, // and returns OK if authentication was successful. // It can be used to verify the validity of a client's credentials. -func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, userAgent string) (statusMessage, token string, _ error) { - // TODO Use ctx when searching for repositories +func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, userAgent string) (token string, _ error) { registryHostName := IndexHostname if authConfig.ServerAddress != "" { @@ -44,7 +43,7 @@ func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, use } u, err := url.Parse(serverAddress) if err != nil { - return "", "", invalidParamWrapf(err, "unable to parse server address") + return "", invalidParamWrapf(err, "unable to parse server address") } registryHostName = u.Host } @@ -53,9 +52,9 @@ func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, use endpoints, err := s.lookupV2Endpoints(ctx, registryHostName) if err != nil { if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) { - return "", "", err + return "", err } - return "", "", invalidParam(err) + return "", invalidParam(err) } var lastErr error @@ -64,7 +63,7 @@ func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, use if err != nil { if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) || cerrdefs.IsUnauthorized(err) { // Failed to authenticate; don't continue with (non-TLS) endpoints. - return "", "", err + return "", err } // Try next endpoint log.G(ctx).WithFields(log.Fields{ @@ -75,11 +74,10 @@ func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, use continue } - // TODO(thaJeztah): move the statusMessage to the API endpoint; we don't need to produce that here? - return "Login Succeeded", authToken, nil + return authToken, nil } - return "", "", lastErr + return "", lastErr } // APIEndpoint represents a remote API endpoint