Skip to content

Commit b131ac3

Browse files
committed
adjust affinity group commands
1 parent 99f4d2d commit b131ac3

File tree

12 files changed

+104
-82
lines changed

12 files changed

+104
-82
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.9.0
2121
github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.1
2222
github.com/stackitcloud/stackit-sdk-go/services/git v0.8.0
23-
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.31.0
23+
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.0.0
2424
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.2
2525
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.1
2626
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.2.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,8 @@ github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.1 h1:CnhAMLql0MNmAeq4r
571571
github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.1/go.mod h1:7Bx85knfNSBxulPdJUFuBePXNee3cO+sOTYnUG6M+iQ=
572572
github.com/stackitcloud/stackit-sdk-go/services/git v0.8.0 h1:/weT7P5Uwy1Qlhw0NidqtQBlbbb/dQehweDV/I9ShXg=
573573
github.com/stackitcloud/stackit-sdk-go/services/git v0.8.0/go.mod h1:AXFfYBJZIW1o0W0zZEb/proQMhMsb3Nn5E1htS8NDPE=
574-
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.31.0 h1:dnEjyapuv8WwRN5vE2z6+4/+ZqQTBx+bX27x2nOF7Jw=
575-
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.31.0/go.mod h1:854gnLR92NvAbJAA1xZEumrtNh1DoBP1FXTMvhwYA6w=
574+
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.0.0 h1:qLMpd5whPMLnaLEdFQjK51q/o9V6eMFMORBDSsyGyNI=
575+
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.0.0/go.mod h1:854gnLR92NvAbJAA1xZEumrtNh1DoBP1FXTMvhwYA6w=
576576
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.6.0 h1:q33ZaCBVEBUsnMDxYyuJKtJvGcE5nKgvuPed3s8zXNI=
577577
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.6.0/go.mod h1:20QOZ3rBC9wTGgzXzLz9M6YheX0VaxWE0/JI+s8On7k=
578578
github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.1 h1:hv5WrRU9rN6Jx4OwdOGJRyaQrfA9p1tzEoQK6/CDyoA=

internal/cmd/affinity-groups/create/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func configureFlags(cmd *cobra.Command) {
8888
}
8989

9090
func buildRequest(ctx context.Context, model inputModel, apiClient *iaas.APIClient) iaas.ApiCreateAffinityGroupRequest {
91-
req := apiClient.CreateAffinityGroup(ctx, model.ProjectId)
91+
req := apiClient.CreateAffinityGroup(ctx, model.ProjectId, model.Region)
9292
req = req.CreateAffinityGroupPayload(
9393
iaas.CreateAffinityGroupPayload{
9494
Name: utils.Ptr(model.Name),

internal/cmd/affinity-groups/create/create_test.go

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

18-
const projectIdFlag = globalflags.ProjectIdFlag
18+
const (
19+
projectIdFlag = globalflags.ProjectIdFlag
20+
regionFlag = globalflags.RegionFlag
21+
22+
testName = "test-name"
23+
testPolicy = "test-policy"
24+
testRegion = "eu01"
25+
)
1926

2027
type testCtxKey struct{}
2128

@@ -25,14 +32,10 @@ var (
2532
testProjectId = uuid.NewString()
2633
)
2734

28-
const (
29-
testName = "test-name"
30-
testPolicy = "test-policy"
31-
)
32-
3335
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3436
flagValues := map[string]string{
3537
projectIdFlag: testProjectId,
38+
regionFlag: testRegion,
3639

3740
nameFlag: testName,
3841
policyFlag: testPolicy,
@@ -48,6 +51,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4851
GlobalFlagModel: &globalflags.GlobalFlagModel{
4952
Verbosity: globalflags.VerbosityDefault,
5053
ProjectId: testProjectId,
54+
Region: testRegion,
5155
},
5256
Name: testName,
5357
Policy: testPolicy,
@@ -59,7 +63,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5963
}
6064

6165
func fixtureRequest(mods ...func(request *iaas.ApiCreateAffinityGroupRequest)) iaas.ApiCreateAffinityGroupRequest {
62-
request := testClient.CreateAffinityGroup(testCtx, testProjectId)
66+
request := testClient.CreateAffinityGroup(testCtx, testProjectId, testRegion)
6367
request = request.CreateAffinityGroupPayload(fixturePayload())
6468
for _, mod := range mods {
6569
mod(&request)

internal/cmd/affinity-groups/delete/delete.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
5858
projectLabel = model.ProjectId
5959
}
6060

61-
affinityGroupLabel, err := iaasUtils.GetAffinityGroupName(ctx, apiClient, model.ProjectId, model.AffinityGroupId)
61+
affinityGroupLabel, err := iaasUtils.GetAffinityGroupName(ctx, apiClient, model.ProjectId, model.Region, model.AffinityGroupId)
6262
if err != nil {
6363
params.Printer.Debug(print.ErrorLevel, "get affinity group name: %v", err)
6464
affinityGroupLabel = model.AffinityGroupId
@@ -87,7 +87,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
8787
}
8888

8989
func buildRequest(ctx context.Context, model inputModel, apiClient *iaas.APIClient) iaas.ApiDeleteAffinityGroupRequest {
90-
return apiClient.DeleteAffinityGroup(ctx, model.ProjectId, model.AffinityGroupId)
90+
return apiClient.DeleteAffinityGroup(ctx, model.ProjectId, model.Region, model.AffinityGroupId)
9191
}
9292

9393
func parseInput(p *print.Printer, cmd *cobra.Command, cliArgs []string) (*inputModel, error) {

internal/cmd/affinity-groups/delete/delete_test.go

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

16-
const projectIdFlag = globalflags.ProjectIdFlag
16+
const (
17+
projectIdFlag = globalflags.ProjectIdFlag
18+
regionFlag = globalflags.RegionFlag
19+
20+
testRegion = "eu01"
21+
)
1722

1823
type testCtxKey struct{}
1924

@@ -38,6 +43,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3843
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3944
flagValues := map[string]string{
4045
projectIdFlag: testProjectId,
46+
regionFlag: testRegion,
4147
}
4248
for _, mod := range mods {
4349
mod(flagValues)
@@ -50,6 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5056
GlobalFlagModel: &globalflags.GlobalFlagModel{
5157
Verbosity: globalflags.VerbosityDefault,
5258
ProjectId: testProjectId,
59+
Region: testRegion,
5360
},
5461
AffinityGroupId: testAffinityGroupId,
5562
}
@@ -60,7 +67,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
6067
}
6168

6269
func fixtureRequest(mods ...func(request *iaas.ApiDeleteAffinityGroupRequest)) iaas.ApiDeleteAffinityGroupRequest {
63-
request := testClient.DeleteAffinityGroup(testCtx, testProjectId, testAffinityGroupId)
70+
request := testClient.DeleteAffinityGroup(testCtx, testProjectId, testRegion, testAffinityGroupId)
6471
for _, mod := range mods {
6572
mod(&request)
6673
}

internal/cmd/affinity-groups/describe/describe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
6868
}
6969

7070
func buildRequest(ctx context.Context, model inputModel, apiClient *iaas.APIClient) iaas.ApiGetAffinityGroupRequest {
71-
return apiClient.GetAffinityGroup(ctx, model.ProjectId, model.AffinityGroupId)
71+
return apiClient.GetAffinityGroup(ctx, model.ProjectId, model.Region, model.AffinityGroupId)
7272
}
7373

7474
func parseInput(p *print.Printer, cmd *cobra.Command, cliArgs []string) (*inputModel, error) {

internal/cmd/affinity-groups/describe/describe_test.go

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

16-
const projectIdFlag = globalflags.ProjectIdFlag
16+
const (
17+
projectIdFlag = globalflags.ProjectIdFlag
18+
regionFlag = globalflags.RegionFlag
19+
20+
testRegion = "eu01"
21+
)
1722

1823
type testCtxKey struct{}
1924

@@ -38,6 +43,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3843
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3944
flagValues := map[string]string{
4045
projectIdFlag: testProjectId,
46+
regionFlag: testRegion,
4147
}
4248
for _, mod := range mods {
4349
mod(flagValues)
@@ -50,6 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5056
GlobalFlagModel: &globalflags.GlobalFlagModel{
5157
Verbosity: globalflags.VerbosityDefault,
5258
ProjectId: testProjectId,
59+
Region: testRegion,
5360
},
5461
AffinityGroupId: testAffinityGroupId,
5562
}
@@ -60,7 +67,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
6067
}
6168

6269
func fixtureRequest(mods ...func(request *iaas.ApiGetAffinityGroupRequest)) iaas.ApiGetAffinityGroupRequest {
63-
request := testClient.GetAffinityGroup(testCtx, testProjectId, testAffinityGroupId)
70+
request := testClient.GetAffinityGroup(testCtx, testProjectId, testRegion, testAffinityGroupId)
6471
for _, mod := range mods {
6572
mod(&request)
6673
}

internal/cmd/affinity-groups/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func configureFlags(cmd *cobra.Command) {
8282
}
8383

8484
func buildRequest(ctx context.Context, model inputModel, apiClient *iaas.APIClient) iaas.ApiListAffinityGroupsRequest {
85-
return apiClient.ListAffinityGroups(ctx, model.ProjectId)
85+
return apiClient.ListAffinityGroups(ctx, model.ProjectId, model.Region)
8686
}
8787

8888
func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, error) {

internal/cmd/affinity-groups/list/list_test.go

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

19-
const projectIdFlag = globalflags.ProjectIdFlag
19+
const (
20+
projectIdFlag = globalflags.ProjectIdFlag
21+
regionFlag = globalflags.RegionFlag
22+
23+
testRegion = "eu01"
24+
testLimit = 10
25+
)
2026

2127
type testCtxKey struct{}
2228

@@ -26,13 +32,10 @@ var (
2632
testProjectId = uuid.NewString()
2733
)
2834

29-
const (
30-
testLimit = 10
31-
)
32-
3335
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3436
flagValues := map[string]string{
3537
projectIdFlag: testProjectId,
38+
regionFlag: testRegion,
3639
}
3740
for _, mod := range mods {
3841
mod(flagValues)
@@ -45,6 +48,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4548
GlobalFlagModel: &globalflags.GlobalFlagModel{
4649
Verbosity: globalflags.VerbosityDefault,
4750
ProjectId: testProjectId,
51+
Region: testRegion,
4852
},
4953
}
5054
for _, mod := range mods {
@@ -54,7 +58,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5458
}
5559

5660
func fixtureRequest(mods ...func(request *iaas.ApiListAffinityGroupsRequest)) iaas.ApiListAffinityGroupsRequest {
57-
request := testClient.ListAffinityGroups(testCtx, testProjectId)
61+
request := testClient.ListAffinityGroups(testCtx, testProjectId, testRegion)
5862
for _, mod := range mods {
5963
mod(&request)
6064
}

0 commit comments

Comments
 (0)