@@ -28,8 +28,8 @@ import (
2828
2929func newListServiceKeysCmd () * cobra.Command {
3030 var (
31- keysPageSize uint32
32- listAll bool
31+ pageSize uint32
32+ listAll bool
3333 )
3434
3535 cmd := & cobra.Command {
@@ -47,7 +47,7 @@ func newListServiceKeysCmd() *cobra.Command {
4747 if listAll {
4848 stateFilter = types .KeyStatesAll
4949 }
50- for key , err := range common .Client ().ListAllServiceKeys (& keysPageSize , & stateFilter ).Iter (cmd .Context ()) {
50+ for key , err := range common .Client ().ListAllServiceKeys (common . GetOkmsId (), & pageSize , & stateFilter ).Iter (cmd .Context ()) {
5151 exit .OnErr (err )
5252 keys .ObjectsList = append (keys .ObjectsList , * key )
5353 }
@@ -75,7 +75,7 @@ func newListServiceKeysCmd() *cobra.Command {
7575 },
7676 }
7777
78- cmd .Flags ().Uint32Var (& keysPageSize , "page-size" , 100 , "Number of keys to fetch per page (between 10 and 500)" )
78+ cmd .Flags ().Uint32Var (& pageSize , "page-size" , 100 , "Number of keys to fetch per page (between 10 and 500)" )
7979 cmd .Flags ().BoolVarP (& listAll , "all" , "A" , false , "List all keys (including deactivated and deleted ones)" )
8080 return cmd
8181}
@@ -115,7 +115,7 @@ func newAddServiceKeyCmd() *cobra.Command {
115115 body .Size = & keySizeEnum
116116 }
117117
118- resp := exit .OnErr2 (common .Client ().CreateImportServiceKey (cmd .Context (), nil , body ))
118+ resp := exit .OnErr2 (common .Client ().CreateImportServiceKey (cmd .Context (), common . GetOkmsId (), nil , body ))
119119 if cmd .Flag ("output" ).Value .String () == string (flagsmgmt .JSON_OUTPUT_FORMAT ) {
120120 output .JsonPrint (resp )
121121 } else {
@@ -141,7 +141,7 @@ func newGetServiceKeyCmd() *cobra.Command {
141141 Args : cobra .ExactArgs (1 ),
142142 Run : func (cmd * cobra.Command , args []string ) {
143143 keyId := exit .OnErr2 (uuid .Parse (args [0 ]))
144- resp := exit .OnErr2 (common .Client ().GetServiceKey (cmd .Context (), keyId , nil ))
144+ resp := exit .OnErr2 (common .Client ().GetServiceKey (cmd .Context (), common . GetOkmsId (), keyId , nil ))
145145 if cmd .Flag ("output" ).Value .String () == string (flagsmgmt .JSON_OUTPUT_FORMAT ) {
146146 output .JsonPrint (resp )
147147 } else {
@@ -159,7 +159,7 @@ func newExportPublicKeyCmd() *cobra.Command {
159159 Args : cobra .ExactArgs (1 ),
160160 Run : func (cmd * cobra.Command , args []string ) {
161161 keyId := exit .OnErr2 (uuid .Parse (args [0 ]))
162- resp := exit .OnErr2 (common .Client ().GetServiceKey (cmd .Context (), keyId , utils .PtrTo (types .Jwk )))
162+ resp := exit .OnErr2 (common .Client ().GetServiceKey (cmd .Context (), common . GetOkmsId (), keyId , utils .PtrTo (types .Jwk )))
163163 if resp .Keys == nil || len (* resp .Keys ) == 0 {
164164 exit .OnErr (errors .New ("Server returned no key" ))
165165 }
@@ -228,10 +228,10 @@ func newImportServiceKeyCmd() *cobra.Command {
228228 key := flagsmgmt .BytesFromArg (args [1 ], 8192 )
229229 var resp * types.GetServiceKeyResponse
230230 if ! symmetric {
231- resp = exit .OnErr2 (common .Client ().ImportKeyPairPEM (cmd .Context (), key , args [0 ], keyContext , keyUsage .ToCryptographicUsage ()... ))
231+ resp = exit .OnErr2 (common .Client ().ImportKeyPairPEM (cmd .Context (), common . GetOkmsId (), key , args [0 ], keyContext , keyUsage .ToCryptographicUsage ()... ))
232232 } else {
233233 k := exit .OnErr2 (base64 .StdEncoding .DecodeString (string (key )))
234- resp = exit .OnErr2 (common .Client ().ImportKey (cmd .Context (), k , args [0 ], keyContext , keyUsage .ToCryptographicUsage ()... ))
234+ resp = exit .OnErr2 (common .Client ().ImportKey (cmd .Context (), common . GetOkmsId (), k , args [0 ], keyContext , keyUsage .ToCryptographicUsage ()... ))
235235 }
236236
237237 if cmd .Flag ("output" ).Value .String () == string (flagsmgmt .JSON_OUTPUT_FORMAT ) {
@@ -310,12 +310,12 @@ func newDeleteKeyCmd() *cobra.Command {
310310 continue
311311 }
312312 if force {
313- if err := common .Client ().DeactivateServiceKey (cmd .Context (), keyId , types .Unspecified ); err != nil {
313+ if err := common .Client ().DeactivateServiceKey (cmd .Context (), common . GetOkmsId (), keyId , types .Unspecified ); err != nil {
314314 errs = append (errs , fmt .Errorf ("Failed to deactivate key %q: %w" , id , err ))
315315 continue
316316 }
317317 }
318- if err := common .Client ().DeleteServiceKey (cmd .Context (), keyId ); err != nil {
318+ if err := common .Client ().DeleteServiceKey (cmd .Context (), common . GetOkmsId (), keyId ); err != nil {
319319 errs = append (errs , fmt .Errorf ("Failed to delete key %q: %w" , id , err ))
320320 }
321321 }
@@ -342,7 +342,7 @@ func newDeactivateKeyCmd() *cobra.Command {
342342 errs = append (errs , fmt .Errorf ("Invalid Key ID %q: %w" , id , err ))
343343 continue
344344 }
345- if err := common .Client ().DeactivateServiceKey (cmd .Context (), keyId , revocationReason .RestModel ()); err != nil {
345+ if err := common .Client ().DeactivateServiceKey (cmd .Context (), common . GetOkmsId (), keyId , revocationReason .RestModel ()); err != nil {
346346 errs = append (errs , fmt .Errorf ("Failed to deactivate key %q: %w" , id , err ))
347347 }
348348 }
@@ -366,7 +366,7 @@ func newActivateKeyCmd() *cobra.Command {
366366 errs = append (errs , fmt .Errorf ("Invalid Key ID %q: %w" , id , err ))
367367 continue
368368 }
369- if err := common .Client ().ActivateServiceKey (cmd .Context (), keyId ); err != nil {
369+ if err := common .Client ().ActivateServiceKey (cmd .Context (), common . GetOkmsId (), keyId ); err != nil {
370370 errs = append (errs , fmt .Errorf ("Failed to activate key %q: %w" , id , err ))
371371 }
372372 }
@@ -388,7 +388,7 @@ func newUpdateKeyCmd() *cobra.Command {
388388 if name != "" {
389389 body .Name = name
390390 }
391- resp := exit .OnErr2 (common .Client ().UpdateServiceKey (cmd .Context (), keyId , body ))
391+ resp := exit .OnErr2 (common .Client ().UpdateServiceKey (cmd .Context (), common . GetOkmsId (), keyId , body ))
392392 printServiceKey (resp )
393393 },
394394 }
0 commit comments