Skip to content

Commit 99638ed

Browse files
authored
feat(ske): Region adjustment (#842)
Signed-off-by: Alexander Dahmen <[email protected]>
1 parent 3bf6282 commit 99638ed

File tree

27 files changed

+128
-74
lines changed

27 files changed

+128
-74
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require (
3131
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.2.0
3232
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.9.0
3333
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.1
34-
github.com/stackitcloud/stackit-sdk-go/services/ske v0.27.0
34+
github.com/stackitcloud/stackit-sdk-go/services/ske v1.0.0
3535
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.3.0
3636
github.com/zalando/go-keyring v0.2.6
3737
golang.org/x/mod v0.25.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,8 @@ github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.9.0 h1:2d28WFQ
608608
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.9.0/go.mod h1:t77MA8uyEU9KZd1On5JpnxI3xhVPKIS8WutStqvU8Cw=
609609
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.1 h1:h1TsWatlsexLeKdkb3L8chcxaXJOy/cLXctsRxhb4xg=
610610
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.1/go.mod h1:M4xZ2BnmROvLV2MrAP6A8o9BnyT0CkvpEcP8lBOfRs8=
611-
github.com/stackitcloud/stackit-sdk-go/services/ske v0.27.0 h1:bwLmLXvtCl1XkPRP+YrXwfz+lBMaGWH/crlNbYtxeqE=
612-
github.com/stackitcloud/stackit-sdk-go/services/ske v0.27.0/go.mod h1:V09NmPahuUiuZEogVPgxuVqqti0th5B7TVAjuiM09mE=
611+
github.com/stackitcloud/stackit-sdk-go/services/ske v1.0.0 h1:PX8VTo2UhPd6BeEaCHFlpIkDbk9OFQEO6eJJ8JkxesA=
612+
github.com/stackitcloud/stackit-sdk-go/services/ske v1.0.0/go.mod h1:V09NmPahuUiuZEogVPgxuVqqti0th5B7TVAjuiM09mE=
613613
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.3.0 h1:pUl/981oAXPnZd7++69NfEWv6JwW9UpxER16XxQUdOk=
614614
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.3.0/go.mod h1:S04/QsQrB2EgYGjl62BO+9QUswrlRBoBosigrhdmccM=
615615
github.com/stbenjam/no-sprintf-host-port v0.2.0 h1:i8pxvGrt1+4G0czLr/WnmyH7zbZ8Bg8etvARQ1rpyl4=

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
108108
}
109109

110110
// Check if cluster exists
111-
exists, err := skeUtils.ClusterExists(ctx, apiClient, model.ProjectId, model.ClusterName)
111+
exists, err := skeUtils.ClusterExists(ctx, apiClient, model.ProjectId, model.Region, model.ClusterName)
112112
if err != nil {
113113
return err
114114
}
@@ -118,7 +118,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
118118

119119
// Fill in default payload, if needed
120120
if model.Payload == nil {
121-
defaultPayload, err := skeUtils.GetDefaultPayload(ctx, apiClient)
121+
defaultPayload, err := skeUtils.GetDefaultPayload(ctx, apiClient, model.Region)
122122
if err != nil {
123123
return fmt.Errorf("get default payload: %w", err)
124124
}
@@ -137,7 +137,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
137137
if !model.Async {
138138
s := spinner.New(params.Printer)
139139
s.Start("Creating cluster")
140-
_, err = wait.CreateOrUpdateClusterWaitHandler(ctx, apiClient, model.ProjectId, name).WaitWithContext(ctx)
140+
_, err = wait.CreateOrUpdateClusterWaitHandler(ctx, apiClient, model.ProjectId, model.Region, name).WaitWithContext(ctx)
141141
if err != nil {
142142
return fmt.Errorf("wait for SKE cluster creation: %w", err)
143143
}
@@ -192,7 +192,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
192192
}
193193

194194
func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClient) ske.ApiCreateOrUpdateClusterRequest {
195-
req := apiClient.CreateOrUpdateCluster(ctx, model.ProjectId, model.ClusterName)
195+
req := apiClient.CreateOrUpdateCluster(ctx, model.ProjectId, model.Region, model.ClusterName)
196196

197197
req = req.CreateOrUpdateClusterPayload(*model.Payload)
198198
return req

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ var testClient = &ske.APIClient{}
2626
var testProjectId = uuid.NewString()
2727
var testClusterName = "cluster"
2828

29+
const testRegion = "eu01"
30+
2931
var testPayload = &ske.CreateOrUpdateClusterPayload{
3032
Kubernetes: &ske.Kubernetes{
3133
Version: utils.Ptr("1.25.15"),
@@ -81,7 +83,8 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
8183

8284
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
8385
flagValues := map[string]string{
84-
projectIdFlag: testProjectId,
86+
globalflags.ProjectIdFlag: testProjectId,
87+
globalflags.RegionFlag: testRegion,
8588
payloadFlag: fmt.Sprintf(`{
8689
"name": "cli-jp",
8790
"kubernetes": {
@@ -128,6 +131,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
128131
model := &inputModel{
129132
GlobalFlagModel: &globalflags.GlobalFlagModel{
130133
ProjectId: testProjectId,
134+
Region: testRegion,
131135
Verbosity: globalflags.VerbosityDefault,
132136
},
133137
ClusterName: testClusterName,
@@ -140,7 +144,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
140144
}
141145

142146
func fixtureRequest(mods ...func(request *ske.ApiCreateOrUpdateClusterRequest)) ske.ApiCreateOrUpdateClusterRequest {
143-
request := testClient.CreateOrUpdateCluster(testCtx, testProjectId, fixtureInputModel().ClusterName)
147+
request := testClient.CreateOrUpdateCluster(testCtx, testProjectId, testRegion, fixtureInputModel().ClusterName)
144148
request = request.CreateOrUpdateClusterPayload(*testPayload)
145149
for _, mod := range mods {
146150
mod(&request)

internal/cmd/ske/cluster/delete/delete.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
7070
if !model.Async {
7171
s := spinner.New(params.Printer)
7272
s.Start("Deleting cluster")
73-
_, err = wait.DeleteClusterWaitHandler(ctx, apiClient, model.ProjectId, model.ClusterName).WaitWithContext(ctx)
73+
_, err = wait.DeleteClusterWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ClusterName).WaitWithContext(ctx)
7474
if err != nil {
7575
return fmt.Errorf("wait for SKE cluster deletion: %w", err)
7676
}
@@ -114,6 +114,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
114114
}
115115

116116
func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClient) ske.ApiDeleteClusterRequest {
117-
req := apiClient.DeleteCluster(ctx, model.ProjectId, model.ClusterName)
117+
req := apiClient.DeleteCluster(ctx, model.ProjectId, model.Region, model.ClusterName)
118118
return req
119119
}

internal/cmd/ske/cluster/delete/delete_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ var testClient = &ske.APIClient{}
2323
var testProjectId = uuid.NewString()
2424
var testClusterName = "cluster"
2525

26+
const testRegion = "eu01"
27+
2628
func fixtureArgValues(mods ...func(argValues []string)) []string {
2729
argValues := []string{
2830
testClusterName,
@@ -35,7 +37,8 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3537

3638
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3739
flagValues := map[string]string{
38-
projectIdFlag: testProjectId,
40+
globalflags.ProjectIdFlag: testProjectId,
41+
globalflags.RegionFlag: testRegion,
3942
}
4043
for _, mod := range mods {
4144
mod(flagValues)
@@ -47,6 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4750
model := &inputModel{
4851
GlobalFlagModel: &globalflags.GlobalFlagModel{
4952
ProjectId: testProjectId,
53+
Region: testRegion,
5054
Verbosity: globalflags.VerbosityDefault,
5155
},
5256
ClusterName: testClusterName,
@@ -58,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5862
}
5963

6064
func fixtureRequest(mods ...func(request *ske.ApiDeleteClusterRequest)) ske.ApiDeleteClusterRequest {
61-
request := testClient.DeleteCluster(testCtx, testProjectId, testClusterName)
65+
request := testClient.DeleteCluster(testCtx, testProjectId, testRegion, testClusterName)
6266
for _, mod := range mods {
6367
mod(&request)
6468
}

internal/cmd/ske/cluster/describe/describe.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, inputArgs []string) (*inpu
9393
}
9494

9595
func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClient) ske.ApiGetClusterRequest {
96-
req := apiClient.GetCluster(ctx, model.ProjectId, model.ClusterName)
96+
req := apiClient.GetCluster(ctx, model.ProjectId, model.Region, model.ClusterName)
9797
return req
9898
}
9999

internal/cmd/ske/cluster/describe/describe_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ var testClient = &ske.APIClient{}
2323
var testProjectId = uuid.NewString()
2424
var testClusterName = "cluster"
2525

26+
const testRegion = "eu01"
27+
2628
func fixtureArgValues(mods ...func(argValues []string)) []string {
2729
argValues := []string{
2830
testClusterName,
@@ -35,7 +37,8 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3537

3638
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3739
flagValues := map[string]string{
38-
projectIdFlag: testProjectId,
40+
globalflags.ProjectIdFlag: testProjectId,
41+
globalflags.RegionFlag: testRegion,
3942
}
4043
for _, mod := range mods {
4144
mod(flagValues)
@@ -47,6 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4750
model := &inputModel{
4851
GlobalFlagModel: &globalflags.GlobalFlagModel{
4952
ProjectId: testProjectId,
53+
Region: testRegion,
5054
Verbosity: globalflags.VerbosityDefault,
5155
},
5256
ClusterName: testClusterName,
@@ -58,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5862
}
5963

6064
func fixtureRequest(mods ...func(request *ske.ApiGetClusterRequest)) ske.ApiGetClusterRequest {
61-
request := testClient.GetCluster(testCtx, testProjectId, testClusterName)
65+
request := testClient.GetCluster(testCtx, testProjectId, testRegion, testClusterName)
6266
for _, mod := range mods {
6367
mod(&request)
6468
}

internal/cmd/ske/cluster/generate-payload/generate_payload.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
7070

7171
var payload *ske.CreateOrUpdateClusterPayload
7272
if model.ClusterName == nil {
73-
payload, err = skeUtils.GetDefaultPayload(ctx, apiClient)
73+
payload, err = skeUtils.GetDefaultPayload(ctx, apiClient, model.Region)
7474
if err != nil {
7575
return err
7676
}
@@ -130,7 +130,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
130130
}
131131

132132
func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClient) ske.ApiGetClusterRequest {
133-
req := apiClient.GetCluster(ctx, model.ProjectId, *model.ClusterName)
133+
req := apiClient.GetCluster(ctx, model.ProjectId, model.Region, *model.ClusterName)
134134
return req
135135
}
136136

internal/cmd/ske/cluster/generate-payload/generate_payload_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ const (
2828
testFilePath = "example-file"
2929
)
3030

31+
const testRegion = "eu01"
32+
3133
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3234
flagValues := map[string]string{
33-
projectIdFlag: testProjectId,
34-
clusterNameFlag: testClusterName,
35-
filePathFlag: testFilePath,
35+
globalflags.ProjectIdFlag: testProjectId,
36+
globalflags.RegionFlag: testRegion,
37+
clusterNameFlag: testClusterName,
38+
filePathFlag: testFilePath,
3639
}
3740
for _, mod := range mods {
3841
mod(flagValues)
@@ -44,6 +47,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4447
model := &inputModel{
4548
GlobalFlagModel: &globalflags.GlobalFlagModel{
4649
ProjectId: testProjectId,
50+
Region: testRegion,
4751
Verbosity: globalflags.VerbosityDefault,
4852
},
4953
ClusterName: utils.Ptr(testClusterName),
@@ -56,7 +60,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5660
}
5761

5862
func fixtureRequest(mods ...func(request *ske.ApiGetClusterRequest)) ske.ApiGetClusterRequest {
59-
request := testClient.GetCluster(testCtx, testProjectId, testClusterName)
63+
request := testClient.GetCluster(testCtx, testProjectId, testRegion, testClusterName)
6064
for _, mod := range mods {
6165
mod(&request)
6266
}

0 commit comments

Comments
 (0)