Skip to content

feat(postgresflex): migrate to v3 API - #1505

Open
rubenhoenle wants to merge 6 commits into
mainfrom
feat/postgresflex-v3-api
Open

feat(postgresflex): migrate to v3 API#1505
rubenhoenle wants to merge 6 commits into
mainfrom
feat/postgresflex-v3-api

Conversation

@rubenhoenle

Copy link
Copy Markdown
Member

Description

relates to STACKITCLI-415

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see e.g. here)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@rubenhoenle
rubenhoenle marked this pull request as ready for review July 29, 2026 13:31
@rubenhoenle
rubenhoenle requested a review from a team as a code owner July 29, 2026 13:31
@rubenhoenle
rubenhoenle force-pushed the feat/postgresflex-v3-api branch from 477d84b to 1a8fed5 Compare July 29, 2026 13:31
Comment thread internal/cmd/postgresflex/instance/create/create.go Outdated
Comment thread internal/cmd/postgresflex/backup/describe/describe.go
Comment thread internal/cmd/postgresflex/backup/list/list.go Outdated
Comment thread internal/cmd/postgresflex/instance/clone/clone.go
Comment thread internal/cmd/postgresflex/instance/create/create.go Outdated
Comment thread internal/cmd/postgresflex/instance/update/update.go Outdated
Comment thread internal/pkg/services/postgresflex/utils/utils.go Outdated
Comment thread internal/pkg/services/postgresflex/utils/utils.go Outdated
Comment thread internal/cmd/postgresflex/instance/update/update.go Outdated
Comment thread internal/cmd/postgresflex/backup/list/list.go Outdated
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Merging this branch changes the coverage (11 decrease, 9 increase)

Impacted Packages Coverage Δ 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/backup 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/backup/describe 67.44% (-0.64%) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/backup/list 64.15% (+3.77%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/backup/update-schedule 36.84% (-3.16%) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/flavor 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/flavor/describe 78.85% (+78.85%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/flavor/list 70.00% (+70.00%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/clone 42.86% (-16.88%) 💀
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/create 48.15% (-11.85%) 💀
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/delete 33.33% (+1.39%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/describe 72.92% (-6.77%) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/list 64.58% (+6.25%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/update 64.80% (-0.32%) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/options 57.95% (-0.29%) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/create 54.55% (-4.64%) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/delete 39.53% (+2.03%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/describe 68.18% (-0.87%) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/list 62.26% (+2.26%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/reset-password 48.98% (-1.02%) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/update 45.83% (+1.39%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/version 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/version/list 64.52% (+64.52%) 🌟
github.com/stackitcloud/stackit-cli/internal/pkg/services/postgresflex/client 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/pkg/services/postgresflex/utils 77.08% (-5.01%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/backup/backup.go 0.00% (ø) 6 0 6
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/backup/describe/describe.go 67.44% (-0.64%) 43 (-4) 29 (-3) 14 (-1) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/backup/list/list.go 64.15% (+3.77%) 53 34 (+2) 19 (-2) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/backup/update-schedule/update_schedule.go 36.84% (-3.16%) 38 (+3) 14 24 (+3) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/flavor/describe/describe.go 78.85% (+78.85%) 52 (+52) 41 (+41) 11 (+11) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/flavor/flavor.go 0.00% (ø) 5 (+5) 0 5 (+5)
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/flavor/list/list.go 70.00% (+70.00%) 40 (+40) 28 (+28) 12 (+12) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/clone/clone.go 42.86% (-16.88%) 70 (-7) 30 (-16) 40 (+9) 💀
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/create/create.go 48.15% (-11.85%) 135 (+35) 65 (+5) 70 (+30) 💀
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/delete/delete.go 33.33% (+1.39%) 45 (-27) 15 (-8) 30 (-19) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/describe/describe.go 72.92% (-6.77%) 48 (-16) 35 (-16) 13 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/list/list.go 64.58% (+6.25%) 48 31 (+3) 17 (-3) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/update/update.go 64.80% (-0.32%) 125 (-4) 81 (-3) 44 (-1) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/options/options.go 57.95% (-0.29%) 88 (-3) 51 (-2) 37 (-1) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/postgresflex.go 0.00% (ø) 9 (+2) 0 9 (+2)
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/create/create.go 54.55% (-4.64%) 44 (-5) 24 (-5) 20 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/delete/delete.go 39.53% (+2.03%) 43 (+3) 17 (+2) 26 (+1) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/describe/describe.go 68.18% (-0.87%) 44 (+2) 30 (+1) 14 (+1) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/list/list.go 62.26% (+2.26%) 53 (+3) 33 (+3) 20 👍
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/reset-password/reset_password.go 48.98% (-1.02%) 49 (+1) 24 25 (+1) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/update/update.go 45.83% (+1.39%) 48 (+3) 22 (+2) 26 (+1) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/version/list/list.go 64.52% (+64.52%) 31 (+31) 20 (+20) 11 (+11) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/version/version.go 0.00% (ø) 4 (+4) 0 4 (+4)
github.com/stackitcloud/stackit-cli/internal/pkg/services/postgresflex/client/client.go 0.00% (ø) 2 (+1) 0 2 (+1)
github.com/stackitcloud/stackit-cli/internal/pkg/services/postgresflex/utils/utils.go 77.08% (-5.01%) 48 (-19) 37 (-18) 11 (-1) 👎

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/backup/describe/describe_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/backup/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/backup/update-schedule/update_schedule_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/flavor/describe/describe_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/flavor/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/clone/clone_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/create/create_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/delete/delete_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/describe/describe_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/instance/update/update_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/options/options_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/create/create_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/delete/delete_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/describe/describe_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/reset-password/reset_password_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/user/update/update_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/version/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/services/postgresflex/utils/utils_test.go

ListVersions(ctx context.Context, projectId, region string) postgresflex.ApiListVersionsRequest
GetInstance(ctx context.Context, projectId, region, instanceId string) postgresflex.ApiGetInstanceRequest
GetUser(ctx context.Context, projectId, region, instanceId, userId string) postgresflex.ApiGetUserRequest
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client is not used anymore, we can remove it

Comment on lines 40 to 72
func GetInstanceReplicas(instanceType string) (int32, error) {
numReplicas, ok := instanceTypeToReplicas[instanceType]
if !ok {
return 0, fmt.Errorf("invalid instance type: %v", instanceType)
}
return numReplicas, nil
}

func GetInstanceType(numReplicas int32) (string, error) {
for k, v := range instanceTypeToReplicas {
if v == numReplicas {
return k, nil
}
}
return "", fmt.Errorf("invalid number of replicas: %v", numReplicas)
}

func ValidateFlavorId(flavorId string, flavors []postgresflex.Flavor) error {
func ValidateFlavorId(flavorId string, flavors []postgresflex.ListFlavors) error {
if flavors == nil {
return fmt.Errorf("nil flavors")
}

for _, f := range flavors {
if f.Id != nil && strings.EqualFold(*f.Id, flavorId) {
if strings.EqualFold(f.Id, flavorId) {
return nil
}
}

return &errors.DatabaseInvalidFlavorError{
Service: "postgresflex",
Details: fmt.Sprintf("You provided flavor ID '%s', which is invalid.", flavorId),
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetInstanceReplicas, GetInstanceType and ValidateFlavorId functions are not used anymore. We can clean up

}
}

func TestGetInstanceType(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test can be cleaned up after related util function is deleted

}
}

func TestValidateFlavorId(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test can be cleaned up after related util function is deleted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants