Skip to content

Commit 821125a

Browse files
committed
adjust quota commands
1 parent 5ad763b commit 821125a

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

internal/cmd/quota/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
9393
}
9494

9595
func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APIClient) iaas.ApiListQuotasRequest {
96-
request := apiClient.ListQuotas(ctx, model.ProjectId)
96+
request := apiClient.ListQuotas(ctx, model.ProjectId, model.Region)
9797

9898
return request
9999
}

internal/cmd/quota/list/list_test.go

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

18-
var projectIdFlag = globalflags.ProjectIdFlag
18+
const (
19+
testRegion = "eu01"
20+
)
1921

2022
type testCtxKey struct{}
2123

@@ -27,7 +29,8 @@ var (
2729

2830
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
2931
flagValues := map[string]string{
30-
projectIdFlag: testProjectId,
32+
globalflags.ProjectIdFlag: testProjectId,
33+
globalflags.RegionFlag: testRegion,
3134
}
3235
for _, mod := range mods {
3336
mod(flagValues)
@@ -37,7 +40,11 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st
3740

3841
func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
3942
model := &inputModel{
40-
GlobalFlagModel: &globalflags.GlobalFlagModel{ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault},
43+
GlobalFlagModel: &globalflags.GlobalFlagModel{
44+
ProjectId: testProjectId,
45+
Region: testRegion,
46+
Verbosity: globalflags.VerbosityDefault,
47+
},
4148
}
4249
for _, mod := range mods {
4350
mod(model)
@@ -46,7 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4653
}
4754

4855
func fixtureRequest(mods ...func(request *iaas.ApiListQuotasRequest)) iaas.ApiListQuotasRequest {
49-
request := testClient.ListQuotas(testCtx, testProjectId)
56+
request := testClient.ListQuotas(testCtx, testProjectId, testRegion)
5057
for _, mod := range mods {
5158
mod(&request)
5259
}
@@ -75,21 +82,21 @@ func TestParseInput(t *testing.T) {
7582
{
7683
description: "project id missing",
7784
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
78-
delete(flagValues, projectIdFlag)
85+
delete(flagValues, globalflags.ProjectIdFlag)
7986
}),
8087
isValid: false,
8188
},
8289
{
8390
description: "project id invalid 1",
8491
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
85-
flagValues[projectIdFlag] = ""
92+
flagValues[globalflags.ProjectIdFlag] = ""
8693
}),
8794
isValid: false,
8895
},
8996
{
9097
description: "project id invalid 2",
9198
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
92-
flagValues[projectIdFlag] = "invalid-uuid"
99+
flagValues[globalflags.ProjectIdFlag] = "invalid-uuid"
93100
}),
94101
isValid: false,
95102
},

0 commit comments

Comments
 (0)