Skip to content

Commit 393d1bd

Browse files
authored
feat(serviceenablement): Region adjustment (#649)
Signed-off-by: Alexander Dahmen <[email protected]>
1 parent 8e7e4aa commit 393d1bd

File tree

12 files changed

+49
-45
lines changed

12 files changed

+49
-45
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.6.0
2929
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v0.5.0
3030
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.6.0
31-
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v0.5.0
31+
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.0.0
3232
github.com/stackitcloud/stackit-sdk-go/services/ske v0.22.0
3333
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.0.0
3434
github.com/zalando/go-keyring v0.2.6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ github.com/stackitcloud/stackit-sdk-go/services/serverupdate v0.5.0 h1:TMUxDh8XG
157157
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v0.5.0/go.mod h1:giHnHz3kHeLY8Av9MZLsyJlaTXYz+BuGqdP/SKB5Vo0=
158158
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.6.0 h1:y+XzJcntHJ7M+IWWvAUkiVFA8op+jZxwHs3ktW2aLoA=
159159
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.6.0/go.mod h1:J/Wa67cbDI1wAyxib9PiEbNqGfIoFUH+DSLueVazQx8=
160-
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v0.5.0 h1:QG+rGBHsyXOlJ3ZIeOgExGqu9PoTlGY1rltW/VpG6lw=
161-
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v0.5.0/go.mod h1:16dOVT052cMuHhUJ3NIcPuY7TrpCr9QlxmvvfjLZubA=
160+
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.0.0 h1:Xxd5KUSWRt7FytnNWClLEa0n9GM6e5xAKo835ODSpAM=
161+
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.0.0/go.mod h1:EMqjiq/72WKXSwnJGLpumUJS4Uwlyhg5vtNg7qWoGtc=
162162
github.com/stackitcloud/stackit-sdk-go/services/ske v0.22.0 h1:3KUVls8zXsbT2tOYRSHyp3/l0Kpjl4f3INmQKYTe65Y=
163163
github.com/stackitcloud/stackit-sdk-go/services/ske v0.22.0/go.mod h1:63IvXpBJTIVONAnGPSDo0sRJ+6n6tzO918OLqfYBxto=
164164
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.0.0 h1:RYJO0rZea9+sxVfaJDWRo2zgfKNgiUcA5c0nbvZURiU=

internal/cmd/ske/cluster/create/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
9696
}
9797

9898
// Check if the project is enabled before trying to create
99-
enabled, err := serviceEnablementUtils.ProjectEnabled(ctx, serviceEnablementApiClient, model.ProjectId)
99+
enabled, err := serviceEnablementUtils.ProjectEnabled(ctx, serviceEnablementApiClient, model.ProjectId, model.Region)
100100
if err != nil {
101101
return err
102102
}

internal/cmd/ske/cluster/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
6969
}
7070

7171
// Check if SKE is enabled for this project
72-
enabled, err := serviceEnablementUtils.ProjectEnabled(ctx, serviceEnablementApiClient, model.ProjectId)
72+
enabled, err := serviceEnablementUtils.ProjectEnabled(ctx, serviceEnablementApiClient, model.ProjectId, model.Region)
7373
if err != nil {
7474
return err
7575
}

internal/cmd/ske/describe/describe.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
8181
return &model, nil
8282
}
8383

84-
func buildRequest(ctx context.Context, model *inputModel, apiClient *serviceenablement.APIClient) serviceenablement.ApiGetServiceStatusRequest {
85-
req := apiClient.GetServiceStatus(ctx, model.ProjectId, skeUtils.SKEServiceId)
84+
func buildRequest(ctx context.Context, model *inputModel, apiClient *serviceenablement.APIClient) serviceenablement.ApiGetServiceStatusRegionalRequest {
85+
req := apiClient.GetServiceStatusRegional(ctx, model.Region, model.ProjectId, skeUtils.SKEServiceId)
8686
return req
8787
}
8888

internal/cmd/ske/describe/describe_test.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ import (
1515
"github.com/spf13/cobra"
1616
)
1717

18-
var projectIdFlag = globalflags.ProjectIdFlag
19-
2018
type testCtxKey struct{}
2119

2220
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
2321
var testClient = &serviceenablement.APIClient{}
2422
var testProjectId = uuid.NewString()
23+
var testRegion = "eu01"
2524

2625
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
2726
flagValues := map[string]string{
28-
projectIdFlag: testProjectId,
27+
globalflags.ProjectIdFlag: testProjectId,
28+
globalflags.RegionFlag: testRegion,
2929
}
3030
for _, mod := range mods {
3131
mod(flagValues)
@@ -37,6 +37,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
3737
model := &inputModel{
3838
GlobalFlagModel: &globalflags.GlobalFlagModel{
3939
ProjectId: testProjectId,
40+
Region: testRegion,
4041
Verbosity: globalflags.VerbosityDefault,
4142
},
4243
}
@@ -46,8 +47,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4647
return model
4748
}
4849

49-
func fixtureRequest(mods ...func(request *serviceenablement.ApiGetServiceStatusRequest)) serviceenablement.ApiGetServiceStatusRequest {
50-
request := testClient.GetServiceStatus(testCtx, testProjectId, serviceEnablementUtils.SKEServiceId) //nolint:staticcheck //command will be removed in a later update
50+
func fixtureRequest(mods ...func(request *serviceenablement.ApiGetServiceStatusRegionalRequest)) serviceenablement.ApiGetServiceStatusRegionalRequest {
51+
request := testClient.GetServiceStatusRegional(testCtx, testRegion, testProjectId, serviceEnablementUtils.SKEServiceId) //nolint:staticcheck //command will be removed in a later update
5152
for _, mod := range mods {
5253
mod(&request)
5354
}
@@ -75,21 +76,21 @@ func TestParseInput(t *testing.T) {
7576
{
7677
description: "project id missing",
7778
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
78-
delete(flagValues, projectIdFlag)
79+
delete(flagValues, globalflags.ProjectIdFlag)
7980
}),
8081
isValid: false,
8182
},
8283
{
8384
description: "project id invalid 1",
8485
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
85-
flagValues[projectIdFlag] = ""
86+
flagValues[globalflags.ProjectIdFlag] = ""
8687
}),
8788
isValid: false,
8889
},
8990
{
9091
description: "project id invalid 2",
9192
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
92-
flagValues[projectIdFlag] = "invalid-uuid"
93+
flagValues[globalflags.ProjectIdFlag] = "invalid-uuid"
9394
}),
9495
isValid: false,
9596
},
@@ -146,7 +147,7 @@ func TestBuildRequest(t *testing.T) {
146147
description string
147148
model *inputModel
148149
isValid bool
149-
expectedRequest serviceenablement.ApiGetServiceStatusRequest
150+
expectedRequest serviceenablement.ApiGetServiceStatusRegionalRequest
150151
}{
151152
{
152153
description: "base",

internal/cmd/ske/disable/disable.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
7272
if !model.Async {
7373
s := spinner.New(p)
7474
s.Start("Disabling SKE")
75-
_, err = wait.DisableServiceWaitHandler(ctx, apiClient, model.ProjectId, utils.SKEServiceId).WaitWithContext(ctx)
75+
_, err = wait.DisableServiceWaitHandler(ctx, apiClient, model.Region, model.ProjectId, utils.SKEServiceId).WaitWithContext(ctx)
7676
if err != nil {
7777
return fmt.Errorf("wait for SKE disabling: %w", err)
7878
}
@@ -112,7 +112,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
112112
return &model, nil
113113
}
114114

115-
func buildRequest(ctx context.Context, model *inputModel, apiClient *serviceenablement.APIClient) serviceenablement.ApiDisableServiceRequest {
116-
req := apiClient.DisableService(ctx, model.ProjectId, utils.SKEServiceId)
115+
func buildRequest(ctx context.Context, model *inputModel, apiClient *serviceenablement.APIClient) serviceenablement.ApiDisableServiceRegionalRequest {
116+
req := apiClient.DisableServiceRegional(ctx, model.Region, model.ProjectId, utils.SKEServiceId)
117117
return req
118118
}

internal/cmd/ske/disable/disable_test.go

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

18-
var projectIdFlag = globalflags.ProjectIdFlag
19-
2018
type testCtxKey struct{}
2119

2220
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
2321
var testClient = &serviceenablement.APIClient{}
2422
var testProjectId = uuid.NewString()
23+
var testRegion = "eu01"
2524

2625
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
2726
flagValues := map[string]string{
28-
projectIdFlag: testProjectId,
27+
globalflags.ProjectIdFlag: testProjectId,
28+
globalflags.RegionFlag: testRegion,
2929
}
3030
for _, mod := range mods {
3131
mod(flagValues)
@@ -37,6 +37,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
3737
model := &inputModel{
3838
GlobalFlagModel: &globalflags.GlobalFlagModel{
3939
ProjectId: testProjectId,
40+
Region: testRegion,
4041
Verbosity: globalflags.VerbosityDefault,
4142
},
4243
}
@@ -46,8 +47,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4647
return model
4748
}
4849

49-
func fixtureRequest(mods ...func(request *serviceenablement.ApiDisableServiceRequest)) serviceenablement.ApiDisableServiceRequest {
50-
request := testClient.DisableService(testCtx, testProjectId, utils.SKEServiceId)
50+
func fixtureRequest(mods ...func(request *serviceenablement.ApiDisableServiceRegionalRequest)) serviceenablement.ApiDisableServiceRegionalRequest {
51+
request := testClient.DisableServiceRegional(testCtx, testRegion, testProjectId, utils.SKEServiceId)
5152
for _, mod := range mods {
5253
mod(&request)
5354
}
@@ -75,21 +76,21 @@ func TestParseInput(t *testing.T) {
7576
{
7677
description: "project id missing",
7778
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
78-
delete(flagValues, projectIdFlag)
79+
delete(flagValues, globalflags.ProjectIdFlag)
7980
}),
8081
isValid: false,
8182
},
8283
{
8384
description: "project id invalid 1",
8485
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
85-
flagValues[projectIdFlag] = ""
86+
flagValues[globalflags.ProjectIdFlag] = ""
8687
}),
8788
isValid: false,
8889
},
8990
{
9091
description: "project id invalid 2",
9192
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
92-
flagValues[projectIdFlag] = "invalid-uuid"
93+
flagValues[globalflags.ProjectIdFlag] = "invalid-uuid"
9394
}),
9495
isValid: false,
9596
},
@@ -145,7 +146,7 @@ func TestBuildRequest(t *testing.T) {
145146
tests := []struct {
146147
description string
147148
model *inputModel
148-
expectedRequest serviceenablement.ApiDisableServiceRequest
149+
expectedRequest serviceenablement.ApiDisableServiceRegionalRequest
149150
}{
150151
{
151152
description: "base",

internal/cmd/ske/enable/enable.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
7272
if !model.Async {
7373
s := spinner.New(p)
7474
s.Start("Enabling SKE")
75-
_, err = wait.EnableServiceWaitHandler(ctx, apiClient, model.ProjectId, utils.SKEServiceId).WaitWithContext(ctx)
75+
_, err = wait.EnableServiceWaitHandler(ctx, apiClient, model.Region, model.ProjectId, utils.SKEServiceId).WaitWithContext(ctx)
7676
if err != nil {
7777
return fmt.Errorf("wait for SKE enabling: %w", err)
7878
}
@@ -112,7 +112,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
112112
return &model, nil
113113
}
114114

115-
func buildRequest(ctx context.Context, model *inputModel, apiClient *serviceenablement.APIClient) serviceenablement.ApiEnableServiceRequest {
116-
req := apiClient.EnableService(ctx, model.ProjectId, utils.SKEServiceId)
115+
func buildRequest(ctx context.Context, model *inputModel, apiClient *serviceenablement.APIClient) serviceenablement.ApiEnableServiceRegionalRequest {
116+
req := apiClient.EnableServiceRegional(ctx, model.Region, model.ProjectId, utils.SKEServiceId)
117117
return req
118118
}

internal/cmd/ske/enable/enable_test.go

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

18-
var projectIdFlag = globalflags.ProjectIdFlag
19-
2018
type testCtxKey struct{}
2119

2220
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
2321
var testClient = &serviceenablement.APIClient{}
2422
var testProjectId = uuid.NewString()
23+
var testRegion = "eu01"
2524

2625
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
2726
flagValues := map[string]string{
28-
projectIdFlag: testProjectId,
27+
globalflags.ProjectIdFlag: testProjectId,
28+
globalflags.RegionFlag: testRegion,
2929
}
3030
for _, mod := range mods {
3131
mod(flagValues)
@@ -37,6 +37,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
3737
model := &inputModel{
3838
GlobalFlagModel: &globalflags.GlobalFlagModel{
3939
ProjectId: testProjectId,
40+
Region: testRegion,
4041
Verbosity: globalflags.VerbosityDefault,
4142
},
4243
}
@@ -46,8 +47,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4647
return model
4748
}
4849

49-
func fixtureRequest(mods ...func(request *serviceenablement.ApiEnableServiceRequest)) serviceenablement.ApiEnableServiceRequest {
50-
request := testClient.EnableService(testCtx, testProjectId, utils.SKEServiceId)
50+
func fixtureRequest(mods ...func(request *serviceenablement.ApiEnableServiceRegionalRequest)) serviceenablement.ApiEnableServiceRegionalRequest {
51+
request := testClient.EnableServiceRegional(testCtx, testRegion, testProjectId, utils.SKEServiceId)
5152
for _, mod := range mods {
5253
mod(&request)
5354
}
@@ -75,21 +76,21 @@ func TestParseInput(t *testing.T) {
7576
{
7677
description: "project id missing",
7778
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
78-
delete(flagValues, projectIdFlag)
79+
delete(flagValues, globalflags.ProjectIdFlag)
7980
}),
8081
isValid: false,
8182
},
8283
{
8384
description: "project id invalid 1",
8485
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
85-
flagValues[projectIdFlag] = ""
86+
flagValues[globalflags.ProjectIdFlag] = ""
8687
}),
8788
isValid: false,
8889
},
8990
{
9091
description: "project id invalid 2",
9192
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
92-
flagValues[projectIdFlag] = "invalid-uuid"
93+
flagValues[globalflags.ProjectIdFlag] = "invalid-uuid"
9394
}),
9495
isValid: false,
9596
},
@@ -145,7 +146,7 @@ func TestBuildRequest(t *testing.T) {
145146
tests := []struct {
146147
description string
147148
model *inputModel
148-
expectedRequest serviceenablement.ApiEnableServiceRequest
149+
expectedRequest serviceenablement.ApiEnableServiceRegionalRequest
149150
}{
150151
{
151152
description: "base",

0 commit comments

Comments
 (0)