Skip to content

Commit b843f75

Browse files
committed
Region adjustment of object-storage regarding the SDK update
1 parent 1d85aa4 commit b843f75

File tree

26 files changed

+96
-47
lines changed

26 files changed

+96
-47
lines changed

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.GlobalFlagModel.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
}

internal/cmd/object-storage/credentials-group/create/create.go

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

107107
func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiCreateCredentialsGroupRequest {
108-
req := apiClient.CreateCredentialsGroup(ctx, model.ProjectId)
108+
req := apiClient.CreateCredentialsGroup(ctx, model.ProjectId, model.Region)
109109
req = req.CreateCredentialsGroupPayload(objectstorage.CreateCredentialsGroupPayload{
110110
DisplayName: utils.Ptr(model.CredentialsGroupName),
111111
})

internal/cmd/object-storage/credentials-group/create/create_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@ import (
1515
)
1616

1717
var projectIdFlag = globalflags.ProjectIdFlag
18+
var regionFlag = globalflags.RegionFlag
1819

1920
type testCtxKey struct{}
2021

2122
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
2223
var testClient = &objectstorage.APIClient{}
2324
var testProjectId = uuid.NewString()
2425
var testCredentialsGroupName = "test-name"
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
credentialsGroupNameFlag: testCredentialsGroupName,
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
CredentialsGroupName: testCredentialsGroupName,
4448
}
@@ -59,7 +63,7 @@ func fixturePayload(mods ...func(payload *objectstorage.CreateCredentialsGroupPa
5963
}
6064

6165
func fixtureRequest(mods ...func(request *objectstorage.ApiCreateCredentialsGroupRequest)) objectstorage.ApiCreateCredentialsGroupRequest {
62-
request := testClient.CreateCredentialsGroup(testCtx, testProjectId)
66+
request := testClient.CreateCredentialsGroup(testCtx, testProjectId, testRegion)
6367
request = request.CreateCredentialsGroupPayload(fixturePayload())
6468
for _, mod := range mods {
6569
mod(&request)

0 commit comments

Comments
 (0)