Skip to content

Commit ae26e81

Browse files
chore(mongodbflex): PR feedback
1 parent d1ecb60 commit ae26e81

7 files changed

Lines changed: 165 additions & 158 deletions

File tree

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,8 @@ github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0 h1:LFIH1wAp633ZA
620620
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0/go.mod h1:joa89Y1dyn0j22FstRcIKfW2ada3FDxNfttxSvq27uY=
621621
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.12.0 h1:SVd3WMmLAE0Jxk2SaRuM85DTOOXHycyMpZGx9vzqNkI=
622622
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.12.0/go.mod h1:0hHEPiOEMAA23EzEl42Rm3FlyKIzkW+LWLvDkuFTZ+Q=
623-
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0 h1:UxnbsKm6PQV8Gudw/EhySaEh9q1xSaTG8mzJz1EvhnE=
624-
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0/go.mod h1:RFL4h6JZvpsyFYbdJ3+eINEkletzJQTfrPdd+yPT/fU=
623+
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0 h1:T+ll3lS0Kn18d8hTOrVAMKcQrXiab+Cuj0cTnAYHmj0=
624+
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0/go.mod h1:QsPtoqAYvumyPU6ToX/5j1PbudN+VSTuvh6mp154ecM=
625625
github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0 h1:LGwCvvST0fwUgZ6bOxYIfu45qqTgv421ZS07UhKjZL8=
626626
github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0/go.mod h1:9KdrXC5JS30Ay3mR0adb3vNdhca+qxiy/cPF5P4wehQ=
627627
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6 h1:oTVx1+O177Ojn8OvXIOUbRSwtx7L59jhxDPrZEQFOfQ=

internal/cmd/mongodbflex/backup/restore-jobs/restore_jobs.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,15 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7575
if err != nil {
7676
return fmt.Errorf("get restore jobs for MongoDB Flex instance %q: %w", instanceLabel, err)
7777
}
78-
if len(resp.Items) == 0 {
79-
cmd.Printf("No restore jobs found for instance %q\n", instanceLabel)
80-
return nil
81-
}
82-
restoreJobs := resp.Items
78+
79+
restoreJobs := resp.GetItems()
8380

8481
// Truncate output
8582
if model.Limit != nil && len(restoreJobs) > int(*model.Limit) {
8683
restoreJobs = restoreJobs[:*model.Limit]
8784
}
8885

89-
return outputResult(params.Printer, model.OutputFormat, restoreJobs)
86+
return outputResult(params.Printer, model.OutputFormat, instanceLabel, restoreJobs)
9087
},
9188
}
9289

@@ -131,8 +128,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex
131128
return req
132129
}
133130

134-
func outputResult(p *print.Printer, outputFormat string, restoreJobs []mongodbflex.RestoreInstanceStatus) error {
131+
func outputResult(p *print.Printer, outputFormat, instanceLabel string, restoreJobs []mongodbflex.RestoreInstanceStatus) error {
135132
return p.OutputResult(outputFormat, restoreJobs, func() error {
133+
if len(restoreJobs) == 0 {
134+
p.Outputf("No restore jobs found for instance %q\n", instanceLabel)
135+
return nil
136+
}
136137
table := tables.NewTable()
137138
table.SetHeader("ID", "BACKUP ID", "BACKUP INSTANCE ID", "DATE", "STATUS")
138139
for i := range restoreJobs {

internal/cmd/mongodbflex/backup/restore-jobs/restore_jobs_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@ func TestBuildRequest(t *testing.T) {
177177

178178
func TestOutputResult(t *testing.T) {
179179
type args struct {
180-
outputFormat string
181-
restoreJobs []mongodbflex.RestoreInstanceStatus
180+
outputFormat string
181+
instanceLabel string
182+
restoreJobs []mongodbflex.RestoreInstanceStatus
182183
}
183184
tests := []struct {
184185
name string
@@ -208,7 +209,7 @@ func TestOutputResult(t *testing.T) {
208209
params := testparams.NewTestParams()
209210
for _, tt := range tests {
210211
t.Run(tt.name, func(t *testing.T) {
211-
if err := outputResult(params.Printer, tt.args.outputFormat, tt.args.restoreJobs); (err != nil) != tt.wantErr {
212+
if err := outputResult(params.Printer, tt.args.outputFormat, tt.args.instanceLabel, tt.args.restoreJobs); (err != nil) != tt.wantErr {
212213
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
213214
}
214215
})

0 commit comments

Comments
 (0)