From 00698d6ac483c7df25ae8509cd2d5e4a6acbf665 Mon Sep 17 00:00:00 2001 From: Ogulcan Aydogan Date: Wed, 10 Jun 2026 23:12:33 +0100 Subject: [PATCH] fix: use %w instead of %v for error wrapping in login and logout Switch return fmt.Errorf calls in cmd/notation/login.go and cmd/notation/logout.go from %v to %w so callers can inspect the underlying error via errors.Is/errors.As. The house style across the rest of the codebase already uses %w for these patterns. Signed-off-by: Ogulcan Aydogan --- cmd/notation/login.go | 6 +++--- cmd/notation/logout.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/notation/login.go b/cmd/notation/login.go index d7d4309e6..711d5d20d 100644 --- a/cmd/notation/login.go +++ b/cmd/notation/login.go @@ -112,16 +112,16 @@ func runLogin(ctx context.Context, opts *loginOpts) error { cred := opts.Credential() credsStore, err := auth.NewCredentialsStore() if err != nil { - return fmt.Errorf("failed to get credentials store: %v", err) + return fmt.Errorf("failed to get credentials store: %w", err) } registry, err := getRegistryLoginClient(ctx, &opts.SecureFlagOpts, serverAddress) if err != nil { - return fmt.Errorf("failed to get registry client: %v", err) + return fmt.Errorf("failed to get registry client: %w", err) } if err := credentials.Login(ctx, credsStore, registry, cred); err != nil { registryName := registry.Reference.Registry if !errors.Is(err, credentials.ErrPlaintextPutDisabled) { - return fmt.Errorf("failed to log in to %s: %v", registryName, err) + return fmt.Errorf("failed to log in to %s: %w", registryName, err) } // ErrPlaintextPutDisabled returned by Login() indicates that the diff --git a/cmd/notation/logout.go b/cmd/notation/logout.go index ef89c2b31..f9678bb23 100644 --- a/cmd/notation/logout.go +++ b/cmd/notation/logout.go @@ -56,10 +56,10 @@ func runLogout(ctx context.Context, opts *logoutOpts) error { ctx = opts.LoggingFlagOpts.InitializeLogger(ctx) credsStore, err := auth.NewCredentialsStore() if err != nil { - return fmt.Errorf("failed to get credentials store: %v", err) + return fmt.Errorf("failed to get credentials store: %w", err) } if err := credentials.Logout(ctx, credsStore, opts.server); err != nil { - return fmt.Errorf("failed to log out of %s: %v", opts.server, err) + return fmt.Errorf("failed to log out of %s: %w", opts.server, err) } fmt.Println("Logout Succeeded")