Skip to content

Commit b5ff86a

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

File tree

12 files changed

+97
-87
lines changed

12 files changed

+97
-87
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: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ import (
1515
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
1616
)
1717

18-
const projectIdFlag = globalflags.ProjectIdFlag
18+
const (
19+
testName = "test-name"
20+
testPolicy = "test-policy"
21+
testRegion = "eu01"
22+
)
1923

2024
type testCtxKey struct{}
2125

@@ -25,14 +29,10 @@ var (
2529
testProjectId = uuid.NewString()
2630
)
2731

28-
const (
29-
testName = "test-name"
30-
testPolicy = "test-policy"
31-
)
32-
3332
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3433
flagValues := map[string]string{
35-
projectIdFlag: testProjectId,
34+
globalflags.ProjectIdFlag: testProjectId,
35+
globalflags.RegionFlag: testRegion,
3636

3737
nameFlag: testName,
3838
policyFlag: testPolicy,
@@ -48,6 +48,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4848
GlobalFlagModel: &globalflags.GlobalFlagModel{
4949
Verbosity: globalflags.VerbosityDefault,
5050
ProjectId: testProjectId,
51+
Region: testRegion,
5152
},
5253
Name: testName,
5354
Policy: testPolicy,
@@ -59,7 +60,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5960
}
6061

6162
func fixtureRequest(mods ...func(request *iaas.ApiCreateAffinityGroupRequest)) iaas.ApiCreateAffinityGroupRequest {
62-
request := testClient.CreateAffinityGroup(testCtx, testProjectId)
63+
request := testClient.CreateAffinityGroup(testCtx, testProjectId, testRegion)
6364
request = request.CreateAffinityGroupPayload(fixturePayload())
6465
for _, mod := range mods {
6566
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: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import (
1313
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
1414
)
1515

16-
const projectIdFlag = globalflags.ProjectIdFlag
16+
const (
17+
testRegion = "eu01"
18+
)
1719

1820
type testCtxKey struct{}
1921

@@ -37,7 +39,8 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3739

3840
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3941
flagValues := map[string]string{
40-
projectIdFlag: testProjectId,
42+
globalflags.ProjectIdFlag: testProjectId,
43+
globalflags.RegionFlag: testRegion,
4144
}
4245
for _, mod := range mods {
4346
mod(flagValues)
@@ -50,6 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5053
GlobalFlagModel: &globalflags.GlobalFlagModel{
5154
Verbosity: globalflags.VerbosityDefault,
5255
ProjectId: testProjectId,
56+
Region: testRegion,
5357
},
5458
AffinityGroupId: testAffinityGroupId,
5559
}
@@ -60,7 +64,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
6064
}
6165

6266
func fixtureRequest(mods ...func(request *iaas.ApiDeleteAffinityGroupRequest)) iaas.ApiDeleteAffinityGroupRequest {
63-
request := testClient.DeleteAffinityGroup(testCtx, testProjectId, testAffinityGroupId)
67+
request := testClient.DeleteAffinityGroup(testCtx, testProjectId, testRegion, testAffinityGroupId)
6468
for _, mod := range mods {
6569
mod(&request)
6670
}

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: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import (
1313
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
1414
)
1515

16-
const projectIdFlag = globalflags.ProjectIdFlag
16+
const (
17+
testRegion = "eu01"
18+
)
1719

1820
type testCtxKey struct{}
1921

2022
var (
21-
testCtx = context.WithValue(context.Background(), &testCtxKey{}, projectIdFlag)
23+
testCtx = context.WithValue(context.Background(), &testCtxKey{}, "test")
2224
testClient = &iaas.APIClient{}
2325
testProjectId = uuid.NewString()
2426

@@ -37,7 +39,8 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3739

3840
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3941
flagValues := map[string]string{
40-
projectIdFlag: testProjectId,
42+
globalflags.ProjectIdFlag: testProjectId,
43+
globalflags.RegionFlag: testRegion,
4144
}
4245
for _, mod := range mods {
4346
mod(flagValues)
@@ -50,6 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5053
GlobalFlagModel: &globalflags.GlobalFlagModel{
5154
Verbosity: globalflags.VerbosityDefault,
5255
ProjectId: testProjectId,
56+
Region: testRegion,
5357
},
5458
AffinityGroupId: testAffinityGroupId,
5559
}
@@ -60,7 +64,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
6064
}
6165

6266
func fixtureRequest(mods ...func(request *iaas.ApiGetAffinityGroupRequest)) iaas.ApiGetAffinityGroupRequest {
63-
request := testClient.GetAffinityGroup(testCtx, testProjectId, testAffinityGroupId)
67+
request := testClient.GetAffinityGroup(testCtx, testProjectId, testRegion, testAffinityGroupId)
6468
for _, mod := range mods {
6569
mod(&request)
6670
}

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: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ import (
1616
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
1717
)
1818

19-
const projectIdFlag = globalflags.ProjectIdFlag
19+
const (
20+
testRegion = "eu01"
21+
testLimit = 10
22+
)
2023

2124
type testCtxKey struct{}
2225

@@ -26,13 +29,10 @@ var (
2629
testProjectId = uuid.NewString()
2730
)
2831

29-
const (
30-
testLimit = 10
31-
)
32-
3332
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3433
flagValues := map[string]string{
35-
projectIdFlag: testProjectId,
34+
globalflags.ProjectIdFlag: testProjectId,
35+
globalflags.RegionFlag: testRegion,
3636
}
3737
for _, mod := range mods {
3838
mod(flagValues)
@@ -45,6 +45,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4545
GlobalFlagModel: &globalflags.GlobalFlagModel{
4646
Verbosity: globalflags.VerbosityDefault,
4747
ProjectId: testProjectId,
48+
Region: testRegion,
4849
},
4950
}
5051
for _, mod := range mods {
@@ -54,7 +55,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5455
}
5556

5657
func fixtureRequest(mods ...func(request *iaas.ApiListAffinityGroupsRequest)) iaas.ApiListAffinityGroupsRequest {
57-
request := testClient.ListAffinityGroups(testCtx, testProjectId)
58+
request := testClient.ListAffinityGroups(testCtx, testProjectId, testRegion)
5859
for _, mod := range mods {
5960
mod(&request)
6061
}

0 commit comments

Comments
 (0)