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
8 changes: 4 additions & 4 deletions cmd/kosli/apiKey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func (suite *ApiKeyCommandTestSuite) TestUpdatePartialFailure() {
wantError: true,
name: "rotate prints already-rotated keys then surfaces the error",
cmd: "rotate api-key k1 k2 -s test-sa --output json" + args,
goldenRegex: `(?s)sk_one.*Error: API key not found`,
goldenRegex: `(?s)sk_one.*Error: failed to rotate API key: API key not found`,
},
}

Expand Down Expand Up @@ -360,7 +360,7 @@ func (suite *ApiKeyCommandTestSuite) TestDeletePartialFailure() {
wantError: true,
name: "delete reports deleted keys before a later key fails",
cmd: "delete api-key k1 k2 -s test-sa --assume-yes" + args,
goldenRegex: `(?s)API key k1 for service account test-sa was deleted!.*already deleted before this failure: k1.*failed to delete API key k2.*API key not found`,
goldenRegex: `(?s)API key k1 for service account test-sa was deleted!.*already deleted before this failure: k1.*failed to delete API key: API key not found`,
},
}

Expand All @@ -384,7 +384,7 @@ func (suite *ApiKeyCommandTestSuite) TestDeleteApiKeyNotFound() {
wantError: true,
name: "delete surfaces a 404 from the API as an error",
cmd: "delete api-key missing-key --service-account test-sa --assume-yes" + args,
goldenRegex: `(?s)failed to delete API key missing-key.*API key not found`,
goldenRegex: `(?s)failed to delete API key: API key not found`,
},
}

Expand Down Expand Up @@ -421,7 +421,7 @@ func (suite *ApiKeyCommandTestSuite) TestApiErrorsAreSurfaced() {
wantError: true,
name: "rotate surfaces a 404 from the API as an error",
cmd: "rotate api-key missing-key --service-account test-sa" + args,
goldenRegex: `Error: API key not found`,
goldenRegex: `Error: failed to rotate API key: API key not found`,
},
{
wantError: true,
Expand Down
2 changes: 1 addition & 1 deletion cmd/kosli/deleteApiKey.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (o *deleteApiKeyOptions) run(in io.Reader, args []string) error {
}
if _, err := kosliClient.Do(reqParams); err != nil {
reportAlreadyDeleted(i)
return fmt.Errorf("failed to delete API key %s: %w", keyID, err)
return fmt.Errorf("failed to delete API key: %w", err)
Comment thread
mbevc1 marked this conversation as resolved.
Comment thread
mbevc1 marked this conversation as resolved.
}
if !global.DryRun {
logger.Info("API key %s for service account %s was deleted!", style(logger.Out, keyID, ansiBold, ansiCyan), o.serviceAccount)
Expand Down
3 changes: 2 additions & 1 deletion cmd/kosli/rotateApiKey.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
Expand Down Expand Up @@ -125,7 +126,7 @@ func (o *rotateApiKeyOptions) run(out io.Writer, args []string) error {
}
response, err := kosliClient.Do(reqParams)
if err != nil {
runErr = err
runErr = fmt.Errorf("failed to rotate API key: %w", err)
Comment thread
mbevc1 marked this conversation as resolved.
break
}
if !global.DryRun {
Expand Down