Skip to content

Commit e214df1

Browse files
authored
feat: region adjustment object storage (#592)
* Region adjustment of object-storage regarding the SDK update * upgrade dependency github.com/stackitcloud/stackit-sdk-go/services/objectstorage to version 1.0.0 * fix: Renamed `model.GlobalFlagModel.Region` to `model.Region` to stay consistent
1 parent d2bc80c commit e214df1

File tree

28 files changed

+99
-48
lines changed

28 files changed

+99
-48
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ require (
8282
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v0.17.0
8383
github.com/stackitcloud/stackit-sdk-go/services/logme v0.20.2
8484
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.20.1
85-
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v0.11.1
85+
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.0.0
8686
github.com/stackitcloud/stackit-sdk-go/services/observability v0.2.1
8787
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.20.1
8888
github.com/stackitcloud/stackit-sdk-go/services/redis v0.20.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v0.17.0 h1:SXNkKaAsG
136136
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v0.17.0/go.mod h1:5hMtm08NrL+QcgKl94zUDrY7VEzKRcvCJOEOvENBxqc=
137137
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v0.11.1 h1:Df3fTAHaVgyiiyp9LyTTQI8jXSVeGo49eW5ya4AATCY=
138138
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v0.11.1/go.mod h1:V2LEHKyTaaiEBi9L3v62mNQ7xyJSred4OK+himLJOZQ=
139+
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.0.0 h1:/0n2zcH1nMw2noroGhz0fgu2YqtNo9v3AsVhXMRtmtw=
140+
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.0.0/go.mod h1:0XumGX33DT6ItyD8yMlogSPWvpIuoqN7RZBrpUBPX+k=
139141
github.com/stackitcloud/stackit-sdk-go/services/observability v0.2.1 h1:sIz4wJIz6/9Eh6nSoi2sQ+Ef53iOrFsqLKIp2oRkmgo=
140142
github.com/stackitcloud/stackit-sdk-go/services/observability v0.2.1/go.mod h1:okcRTrNDTI3d7MQcYJMliK0qoXeLq0b1wvZuEqgJIWE=
141143
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.19.1 h1:hwRkCCUSWMhKTc7fLakL89V6+9xkxsFQlRthVmrvi1U=

internal/cmd/object-storage/bucket/create/create.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
6262
}
6363

6464
// Check if the project is enabled before trying to create
65-
enabled, err := utils.ProjectEnabled(ctx, apiClient, model.ProjectId)
65+
enabled, err := utils.ProjectEnabled(ctx, apiClient, model.ProjectId, model.Region)
6666
if err != nil {
6767
return fmt.Errorf("check if Object Storage is enabled: %w", err)
6868
}
@@ -83,7 +83,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
8383
if !model.Async {
8484
s := spinner.New(p)
8585
s.Start("Creating bucket")
86-
_, err = wait.CreateBucketWaitHandler(ctx, apiClient, model.ProjectId, model.BucketName).WaitWithContext(ctx)
86+
_, err = wait.CreateBucketWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.BucketName).WaitWithContext(ctx)
8787
if err != nil {
8888
return fmt.Errorf("wait for Object Storage bucket creation: %w", err)
8989
}
@@ -122,7 +122,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
122122
}
123123

124124
func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiCreateBucketRequest {
125-
req := apiClient.CreateBucket(ctx, model.ProjectId, model.BucketName)
125+
req := apiClient.CreateBucket(ctx, model.ProjectId, model.Region, model.BucketName)
126126
return req
127127
}
128128

internal/cmd/object-storage/bucket/create/create_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ import (
1414
)
1515

1616
var projectIdFlag = globalflags.ProjectIdFlag
17+
var regionFlag = globalflags.RegionFlag
1718

1819
type testCtxKey struct{}
1920

2021
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
2122
var testClient = &objectstorage.APIClient{}
2223
var testProjectId = uuid.NewString()
24+
var testRegion = "eu01"
2325
var testBucketName = "my-bucket"
2426

2527
func fixtureArgValues(mods ...func(argValues []string)) []string {
@@ -35,6 +37,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3537
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3638
flagValues := map[string]string{
3739
projectIdFlag: testProjectId,
40+
regionFlag: testRegion,
3841
}
3942
for _, mod := range mods {
4043
mod(flagValues)
@@ -47,6 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4750
GlobalFlagModel: &globalflags.GlobalFlagModel{
4851
ProjectId: testProjectId,
4952
Verbosity: globalflags.VerbosityDefault,
53+
Region: testRegion,
5054
},
5155
BucketName: testBucketName,
5256
}
@@ -57,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5761
}
5862

5963
func fixtureRequest(mods ...func(request *objectstorage.ApiCreateBucketRequest)) objectstorage.ApiCreateBucketRequest {
60-
request := testClient.CreateBucket(testCtx, testProjectId, testBucketName)
64+
request := testClient.CreateBucket(testCtx, testProjectId, testRegion, testBucketName)
6165
for _, mod := range mods {
6266
mod(&request)
6367
}

internal/cmd/object-storage/bucket/delete/delete.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
6969
if !model.Async {
7070
s := spinner.New(p)
7171
s.Start("Deleting bucket")
72-
_, err = wait.DeleteBucketWaitHandler(ctx, apiClient, model.ProjectId, model.BucketName).WaitWithContext(ctx)
72+
_, err = wait.DeleteBucketWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.BucketName).WaitWithContext(ctx)
7373
if err != nil {
7474
return fmt.Errorf("wait for Object Storage bucket deletion: %w", err)
7575
}
@@ -113,6 +113,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
113113
}
114114

115115
func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiDeleteBucketRequest {
116-
req := apiClient.DeleteBucket(ctx, model.ProjectId, model.BucketName)
116+
req := apiClient.DeleteBucket(ctx, model.ProjectId, model.Region, model.BucketName)
117117
return req
118118
}

internal/cmd/object-storage/bucket/delete/delete_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ import (
1414
)
1515

1616
var projectIdFlag = globalflags.ProjectIdFlag
17+
var regionFlag = globalflags.RegionFlag
1718

1819
type testCtxKey struct{}
1920

2021
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
2122
var testClient = &objectstorage.APIClient{}
2223
var testProjectId = uuid.NewString()
24+
var testRegion = "eu01"
2325
var testBucketName = "my-bucket"
2426

2527
func fixtureArgValues(mods ...func(argValues []string)) []string {
@@ -35,6 +37,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3537
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3638
flagValues := map[string]string{
3739
projectIdFlag: testProjectId,
40+
regionFlag: testRegion,
3841
}
3942
for _, mod := range mods {
4043
mod(flagValues)
@@ -47,6 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4750
GlobalFlagModel: &globalflags.GlobalFlagModel{
4851
ProjectId: testProjectId,
4952
Verbosity: globalflags.VerbosityDefault,
53+
Region: testRegion,
5054
},
5155
BucketName: testBucketName,
5256
}
@@ -57,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5761
}
5862

5963
func fixtureRequest(mods ...func(request *objectstorage.ApiDeleteBucketRequest)) objectstorage.ApiDeleteBucketRequest {
60-
request := testClient.DeleteBucket(testCtx, testProjectId, testBucketName)
64+
request := testClient.DeleteBucket(testCtx, testProjectId, testRegion, testBucketName)
6165
for _, mod := range mods {
6266
mod(&request)
6367
}

internal/cmd/object-storage/bucket/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 *objectstorage.APIClient) objectstorage.ApiGetBucketRequest {
96-
req := apiClient.GetBucket(ctx, model.ProjectId, model.BucketName)
96+
req := apiClient.GetBucket(ctx, model.ProjectId, model.Region, model.BucketName)
9797
return req
9898
}
9999

internal/cmd/object-storage/bucket/describe/describe_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ import (
1414
)
1515

1616
var projectIdFlag = globalflags.ProjectIdFlag
17+
var regionFlag = globalflags.RegionFlag
1718

1819
type testCtxKey struct{}
1920

2021
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
2122
var testClient = &objectstorage.APIClient{}
2223
var testProjectId = uuid.NewString()
24+
var testRegion = "eu01"
2325
var testBucketName = "my-bucket"
2426

2527
func fixtureArgValues(mods ...func(argValues []string)) []string {
@@ -35,6 +37,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3537
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3638
flagValues := map[string]string{
3739
projectIdFlag: testProjectId,
40+
regionFlag: testRegion,
3841
}
3942
for _, mod := range mods {
4043
mod(flagValues)
@@ -47,6 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4750
GlobalFlagModel: &globalflags.GlobalFlagModel{
4851
ProjectId: testProjectId,
4952
Verbosity: globalflags.VerbosityDefault,
53+
Region: testRegion,
5054
},
5155
BucketName: testBucketName,
5256
}
@@ -57,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5761
}
5862

5963
func fixtureRequest(mods ...func(request *objectstorage.ApiGetBucketRequest)) objectstorage.ApiGetBucketRequest {
60-
request := testClient.GetBucket(testCtx, testProjectId, testBucketName)
64+
request := testClient.GetBucket(testCtx, testProjectId, testRegion, testBucketName)
6165
for _, mod := range mods {
6266
mod(&request)
6367
}

internal/cmd/object-storage/bucket/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
125125
}
126126

127127
func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiListBucketsRequest {
128-
req := apiClient.ListBuckets(ctx, model.ProjectId)
128+
req := apiClient.ListBuckets(ctx, model.ProjectId, model.Region)
129129
return req
130130
}
131131

internal/cmd/object-storage/bucket/list/list_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,20 @@ import (
1616
)
1717

1818
var projectIdFlag = globalflags.ProjectIdFlag
19+
var regionFlag = globalflags.RegionFlag
1920

2021
type testCtxKey struct{}
2122

2223
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
2324
var testClient = &objectstorage.APIClient{}
2425
var testProjectId = uuid.NewString()
26+
var testRegion = "eu01"
2527

2628
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
2729
flagValues := map[string]string{
2830
projectIdFlag: testProjectId,
2931
limitFlag: "10",
32+
regionFlag: testRegion,
3033
}
3134
for _, mod := range mods {
3235
mod(flagValues)
@@ -39,6 +42,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
3942
GlobalFlagModel: &globalflags.GlobalFlagModel{
4043
ProjectId: testProjectId,
4144
Verbosity: globalflags.VerbosityDefault,
45+
Region: testRegion,
4246
},
4347
Limit: utils.Ptr(int64(10)),
4448
}
@@ -49,7 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4953
}
5054

5155
func fixtureRequest(mods ...func(request *objectstorage.ApiListBucketsRequest)) objectstorage.ApiListBucketsRequest {
52-
request := testClient.ListBuckets(testCtx, testProjectId)
56+
request := testClient.ListBuckets(testCtx, testProjectId, testRegion)
5357
for _, mod := range mods {
5458
mod(&request)
5559
}

0 commit comments

Comments
 (0)