From 3239d530a91ee700dcb222e1e4b25a54c7acf341 Mon Sep 17 00:00:00 2001 From: Carlo Goetz Date: Mon, 10 Aug 2026 17:49:46 +0200 Subject: [PATCH 1/2] fix(json): service-account key create now supports json and yaml output https://github.com/stackitcloud/stackit-cli/issues/1527 --- .../cmd/service-account/key/create/create.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/cmd/service-account/key/create/create.go b/internal/cmd/service-account/key/create/create.go index 81a28c96b..d07c1d43f 100644 --- a/internal/cmd/service-account/key/create/create.go +++ b/internal/cmd/service-account/key/create/create.go @@ -86,13 +86,17 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("create service account key: %w", err) } - params.Printer.Outputf("Created key for service account %s with ID %q\n", model.ServiceAccountEmail, resp.Id) + params.Printer.OutputResult(model.OutputFormat, resp, func() error { + params.Printer.Outputf("Created key for service account %s with ID %q\n", model.ServiceAccountEmail, resp.Id) + + key, err := json.MarshalIndent(resp, "", " ") + if err != nil { + return fmt.Errorf("marshal key: %w", err) + } + params.Printer.Outputln(string(key)) + return nil + }) - key, err := json.MarshalIndent(resp, "", " ") - if err != nil { - return fmt.Errorf("marshal key: %w", err) - } - params.Printer.Outputln(string(key)) return nil }, } From 9dbc82d6775deb45f39fd06230901d06054dc2f9 Mon Sep 17 00:00:00 2001 From: Carlo Goetz Date: Mon, 10 Aug 2026 18:10:05 +0200 Subject: [PATCH 2/2] fix(lint): handle err --- internal/cmd/service-account/key/create/create.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/internal/cmd/service-account/key/create/create.go b/internal/cmd/service-account/key/create/create.go index d07c1d43f..339cf4aaf 100644 --- a/internal/cmd/service-account/key/create/create.go +++ b/internal/cmd/service-account/key/create/create.go @@ -86,7 +86,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("create service account key: %w", err) } - params.Printer.OutputResult(model.OutputFormat, resp, func() error { + return params.Printer.OutputResult(model.OutputFormat, resp, func() error { params.Printer.Outputf("Created key for service account %s with ID %q\n", model.ServiceAccountEmail, resp.Id) key, err := json.MarshalIndent(resp, "", " ") @@ -96,8 +96,6 @@ func NewCmd(params *types.CmdParams) *cobra.Command { params.Printer.Outputln(string(key)) return nil }) - - return nil }, }