Skip to content

Commit 3239d53

Browse files
committed
fix(json): service-account key create now supports json and yaml output
#1527
1 parent 8617752 commit 3239d53

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

  • internal/cmd/service-account/key/create

internal/cmd/service-account/key/create/create.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,17 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
8686
return fmt.Errorf("create service account key: %w", err)
8787
}
8888

89-
params.Printer.Outputf("Created key for service account %s with ID %q\n", model.ServiceAccountEmail, resp.Id)
89+
params.Printer.OutputResult(model.OutputFormat, resp, func() error {
90+
params.Printer.Outputf("Created key for service account %s with ID %q\n", model.ServiceAccountEmail, resp.Id)
91+
92+
key, err := json.MarshalIndent(resp, "", " ")
93+
if err != nil {
94+
return fmt.Errorf("marshal key: %w", err)
95+
}
96+
params.Printer.Outputln(string(key))
97+
return nil
98+
})
9099

91-
key, err := json.MarshalIndent(resp, "", " ")
92-
if err != nil {
93-
return fmt.Errorf("marshal key: %w", err)
94-
}
95-
params.Printer.Outputln(string(key))
96100
return nil
97101
},
98102
}

0 commit comments

Comments
 (0)