Skip to content

feat(mongodbflex): refactor implementation - #1586

Open
GokceGK wants to merge 3 commits into
mainfrom
feat/STACKITCLI-441-refactor-mongodbflex
Open

GokceGK wants to merge 3 commits into
mainfrom
feat/STACKITCLI-441-refactor-mongodbflex

Conversation

@GokceGK

@GokceGK GokceGK commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Description

relates to STACKITCLI-441

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)

@GokceGK
GokceGK requested a review from a team as a code owner September 7, 2026 07:52
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

Merging this branch changes the coverage (3 decrease, 4 increase)

Impacted Packages Coverage Δ 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/flavor 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/flavor/list 66.67% (+66.67%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/instance/create 46.67% (-13.33%) 💀
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/instance/describe 60.78% (+5.56%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/instance/update 62.40% (-1.94%) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/options 61.05% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/storage 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/storage/list 57.14% (+57.14%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/version 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/version/list 41.94% (+41.94%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/options 57.95% (ø)
github.com/stackitcloud/stackit-cli/internal/pkg/services/mongodbflex/utils 79.25% (-4.54%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/flavor/flavor.go 0.00% (ø) 4 (+4) 0 4 (+4)
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/flavor/list/list.go 66.67% (+66.67%) 36 (+36) 24 (+24) 12 (+12) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/instance/create/create.go 46.67% (-13.33%) 120 (+20) 56 (-4) 64 (+24) 💀
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/instance/describe/describe.go 60.78% (+5.56%) 51 (-16) 31 (-6) 20 (-10) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/instance/update/update.go 62.40% (-1.94%) 125 (-4) 78 (-5) 47 (+1) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/mongodbflex.go 0.00% (ø) 10 (+3) 0 10 (+3)
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/options/options.go 61.05% (ø) 95 58 37
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/storage/list/list.go 57.14% (+57.14%) 42 (+42) 24 (+24) 18 (+18) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/storage/storage.go 0.00% (ø) 4 (+4) 0 4 (+4)
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/version/list/list.go 41.94% (+41.94%) 31 (+31) 13 (+13) 18 (+18) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/version/version.go 0.00% (ø) 4 (+4) 0 4 (+4)
github.com/stackitcloud/stackit-cli/internal/cmd/postgresflex/options/options.go 57.95% (ø) 88 51 37
github.com/stackitcloud/stackit-cli/internal/pkg/services/mongodbflex/utils/utils.go 79.25% (-4.54%) 53 (-21) 42 (-20) 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/mongodbflex/flavor/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/instance/create/create_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/instance/update/update_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/storage/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/version/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/services/mongodbflex/utils/utils_test.go

ACL: []string{"0.0.0.0/0"},
BackupSchedule: "0 0/6 * * *",
FlavorId: testFlavorId,
BackupSchedule: utils.Ptr("0 0/6 * * *"),

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.

new () can be used instead of utils.Ptr()
(can be replaced everywhere)

listFlavorsResp: &mongodbflex.ListFlavorsResponse{
Flavors: []mongodbflex.InstanceFlavor{
{
Id: utils.Ptr(testFlavorId),

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.

e.g. here as well

return req, fmt.Errorf("get MongoDB Flex instance: %w", err)
var currentFlavor *mongodbflex.InstanceFlavor
for _, f := range flavors.Flavors {
if f.Id == currentInstance.Item.Flavor.Id {

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.

pointer comparison

}
model.FlavorId, err = getFlavorId(ctx, model, apiClient.DefaultAPI)
if err != nil {
return err

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 return should be kept, right?
If flavorId was not set and the flavorId cannot be obtained via cpu and ram then we cannot proceed here

if err != nil {
return fmt.Errorf("get MongoDB Flex flavors: %w", err)
}

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.

truncate for limit missing

if err != nil {
return fmt.Errorf("get MongoDB Flex storages: %w", err)
}

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.

truncate for limit missing

`List MongoDB Flex storage options for a given flavor. The flavor ID can be retrieved by running "$ stackit mongodbflex options --flavors"`,
"$ stackit mongodbflex options --storages --flavor-id <FLAVOR_ID>"),
),
Deprecated: `Command "stackit mongodbflex options" command is deprecated and will be removed after 2027-03-07. Please use "stackit mongodbflex version list", "stackit mongodbflex flavor list" and "stackit mongodbflex storage list" commands instead.`,

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.

Suggested change
Deprecated: `Command "stackit mongodbflex options" command is deprecated and will be removed after 2027-03-07. Please use "stackit mongodbflex version list", "stackit mongodbflex flavor list" and "stackit mongodbflex storage list" commands instead.`,
Deprecated: `Command "stackit mongodbflex options" is deprecated and will be removed after 2027-03-07. Please use "stackit mongodbflex version list", "stackit mongodbflex flavor list" and "stackit mongodbflex storage list" commands instead.`,


table := tables.NewTable()
table.SetTitle("Versions")
table.SetHeader("VERSION")

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.

nitpick: found during testing the table only has "VERSION".

So it looks like the following:
Versions
VERSION
8.0
7.0

Just an idea: We could remove the duplicate information?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants