Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -28,7 +28,7 @@ require (
github.com/stackitcloud/stackit-sdk-go/services/logs v0.10.1
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.12.1
github.com/stackitcloud/stackit-sdk-go/services/opensearch v1.3.0
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.12.0
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.13.0
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.2
github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.9.1
github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ github.com/stackitcloud/stackit-sdk-go/services/observability v0.25.0 h1:r3URNI1
github.com/stackitcloud/stackit-sdk-go/services/observability v0.25.0/go.mod h1:0fEZQHm729mBdvg4sNrAhM6KmHROHJSeS2FwCMRk46k=
github.com/stackitcloud/stackit-sdk-go/services/opensearch v1.3.0 h1:j8327l7QFhdL4ETg3kV9Q7Jle5GFYtfxMkBS3IvalDo=
github.com/stackitcloud/stackit-sdk-go/services/opensearch v1.3.0/go.mod h1:L+NlfC1hilLOqlLLukCj/UDnxlnNrc/oMikcw3Ansyw=
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.12.0 h1:elIyrDVSYlEtigFO82SWnpfuJZdpv0b2SwvL3M+z9dA=
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.12.0/go.mod h1:yzlakB+f8ur4yAHR6lyCABO+HcEtZG3G2Faj6m5/uW8=
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.13.0 h1:o8+bH3763G5oU1Y8Bf5nkQ8kzqFO7su0VUpeSGKdoPY=
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.13.0/go.mod h1:yzlakB+f8ur4yAHR6lyCABO+HcEtZG3G2Faj6m5/uW8=
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.3.0 h1:jX0fN80M87/O8RVA+kNX1yioj+y30dHd6VrFC8OrRTA=
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.3.0/go.mod h1:TwfVVynB/+AKbccSOLk2qZpPL1tdK43BBAiACP6EtSg=
github.com/stackitcloud/stackit-sdk-go/services/redis v1.4.0 h1:/f1sItmKRplpM8Kaa5LMnmfUPvnlgu5Tf+HV0w57pV0=
Expand Down
5 changes: 4 additions & 1 deletion internal/cmd/postgresflex/instance/clone/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,13 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient postgresflex
if model.StorageSize == nil {
return postgresflex.ApiCloneInstanceRequest{}, fmt.Errorf("storage size is nil")
}
if model.StorageClass == nil {
return postgresflex.ApiCloneInstanceRequest{}, fmt.Errorf("storage class is nil")
}

payload := postgresflex.CloneInstancePayload{
InstanceOverrides: postgresflex.CloneInstanceOverrides{
Class: model.StorageClass,
Class: *model.StorageClass,
Size: *model.StorageSize,
Name: model.InstanceName,
},
Expand Down
17 changes: 14 additions & 3 deletions internal/cmd/postgresflex/instance/clone/clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ func fixturePayload(mods ...func(payload *postgresflex.CloneInstancePayload)) po

payload := postgresflex.CloneInstancePayload{
InstanceOverrides: postgresflex.CloneInstanceOverrides{
Size: testStorageSize,
Class: testStorageClass,
Size: testStorageSize,
},
PointInTime: testRecoveryTimestamp,
}
Expand Down Expand Up @@ -302,6 +303,7 @@ func TestBuildRequest(t *testing.T) {
description: "base",
model: fixtureRequiredInputModel(
func(model *inputModel) {
model.StorageClass = utils.Ptr(testStorageClass)
model.StorageSize = utils.Ptr(testStorageSize)
},
),
Expand All @@ -318,7 +320,7 @@ func TestBuildRequest(t *testing.T) {
expectedRequest: testClient.DefaultAPI.CloneInstance(testCtx, testProjectId, testRegion, testInstanceId).
CloneInstancePayload(postgresflex.CloneInstancePayload{
InstanceOverrides: postgresflex.CloneInstanceOverrides{
Class: utils.Ptr("class"),
Class: "class",
Size: testStorageSize,
},
PointInTime: testRecoveryTimestamp,
Expand All @@ -327,10 +329,19 @@ func TestBuildRequest(t *testing.T) {
{
description: "storage size missing",
model: fixtureRequiredInputModel(func(model *inputModel) {
model.StorageClass = utils.Ptr(testStorageClass)
model.StorageSize = nil
}),
isValid: false,
},
{
description: "storage class missing",
model: fixtureRequiredInputModel(func(model *inputModel) {
model.StorageClass = nil
model.StorageSize = utils.Ptr(testStorageSize)
}),
isValid: false,
},
{
description: "specify storage class and size",
model: fixtureRequiredInputModel(func(model *inputModel) {
Expand All @@ -341,7 +352,7 @@ func TestBuildRequest(t *testing.T) {
expectedRequest: testClient.DefaultAPI.CloneInstance(testCtx, testProjectId, testRegion, testInstanceId).
CloneInstancePayload(postgresflex.CloneInstancePayload{
InstanceOverrides: postgresflex.CloneInstanceOverrides{
Class: utils.Ptr("class"),
Class: "class",
Size: int64(10),
},
PointInTime: testRecoveryTimestamp,
Expand Down
4 changes: 3 additions & 1 deletion internal/cmd/postgresflex/instance/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient postgresflex
return postgresflex.ApiCreateInstanceRequest{}, fmt.Errorf("storage size is nil")
} else if model.Version == nil {
return postgresflex.ApiCreateInstanceRequest{}, fmt.Errorf("version is nil")
} else if model.StorageClass == nil {
return postgresflex.ApiCreateInstanceRequest{}, fmt.Errorf("storage class is nil")
}

req = req.CreateInstancePayload(postgresflex.CreateInstancePayload{
Expand All @@ -363,7 +365,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient postgresflex
},
RetentionDays: *postgresflex.NewNullableInt32(model.RetentionDays),
Storage: postgresflex.StorageCreate{
Class: model.StorageClass,
Class: *model.StorageClass,
Size: *model.StorageSize,
},
Version: *model.Version,
Expand Down
30 changes: 29 additions & 1 deletion internal/cmd/postgresflex/instance/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func fixturePayload(mods ...func(payload *postgresflex.CreateInstancePayload)) p
Acl: []string{"0.0.0.0/0"},
},
Storage: postgresflex.StorageCreate{
Class: utils.Ptr("premium-perf4-stackit"),
Class: "premium-perf4-stackit",
Size: int64(10),
},
Version: "6.0",
Expand Down Expand Up @@ -271,6 +271,34 @@ func TestBuildRequest(t *testing.T) {
*request = request.CreateInstancePayload(payload)
}),
},
{
description: "storage class missing",
model: fixtureInputModel(func(model *inputModel) {
model.StorageClass = nil
}),
isValid: false,
},
{
description: "storage size missing",
model: fixtureInputModel(func(model *inputModel) {
model.StorageSize = nil
}),
isValid: false,
},
{
description: "backup schedule missing",
model: fixtureInputModel(func(model *inputModel) {
model.BackupSchedule = nil
}),
isValid: false,
},
{
description: "version missing",
model: fixtureInputModel(func(model *inputModel) {
model.Version = nil
}),
isValid: false,
},
}

for _, tt := range tests {
Expand Down