Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
386dc10
feat(server): add async output handling for server creation
s-inter Mar 4, 2026
e0ca2d7
feat(volume): add async output handling
s-inter Mar 9, 2026
9029102
feat(network-area): add async output handling
s-inter Mar 9, 2026
1f89580
feat(git): add async output handling for instance creation
s-inter Mar 9, 2026
b04519a
feat(mongodbflex): add async output handling in restore and clone com…
s-inter Mar 9, 2026
f0ba899
Merge remote-tracking branch 'origin/main' into feat/consistent-outpu…
s-inter Mar 9, 2026
3667ecd
feat(kms): add async output handling
s-inter Mar 10, 2026
4248524
feat(sfs): add async output handling
s-inter Mar 10, 2026
d02de70
Merge branch 'main' into feat/consistent-output-for-async
s-inter Mar 10, 2026
c6715b5
Merge remote-tracking branch 'origin/main' into feat/consistent-outpu…
s-inter Mar 16, 2026
ec0972e
fix(kms): remove hardcoded async in outputResult tests
s-inter Mar 16, 2026
1edb1e2
fix(sfs): remove hardcoded async in outputResult tests
s-inter Mar 16, 2026
6e7d725
refactor(kms): unify output handling for async operations
s-inter Mar 16, 2026
976271f
Merge branch 'main' into feat/consistent-output-for-async
s-inter Mar 20, 2026
1f45c26
Update internal/cmd/git/instance/create/create.go
s-inter Mar 20, 2026
6d22550
refactor(git): clean up outputResult function by passing only require…
s-inter Mar 20, 2026
c153566
refactor(git): fix tests & removed redundant checks
s-inter Mar 20, 2026
89bac06
fix(git): remove Id from inputModel
s-inter Mar 20, 2026
52fd2cc
Merge branch 'main' into feat/consistent-output-for-async
s-inter Mar 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions internal/cmd/beta/kms/version/disable/disable.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
params.Printer.Debug(print.ErrorLevel, "get key version: %v", err)
}

return outputResult(params.Printer, model.OutputFormat, resp)
return outputResult(params.Printer, model.OutputFormat, model.Async, resp)
},
}

Expand Down Expand Up @@ -133,7 +133,7 @@ func configureFlags(cmd *cobra.Command) {
cobra.CheckErr(err)
}

func outputResult(p *print.Printer, outputFormat string, resp *kms.Version) error {
func outputResult(p *print.Printer, outputFormat string, async bool, resp *kms.Version) error {
if resp == nil {
return fmt.Errorf("response is nil")
}
Expand All @@ -154,7 +154,11 @@ func outputResult(p *print.Printer, outputFormat string, resp *kms.Version) erro
p.Outputln(string(details))

default:
p.Outputf("Disabled version %d of the key %q\n", utils.PtrValue(resp.Number), utils.PtrValue(resp.KeyId))
operationState := "Disabled"
if async {
operationState = "Triggered disable of"
}
p.Outputf("%s version %d of the key %q\n", operationState, utils.PtrValue(resp.Number), utils.PtrValue(resp.KeyId))
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/beta/kms/version/disable/disable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func TestOutputResult(t *testing.T) {
p.Cmd = NewCmd(&types.CmdParams{Printer: p})
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
err := outputResult(p, tt.outputFormat, tt.resp)
err := outputResult(p, tt.outputFormat, false, tt.resp)
if (err != nil) != tt.wantErr {
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
}
Expand Down
10 changes: 7 additions & 3 deletions internal/cmd/beta/kms/version/enable/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
params.Printer.Debug(print.ErrorLevel, "get key version: %v", err)
}

return outputResult(params.Printer, model.OutputFormat, resp)
return outputResult(params.Printer, model.OutputFormat, model.Async, resp)
},
}

Expand Down Expand Up @@ -133,7 +133,7 @@ func configureFlags(cmd *cobra.Command) {
cobra.CheckErr(err)
}

func outputResult(p *print.Printer, outputFormat string, resp *kms.Version) error {
func outputResult(p *print.Printer, outputFormat string, async bool, resp *kms.Version) error {
if resp == nil {
return fmt.Errorf("response is nil")
}
Expand All @@ -154,7 +154,11 @@ func outputResult(p *print.Printer, outputFormat string, resp *kms.Version) erro
p.Outputln(string(details))

default:
p.Outputf("Enabled version %d of the key %q\n", utils.PtrValue(resp.Number), utils.PtrValue(resp.KeyId))
operationState := "Enabled"
if async {
operationState = "Triggered enable of"
}
p.Outputf("%s version %d of the key %q\n", operationState, utils.PtrValue(resp.Number), utils.PtrValue(resp.KeyId))
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/beta/kms/version/enable/enable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func TestOutputResult(t *testing.T) {
p.Cmd = NewCmd(&types.CmdParams{Printer: p})
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
err := outputResult(p, tt.outputFormat, tt.resp)
err := outputResult(p, tt.outputFormat, false, tt.resp)
if (err != nil) != tt.wantErr {
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
}
Expand Down
10 changes: 7 additions & 3 deletions internal/cmd/beta/sfs/resource-pool/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ The available performance class values can be obtained by running:
s.Stop()
}

return outputResult(params.Printer, model.OutputFormat, projectLabel, resp)
return outputResult(params.Printer, model.OutputFormat, model.Async, projectLabel, resp)
},
}
configureFlags(cmd)
Expand Down Expand Up @@ -170,13 +170,17 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
return &model, nil
}

func outputResult(p *print.Printer, outputFormat, projectLabel string, resp *sfs.CreateResourcePoolResponse) error {
func outputResult(p *print.Printer, outputFormat string, async bool, projectLabel string, resp *sfs.CreateResourcePoolResponse) error {
return p.OutputResult(outputFormat, resp, func() error {
if resp == nil || resp.ResourcePool == nil {
p.Outputln("Resource pool response is empty")
return nil
}
p.Outputf("Created resource pool for project %q. Resource pool ID: %s\n", projectLabel, utils.PtrString(resp.ResourcePool.Id))
operationState := "Created"
if async {
operationState = "Triggered creation of"
}
p.Outputf("%s resource pool for project %q. Resource pool ID: %s\n", operationState, projectLabel, utils.PtrString(resp.ResourcePool.Id))
return nil
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func TestOutputResult(t *testing.T) {
p.Cmd = NewCmd(&types.CmdParams{Printer: p})
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := outputResult(p, tt.args.outputFormat, tt.args.projectLabel, tt.args.resp); (err != nil) != tt.wantErr {
if err := outputResult(p, tt.args.outputFormat, false, tt.args.projectLabel, tt.args.resp); (err != nil) != tt.wantErr {
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
}
})
Expand Down
10 changes: 7 additions & 3 deletions internal/cmd/beta/sfs/resource-pool/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
s.Stop()
}

return outputResult(params.Printer, model.OutputFormat, resourcePoolName, resp)
return outputResult(params.Printer, model.OutputFormat, model.Async, resourcePoolName, resp)
},
}
return cmd
Expand Down Expand Up @@ -110,9 +110,13 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
return &model, nil
}

func outputResult(p *print.Printer, outputFormat, resourcePoolName string, response map[string]interface{}) error {
func outputResult(p *print.Printer, outputFormat string, async bool, resourcePoolName string, response map[string]interface{}) error {
return p.OutputResult(outputFormat, response, func() error {
p.Outputf("Deleted resource pool %q\n", resourcePoolName)
operationState := "Deleted"
if async {
operationState = "Triggered deletion of"
}
p.Outputf("%s resource pool %q\n", operationState, resourcePoolName)
return nil
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func TestOutputResult(t *testing.T) {
p.Cmd = NewCmd(&types.CmdParams{Printer: p})
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := outputResult(p, tt.args.outputFormat, tt.args.resourcePoolName, tt.args.response); (err != nil) != tt.wantErr {
if err := outputResult(p, tt.args.outputFormat, false, tt.args.resourcePoolName, tt.args.response); (err != nil) != tt.wantErr {
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
}
})
Expand Down
10 changes: 7 additions & 3 deletions internal/cmd/beta/sfs/resource-pool/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ The available performance class values can be obtained by running:
s.Stop()
}

return outputResult(params.Printer, model.OutputFormat, resp)
return outputResult(params.Printer, model.OutputFormat, model.Async, resp)
},
}
configureFlags(cmd)
Expand Down Expand Up @@ -165,13 +165,17 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
return &model, nil
}

func outputResult(p *print.Printer, outputFormat string, resp *sfs.UpdateResourcePoolResponse) error {
func outputResult(p *print.Printer, outputFormat string, async bool, resp *sfs.UpdateResourcePoolResponse) error {
return p.OutputResult(outputFormat, resp, func() error {
if resp == nil || resp.ResourcePool == nil {
p.Outputln("Resource pool response is empty")
return nil
}
p.Outputf("Updated resource pool %s\n", utils.PtrString(resp.ResourcePool.Name))
operationState := "Updated"
if async {
operationState = "Triggered update of"
}
p.Outputf("%s resource pool %s\n", operationState, utils.PtrString(resp.ResourcePool.Name))
return nil
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func TestOutputResult(t *testing.T) {
p.Cmd = NewCmd(&types.CmdParams{Printer: p})
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := outputResult(p, tt.args.outputFormat, tt.args.resp); (err != nil) != tt.wantErr {
if err := outputResult(p, tt.args.outputFormat, false, tt.args.resp); (err != nil) != tt.wantErr {
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
}
})
Expand Down
13 changes: 12 additions & 1 deletion internal/cmd/git/instance/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,18 @@ func outputResult(p *print.Printer, model *inputModel, resp *git.Instance) error
}

return p.OutputResult(outputFormat, resp, func() error {
p.Outputf("Created instance %q with id %s\n", model.Name, utils.PtrString(model.Id))
if resp == nil {
return nil
Comment thread
s-inter marked this conversation as resolved.
Outdated
}
operationState := "Created"
if model.Async {
operationState = "Triggered creation of"
}
id := utils.PtrString(model.Id)
if resp.Id != nil {
id = *resp.Id
}
p.Outputf("%s instance %q with id %s\n", operationState, model.Name, id)
return nil
})
}
2 changes: 1 addition & 1 deletion internal/cmd/git/instance/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func TestOutputResult(t *testing.T) {
{
name: "empty input",
args: args{
model: &inputModel{},
model: fixtureInputModel(),
Comment thread
s-inter marked this conversation as resolved.
Outdated
resp: &git.Instance{},
},
wantErr: false,
Expand Down
12 changes: 10 additions & 2 deletions internal/cmd/mongodbflex/backup/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
s.Stop()
}

params.Printer.Outputf("Restored instance %q with backup %q\n", model.InstanceId, model.BackupId)
operationState := "Restored"
if model.Async {
operationState = "Triggered restore of"
}
params.Printer.Outputf("%s instance %q with backup %q\n", operationState, model.InstanceId, model.BackupId)
return nil
}

Expand All @@ -129,7 +133,11 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
s.Stop()
}

params.Printer.Outputf("Cloned instance %q from backup with timestamp %q\n", model.InstanceId, model.Timestamp)
operationState := "Cloned"
if model.Async {
operationState = "Triggered clone of"
}
params.Printer.Outputf("%s instance %q from backup with timestamp %q\n", operationState, model.InstanceId, model.Timestamp)
return nil
},
}
Expand Down
10 changes: 7 additions & 3 deletions internal/cmd/network-area/region/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
s.Stop()
}

return outputResult(params.Printer, model.OutputFormat, model.Region, networkAreaLabel, *resp)
return outputResult(params.Printer, model.OutputFormat, model.Async, model.Region, networkAreaLabel, *resp)
},
}
configureFlags(cmd)
Expand Down Expand Up @@ -186,9 +186,13 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
return req.CreateNetworkAreaRegionPayload(payload)
}

func outputResult(p *print.Printer, outputFormat, region, networkAreaLabel string, regionalArea iaas.RegionalArea) error {
func outputResult(p *print.Printer, outputFormat string, async bool, region, networkAreaLabel string, regionalArea iaas.RegionalArea) error {
return p.OutputResult(outputFormat, regionalArea, func() error {
p.Outputf("Create region configuration for SNA %q.\nRegion: %s\n", networkAreaLabel, region)
operationState := "Created"
if async {
operationState = "Triggered creation of"
}
p.Outputf("%s region configuration for SNA %q.\nRegion: %s\n", operationState, networkAreaLabel, region)
return nil
})
}
3 changes: 2 additions & 1 deletion internal/cmd/network-area/region/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ func TestBuildRequest(t *testing.T) {
func Test_outputResult(t *testing.T) {
type args struct {
outputFormat string
async bool
region string
networkAreaLabel string
regionalArea iaas.RegionalArea
Expand Down Expand Up @@ -300,7 +301,7 @@ func Test_outputResult(t *testing.T) {
p.Cmd = NewCmd(&types.CmdParams{Printer: p})
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := outputResult(p, tt.args.outputFormat, tt.args.region, tt.args.networkAreaLabel, tt.args.regionalArea); (err != nil) != tt.wantErr {
if err := outputResult(p, tt.args.outputFormat, tt.args.async, tt.args.region, tt.args.networkAreaLabel, tt.args.regionalArea); (err != nil) != tt.wantErr {
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
}
})
Expand Down
10 changes: 7 additions & 3 deletions internal/cmd/server/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
s.Stop()
}

return outputResult(params.Printer, model.OutputFormat, projectLabel, resp)
return outputResult(params.Printer, model.OutputFormat, model.Async, projectLabel, resp)
},
}
configureFlags(cmd)
Expand Down Expand Up @@ -322,12 +322,16 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
return req.CreateServerPayload(payload)
}

func outputResult(p *print.Printer, outputFormat, projectLabel string, server *iaas.Server) error {
func outputResult(p *print.Printer, outputFormat string, async bool, projectLabel string, server *iaas.Server) error {
if server == nil {
return fmt.Errorf("server response is empty")
}
return p.OutputResult(outputFormat, server, func() error {
p.Outputf("Created server for project %q.\nServer ID: %s\n", projectLabel, utils.PtrString(server.Id))
operationState := "Created"
if async {
operationState = "Triggered creation of"
}
p.Outputf("%s server for project %q.\nServer ID: %s\n", operationState, projectLabel, utils.PtrString(server.Id))
return nil
})
}
3 changes: 2 additions & 1 deletion internal/cmd/server/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ func TestBuildRequest(t *testing.T) {
func TestOutputResult(t *testing.T) {
type args struct {
outputFormat string
async bool
Comment thread
s-inter marked this conversation as resolved.
projectLabel string
server *iaas.Server
}
Expand All @@ -407,7 +408,7 @@ func TestOutputResult(t *testing.T) {
p.Cmd = NewCmd(&types.CmdParams{Printer: p})
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := outputResult(p, tt.args.outputFormat, tt.args.projectLabel, tt.args.server); (err != nil) != tt.wantErr {
if err := outputResult(p, tt.args.outputFormat, tt.args.async, tt.args.projectLabel, tt.args.server); (err != nil) != tt.wantErr {
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
}
})
Expand Down
6 changes: 5 additions & 1 deletion internal/cmd/volume/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ func outputResult(p *print.Printer, model *inputModel, projectLabel string, volu
return fmt.Errorf("volume response is empty")
}
return p.OutputResult(model.OutputFormat, volume, func() error {
p.Outputf("Created volume for project %q.\nVolume ID: %s\n", projectLabel, utils.PtrString(volume.Id))
operationState := "Created"
if model.Async {
operationState = "Triggered creation of"
}
p.Outputf("%s volume for project %q.\nVolume ID: %s\n", operationState, projectLabel, utils.PtrString(volume.Id))
return nil
})
}
Loading