@@ -30,7 +30,6 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
3030 Long : "Lists all KMS Keyrings." ,
3131 Args : args .NoArgs ,
3232 Example : examples .Build (
33- // Enforce a specific region for the KMS
3433 examples .NewExample (
3534 `List all KMS Keyrings` ,
3635 "$ stackit beta kms keyring list" ),
@@ -57,13 +56,8 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
5756 if err != nil {
5857 return fmt .Errorf ("get KMS Keyrings: %w" , err )
5958 }
60- if resp .KeyRings == nil || len (* resp .KeyRings ) == 0 {
61- params .Printer .Info ("No Keyrings found for project %q in region %q\n " , model .ProjectId , model .Region )
62- return nil
63- }
64- keyRings := * resp .KeyRings
6559
66- return outputResult (params .Printer , model .OutputFormat , keyRings )
60+ return outputResult (params .Printer , model .OutputFormat , model . ProjectId , * resp . KeyRings )
6761 },
6862 }
6963
@@ -97,7 +91,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClie
9791 return req
9892}
9993
100- func outputResult (p * print.Printer , outputFormat string , keyRings []kms.KeyRing ) error {
94+ func outputResult (p * print.Printer , outputFormat , projectId string , keyRings []kms.KeyRing ) error {
10195 switch outputFormat {
10296 case print .JSONOutputFormat :
10397 details , err := json .MarshalIndent (keyRings , "" , " " )
@@ -116,6 +110,11 @@ func outputResult(p *print.Printer, outputFormat string, keyRings []kms.KeyRing)
116110
117111 return nil
118112 default :
113+ if len (keyRings ) == 0 {
114+ p .Outputf ("No Keyrings found for project %q\n " , projectId )
115+ return nil
116+ }
117+
119118 table := tables .NewTable ()
120119 table .SetHeader ("ID" , "NAME" , "STATUS" )
121120
0 commit comments