@@ -17,7 +17,6 @@ import (
1717 "github.com/stackitcloud/stackit-cli/internal/pkg/flags"
1818 "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1919 "github.com/stackitcloud/stackit-cli/internal/pkg/print"
20- "github.com/stackitcloud/stackit-cli/internal/pkg/projectname"
2120 "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
2221 "github.com/stackitcloud/stackit-sdk-go/services/kms"
2322 "github.com/stackitcloud/stackit-sdk-go/services/kms/wait"
@@ -55,10 +54,10 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
5554 Example : examples .Build (
5655 examples .NewExample (
5756 `Create a Symmetric KMS key` ,
58- `$ stackit beta kms key create --key-ring-id "XXX " --algorithm "rsa_2048_oaep_sha256" --name "my-key-name" --purpose "asymmetric_encrypt_decrypt" --protection "software"` ),
57+ `$ stackit beta kms key create --key-ring-id "my-key-ring-id " --algorithm "rsa_2048_oaep_sha256" --name "my-key-name" --purpose "asymmetric_encrypt_decrypt" --protection "software"` ),
5958 examples .NewExample (
6059 `Create a Message Authentication KMS key` ,
61- `$ stackit beta kms key create --key-ring-id "XXX " --algorithm "hmac_sha512" --name "my-key-name" --purpose "message_authentication_code" --protection "software"` ),
60+ `$ stackit beta kms key create --key-ring-id "my-key-ring-id " --algorithm "hmac_sha512" --name "my-key-name" --purpose "message_authentication_code" --protection "software"` ),
6261 ),
6362 RunE : func (cmd * cobra.Command , _ []string ) error {
6463 ctx := context .Background ()
@@ -73,15 +72,8 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
7372 return err
7473 }
7574
76- projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
77- if err != nil {
78- params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
79- projectLabel = model .ProjectId
80- }
81-
8275 if ! model .AssumeYes {
83- prompt := fmt .Sprintf ("Are you sure you want to create a KMS Key for project %q?" , projectLabel )
84- err = params .Printer .PromptForConfirmation (prompt )
76+ err = params .Printer .PromptForConfirmation ("Are you sure you want to create a KMS Key?" )
8577 if err != nil {
8678 return err
8779 }
@@ -105,7 +97,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
10597 s .Stop ()
10698 }
10799
108- return outputResult (params .Printer , model . OutputFormat , projectLabel , resp )
100+ return outputResult (params .Printer , model , resp )
109101 },
110102 }
111103 configureFlags (cmd )
@@ -151,12 +143,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient kmsKeyClient
151143 return req , nil
152144}
153145
154- func outputResult (p * print.Printer , outputFormat , projectLabel string , resp * kms.Key ) error {
146+ func outputResult (p * print.Printer , model * inputModel , resp * kms.Key ) error {
155147 if resp == nil {
156148 return fmt .Errorf ("response is nil" )
157149 }
158150
159- switch outputFormat {
151+ switch model . OutputFormat {
160152 case print .JSONOutputFormat :
161153 details , err := json .MarshalIndent (resp , "" , " " )
162154 if err != nil {
@@ -172,7 +164,12 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, resp *kms
172164 p .Outputln (string (details ))
173165
174166 default :
175- p .Outputf ("Created the key '%s' for project %q. Key ID: %s\n " , utils .PtrString (resp .DisplayName ), projectLabel , utils .PtrString (resp .Id ))
167+ operationState := "Created"
168+ if model .Async {
169+ operationState = "Triggered creation of"
170+ }
171+ p .Outputf ("%s the KMS key '%s'. Key ID: %s\n " , operationState , utils .PtrString (resp .DisplayName ), utils .PtrString (resp .Id ))
172+
176173 }
177174 return nil
178175}
0 commit comments