Skip to content

Commit

Permalink
OCM-7169 | fix: warn revoked break glass credential
Browse files Browse the repository at this point in the history
Signed-off-by: Maggie Chen <[email protected]>
  • Loading branch information
chenz4027 committed May 9, 2024
1 parent 0f7d409 commit 0a3c0ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cmd/describe/breakglasscredential/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ func runWithRuntime(r *rosa.Runtime, cmd *cobra.Command, argv []string) error {
}

if breakGlassCredentialConfig.Status() == cmv1.BreakGlassCredentialStatusRevoked {
return fmt.Errorf("Break glass credential '%s' for cluster '%s' has been revoked.",
r.Reporter.Warnf("Break glass credential '%s' for cluster '%s' has been revoked.",
breakGlassCredentialId, clusterKey)
return nil
}

if output.HasFlag() {
Expand Down
7 changes: 4 additions & 3 deletions cmd/describe/breakglasscredential/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ var _ = Describe("Break glass credential", func() {
testRuntime.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, hypershiftClusterReady))
testRuntime.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK,
test.FormatResource(revokedCredential)))
_, stderr, err := test.RunWithOutputCaptureAndArgv(runWithRuntime, testRuntime.RosaRuntime,
stdout, stderr, err := test.RunWithOutputCaptureAndArgv(runWithRuntime, testRuntime.RosaRuntime,
Cmd, &[]string{})
Expect(err.Error()).To(Equal("Break glass credential 'test-id' for cluster 'cluster1' has been revoked."))
Expect(stderr).To(Equal(""))
Expect(err).To(BeNil())
Expect(stderr).To(Equal("WARN: Break glass credential 'test-id' for cluster 'cluster1' has been revoked.\n"))
Expect(stdout).To(Equal(""))
})
})
})

0 comments on commit 0a3c0ed

Please sign in to comment.