Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ require (
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v0.17.0
github.com/stackitcloud/stackit-sdk-go/services/logme v0.20.2
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.20.1
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v0.11.1
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.0.0
github.com/stackitcloud/stackit-sdk-go/services/observability v0.2.1
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.20.1
github.com/stackitcloud/stackit-sdk-go/services/redis v0.20.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v0.17.0 h1:SXNkKaAsG
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v0.17.0/go.mod h1:5hMtm08NrL+QcgKl94zUDrY7VEzKRcvCJOEOvENBxqc=
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v0.11.1 h1:Df3fTAHaVgyiiyp9LyTTQI8jXSVeGo49eW5ya4AATCY=
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v0.11.1/go.mod h1:V2LEHKyTaaiEBi9L3v62mNQ7xyJSred4OK+himLJOZQ=
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.0.0 h1:/0n2zcH1nMw2noroGhz0fgu2YqtNo9v3AsVhXMRtmtw=
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.0.0/go.mod h1:0XumGX33DT6ItyD8yMlogSPWvpIuoqN7RZBrpUBPX+k=
github.com/stackitcloud/stackit-sdk-go/services/observability v0.2.1 h1:sIz4wJIz6/9Eh6nSoi2sQ+Ef53iOrFsqLKIp2oRkmgo=
github.com/stackitcloud/stackit-sdk-go/services/observability v0.2.1/go.mod h1:okcRTrNDTI3d7MQcYJMliK0qoXeLq0b1wvZuEqgJIWE=
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.19.1 h1:hwRkCCUSWMhKTc7fLakL89V6+9xkxsFQlRthVmrvi1U=
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/object-storage/bucket/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
}

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

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiCreateBucketRequest {
req := apiClient.CreateBucket(ctx, model.ProjectId, model.BucketName)
req := apiClient.CreateBucket(ctx, model.ProjectId, model.GlobalFlagModel.Region, model.BucketName)
Comment thread
marceljk marked this conversation as resolved.
Outdated
return req
}

Expand Down
6 changes: 5 additions & 1 deletion internal/cmd/object-storage/bucket/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import (
)

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

type testCtxKey struct{}

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

func fixtureArgValues(mods ...func(argValues []string)) []string {
Expand All @@ -35,6 +37,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
regionFlag: testRegion,
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -47,6 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},
BucketName: testBucketName,
}
Expand All @@ -57,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *objectstorage.ApiCreateBucketRequest)) objectstorage.ApiCreateBucketRequest {
request := testClient.CreateBucket(testCtx, testProjectId, testBucketName)
request := testClient.CreateBucket(testCtx, testProjectId, testRegion, testBucketName)
for _, mod := range mods {
mod(&request)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/object-storage/bucket/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
if !model.Async {
s := spinner.New(p)
s.Start("Deleting bucket")
_, err = wait.DeleteBucketWaitHandler(ctx, apiClient, model.ProjectId, model.BucketName).WaitWithContext(ctx)
_, err = wait.DeleteBucketWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.BucketName).WaitWithContext(ctx)
if err != nil {
return fmt.Errorf("wait for Object Storage bucket deletion: %w", err)
}
Expand Down Expand Up @@ -113,6 +113,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiDeleteBucketRequest {
req := apiClient.DeleteBucket(ctx, model.ProjectId, model.BucketName)
req := apiClient.DeleteBucket(ctx, model.ProjectId, model.Region, model.BucketName)
return req
}
6 changes: 5 additions & 1 deletion internal/cmd/object-storage/bucket/delete/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import (
)

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

type testCtxKey struct{}

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

func fixtureArgValues(mods ...func(argValues []string)) []string {
Expand All @@ -35,6 +37,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
regionFlag: testRegion,
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -47,6 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},
BucketName: testBucketName,
}
Expand All @@ -57,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *objectstorage.ApiDeleteBucketRequest)) objectstorage.ApiDeleteBucketRequest {
request := testClient.DeleteBucket(testCtx, testProjectId, testBucketName)
request := testClient.DeleteBucket(testCtx, testProjectId, testRegion, testBucketName)
for _, mod := range mods {
mod(&request)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/object-storage/bucket/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiGetBucketRequest {
req := apiClient.GetBucket(ctx, model.ProjectId, model.BucketName)
req := apiClient.GetBucket(ctx, model.ProjectId, model.Region, model.BucketName)
return req
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import (
)

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

type testCtxKey struct{}

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

func fixtureArgValues(mods ...func(argValues []string)) []string {
Expand All @@ -35,6 +37,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
regionFlag: testRegion,
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -47,6 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},
BucketName: testBucketName,
}
Expand All @@ -57,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *objectstorage.ApiGetBucketRequest)) objectstorage.ApiGetBucketRequest {
request := testClient.GetBucket(testCtx, testProjectId, testBucketName)
request := testClient.GetBucket(testCtx, testProjectId, testRegion, testBucketName)
for _, mod := range mods {
mod(&request)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/object-storage/bucket/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiListBucketsRequest {
req := apiClient.ListBuckets(ctx, model.ProjectId)
req := apiClient.ListBuckets(ctx, model.ProjectId, model.Region)
return req
}

Expand Down
6 changes: 5 additions & 1 deletion internal/cmd/object-storage/bucket/list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ import (
)

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

type testCtxKey struct{}

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

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
limitFlag: "10",
regionFlag: testRegion,
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -39,6 +42,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},
Limit: utils.Ptr(int64(10)),
}
Expand All @@ -49,7 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *objectstorage.ApiListBucketsRequest)) objectstorage.ApiListBucketsRequest {
request := testClient.ListBuckets(testCtx, testProjectId)
request := testClient.ListBuckets(testCtx, testProjectId, testRegion)
for _, mod := range mods {
mod(&request)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiCreateCredentialsGroupRequest {
req := apiClient.CreateCredentialsGroup(ctx, model.ProjectId)
req := apiClient.CreateCredentialsGroup(ctx, model.ProjectId, model.Region)
req = req.CreateCredentialsGroupPayload(objectstorage.CreateCredentialsGroupPayload{
DisplayName: utils.Ptr(model.CredentialsGroupName),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ import (
)

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

type testCtxKey struct{}

var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
var testClient = &objectstorage.APIClient{}
var testProjectId = uuid.NewString()
var testCredentialsGroupName = "test-name"
var testRegion = "eu01"

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
credentialsGroupNameFlag: testCredentialsGroupName,
regionFlag: testRegion,
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -39,6 +42,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},
CredentialsGroupName: testCredentialsGroupName,
}
Expand All @@ -59,7 +63,7 @@ func fixturePayload(mods ...func(payload *objectstorage.CreateCredentialsGroupPa
}

func fixtureRequest(mods ...func(request *objectstorage.ApiCreateCredentialsGroupRequest)) objectstorage.ApiCreateCredentialsGroupRequest {
request := testClient.CreateCredentialsGroup(testCtx, testProjectId)
request := testClient.CreateCredentialsGroup(testCtx, testProjectId, testRegion)
request = request.CreateCredentialsGroupPayload(fixturePayload())
for _, mod := range mods {
mod(&request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
return err
}

credentialsGroupLabel, err := objectStorageUtils.GetCredentialsGroupName(ctx, apiClient, model.ProjectId, model.CredentialsGroupId)
credentialsGroupLabel, err := objectStorageUtils.GetCredentialsGroupName(ctx, apiClient, model.ProjectId, model.CredentialsGroupId, model.Region)
if err != nil {
p.Debug(print.ErrorLevel, "get credentials group name: %v", err)
credentialsGroupLabel = model.CredentialsGroupId
Expand Down Expand Up @@ -104,6 +104,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiDeleteCredentialsGroupRequest {
req := apiClient.DeleteCredentialsGroup(ctx, model.ProjectId, model.CredentialsGroupId)
req := apiClient.DeleteCredentialsGroup(ctx, model.ProjectId, model.GlobalFlagModel.Region, model.CredentialsGroupId)
return req
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import (
)

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

type testCtxKey struct{}

var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
var testClient = &objectstorage.APIClient{}
var testProjectId = uuid.NewString()
var testCredentialsGroupId = uuid.NewString()
var testRegion = "eu01"

func fixtureArgValues(mods ...func(argValues []string)) []string {
argValues := []string{
Expand All @@ -35,6 +37,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
regionFlag: testRegion,
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -47,6 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},
CredentialsGroupId: testCredentialsGroupId,
}
Expand All @@ -57,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *objectstorage.ApiDeleteCredentialsGroupRequest)) objectstorage.ApiDeleteCredentialsGroupRequest {
request := testClient.DeleteCredentialsGroup(testCtx, testProjectId, testCredentialsGroupId)
request := testClient.DeleteCredentialsGroup(testCtx, testProjectId, testRegion, testCredentialsGroupId)
for _, mod := range mods {
mod(&request)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiListCredentialsGroupsRequest {
req := apiClient.ListCredentialsGroups(ctx, model.ProjectId)
req := apiClient.ListCredentialsGroups(ctx, model.ProjectId, model.Region)
return req
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ import (
)

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

type testCtxKey struct{}

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

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
limitFlag: "10",
regionFlag: "eu01",
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -38,6 +41,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},
Limit: utils.Ptr(int64(10)),
}
Expand All @@ -48,7 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *objectstorage.ApiListCredentialsGroupsRequest)) objectstorage.ApiListCredentialsGroupsRequest {
request := testClient.ListCredentialsGroups(testCtx, testProjectId)
request := testClient.ListCredentialsGroups(testCtx, testProjectId, testRegion)
for _, mod := range mods {
mod(&request)
}
Expand Down
Loading