Skip to content

Commit cdbc224

Browse files
committed
fix according to review request
1 parent 5b086cc commit cdbc224

File tree

7 files changed

+24
-39
lines changed

7 files changed

+24
-39
lines changed

internal/cmd/volume/backup/create/create.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,11 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
182182
return &model, nil
183183
}
184184

185-
// TODO: Enough?
186185
func buildRequest(model *inputModel, apiClient *iaas.APIClient, ctx context.Context) iaas.ApiCreateBackupRequest {
187-
// TODO: doc says if createeBackup func provides snapshot-id but isnt in the func-signature?
188186
req := apiClient.CreateBackup(ctx, model.ProjectId)
189187
return req
190188
}
191189

192-
// TODO: create(volume)BackupResponse or createBackupResponse needs to be created
193190
func outputResult(p *print.Printer, outputFormat string, async bool, sourceLabel, projectLabel string, resp *iaas.Backup) error {
194191
if resp == nil {
195192
return fmt.Errorf("create backup response is empty")

internal/cmd/volume/backup/create/create_test.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import (
1414
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
1515
)
1616

17-
var projectIdFlag = globalflags.ProjectIdFlag
18-
1917
type testCtxKey struct{}
2018

2119
var (
@@ -29,11 +27,11 @@ var (
2927

3028
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3129
flagValues := map[string]string{
32-
projectIdFlag: testProjectId,
33-
sourceIdFlag: testSourceId,
34-
sourceTypeFlag: "volume",
35-
nameFlag: testName,
36-
labelsFlag: "key1=value1",
30+
globalflags.ProjectIdFlag: testProjectId,
31+
sourceIdFlag: testSourceId,
32+
sourceTypeFlag: "volume",
33+
nameFlag: testName,
34+
labelsFlag: "key1=value1",
3735
}
3836
for _, mod := range mods {
3937
mod(flagValues)
@@ -108,14 +106,14 @@ func TestParseInput(t *testing.T) {
108106
{
109107
description: "project id missing",
110108
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
111-
delete(flagValues, projectIdFlag)
109+
delete(flagValues, globalflags.ProjectIdFlag)
112110
}),
113111
isValid: false,
114112
},
115113
{
116114
description: "project id invalid",
117115
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
118-
flagValues[projectIdFlag] = "invalid-uuid"
116+
flagValues[globalflags.ProjectIdFlag] = "invalid-uuid"
119117
}),
120118
isValid: false,
121119
},

internal/cmd/volume/backup/delete/delete_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import (
1414
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
1515
)
1616

17-
var projectIdFlag = globalflags.ProjectIdFlag
18-
1917
type testCtxKey struct{}
2018

2119
var (
@@ -37,7 +35,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3735

3836
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3937
flagValues := map[string]string{
40-
projectIdFlag: testProjectId,
38+
globalflags.ProjectIdFlag: testProjectId,
4139
}
4240
for _, mod := range mods {
4341
mod(flagValues)
@@ -104,7 +102,7 @@ func TestParseInput(t *testing.T) {
104102
description: "project id missing",
105103
argValues: fixtureArgValues(),
106104
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
107-
delete(flagValues, projectIdFlag)
105+
delete(flagValues, globalflags.ProjectIdFlag)
108106
}),
109107
isValid: false,
110108
},

internal/cmd/volume/backup/describe/describe_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import (
1414
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
1515
)
1616

17-
var projectIdFlag = globalflags.ProjectIdFlag
18-
1917
type testCtxKey struct{}
2018

2119
var (
@@ -37,7 +35,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3735

3836
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3937
flagValues := map[string]string{
40-
projectIdFlag: testProjectId,
38+
globalflags.ProjectIdFlag: testProjectId,
4139
}
4240
for _, mod := range mods {
4341
mod(flagValues)
@@ -104,7 +102,7 @@ func TestParseInput(t *testing.T) {
104102
description: "project id missing",
105103
argValues: fixtureArgValues(),
106104
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
107-
delete(flagValues, projectIdFlag)
105+
delete(flagValues, globalflags.ProjectIdFlag)
108106
}),
109107
isValid: false,
110108
},

internal/cmd/volume/backup/list/list_test.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import (
1616
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
1717
)
1818

19-
var projectIdFlag = globalflags.ProjectIdFlag
20-
2119
type testCtxKey struct{}
2220

2321
var (
@@ -28,9 +26,9 @@ var (
2826

2927
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3028
flagValues := map[string]string{
31-
projectIdFlag: testProjectId,
32-
limitFlag: "10",
33-
labelSelectorFlag: "key1=value1",
29+
globalflags.ProjectIdFlag: testProjectId,
30+
limitFlag: "10",
31+
labelSelectorFlag: "key1=value1",
3432
}
3533
for _, mod := range mods {
3634
mod(flagValues)
@@ -83,21 +81,21 @@ func TestParseInput(t *testing.T) {
8381
{
8482
description: "project id missing",
8583
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
86-
delete(flagValues, projectIdFlag)
84+
delete(flagValues, globalflags.ProjectIdFlag)
8785
}),
8886
isValid: false,
8987
},
9088
{
9189
description: "project id invalid 1",
9290
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
93-
flagValues[projectIdFlag] = ""
91+
flagValues[globalflags.ProjectIdFlag] = ""
9492
}),
9593
isValid: false,
9694
},
9795
{
9896
description: "project id invalid 2",
9997
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
100-
flagValues[projectIdFlag] = "invalid-uuid"
98+
flagValues[globalflags.ProjectIdFlag] = "invalid-uuid"
10199
}),
102100
isValid: false,
103101
},
@@ -209,9 +207,9 @@ func TestOutputResult(t *testing.T) {
209207
wantErr: true,
210208
},
211209
{
212-
name: "set empty create backup response",
210+
name: "empty backup in slice",
213211
args: args{
214-
backups: []iaas.Backup{},
212+
backups: []iaas.Backup{{}},
215213
},
216214
wantErr: false,
217215
},

internal/cmd/volume/backup/restore/restore_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import (
1414
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
1515
)
1616

17-
var projectIdFlag = globalflags.ProjectIdFlag
18-
1917
type testCtxKey struct{}
2018

2119
var (
@@ -37,7 +35,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3735

3836
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3937
flagValues := map[string]string{
40-
projectIdFlag: testProjectId,
38+
globalflags.ProjectIdFlag: testProjectId,
4139
}
4240
for _, mod := range mods {
4341
mod(flagValues)
@@ -104,7 +102,7 @@ func TestParseInput(t *testing.T) {
104102
description: "project id missing",
105103
argValues: fixtureArgValues(),
106104
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
107-
delete(flagValues, projectIdFlag)
105+
delete(flagValues, globalflags.ProjectIdFlag)
108106
}),
109107
isValid: false,
110108
},

internal/cmd/volume/backup/update/update_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import (
1414
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
1515
)
1616

17-
var projectIdFlag = globalflags.ProjectIdFlag
18-
1917
type testCtxKey struct{}
2018

2119
var (
@@ -39,9 +37,9 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3937

4038
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
4139
flagValues := map[string]string{
42-
projectIdFlag: testProjectId,
43-
nameFlag: testName,
44-
labelsFlag: "key1=value1",
40+
globalflags.ProjectIdFlag: testProjectId,
41+
nameFlag: testName,
42+
labelsFlag: "key1=value1",
4543
}
4644
for _, mod := range mods {
4745
mod(flagValues)

0 commit comments

Comments
 (0)