Skip to content

feat(opensearch): region adjustments and migration to new SDK structure#1474

Open
SerseusWasTaken wants to merge 1 commit into
mainfrom
feat/opensearch-sdk-migration
Open

feat(opensearch): region adjustments and migration to new SDK structure#1474
SerseusWasTaken wants to merge 1 commit into
mainfrom
feat/opensearch-sdk-migration

Conversation

@SerseusWasTaken

Copy link
Copy Markdown
Contributor

Description

Migrate opensearch to v2 SDK API

relates to STACKITCLI-372

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)

@SerseusWasTaken SerseusWasTaken requested a review from a team as a code owner July 13, 2026 13:26
@github-actions

Copy link
Copy Markdown

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/credentials/create 56.86% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/credentials/delete 37.50% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/credentials/describe 70.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/credentials/list 60.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/create 61.80% (+0.69%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/delete 26.83% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/describe 59.57% (+7.49%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/list 40.43% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/update 59.38% (+0.43%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/plans 55.77% (ø)
github.com/stackitcloud/stackit-cli/internal/pkg/services/opensearch/client 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/pkg/services/opensearch/utils 26.67% (+1.67%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/credentials/create/create.go 56.86% (ø) 51 29 22
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/credentials/delete/delete.go 37.50% (ø) 40 15 25
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/credentials/describe/describe.go 70.00% (ø) 50 35 15
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/credentials/list/list.go 60.00% (ø) 50 30 20
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/create/create.go 61.80% (+0.69%) 89 (-1) 55 34 (-1) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/delete/delete.go 26.83% (ø) 41 11 30
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/describe/describe.go 59.57% (+7.49%) 47 (-1) 28 (+3) 19 (-4) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/list/list.go 40.43% (ø) 47 19 28
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/update/update.go 59.38% (+0.43%) 96 (+1) 57 (+1) 39 👍
github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/plans/plans.go 55.77% (ø) 52 29 23
github.com/stackitcloud/stackit-cli/internal/pkg/services/opensearch/client/client.go 0.00% (ø) 1 0 1
github.com/stackitcloud/stackit-cli/internal/pkg/services/opensearch/utils/utils.go 26.67% (+1.67%) 30 (-2) 8 22 (-2) 👍

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/opensearch/credentials/create/create_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/credentials/delete/delete_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/credentials/describe/describe_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/credentials/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/create/create_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/delete/delete_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/describe/describe_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/instance/update/update_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/opensearch/plans/plans_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/services/opensearch/utils/utils_test.go

func GetCredentialsUsername(ctx context.Context, apiClient OpenSearchClient, projectId, instanceId, credentialsId string) (string, error) {
resp, err := apiClient.GetCredentialsExecute(ctx, projectId, instanceId, credentialsId)
func GetCredentialsUsername(ctx context.Context, apiClient OpenSearchClient, projectId, region, instanceId, credentialsId string) (string, error) {
resp, err := apiClient.GetCredentials(ctx, projectId, instanceId, region, credentialsId).Execute()

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.

region must be added before instanceId

}
}

type OpenSearchClient interface {

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.

I think we can remove this client and use the apiClient directly. Like we have done for other services

https://github.com/stackitcloud/stackit-cli/pull/1449/changes#diff-fbfa081e40e62c1d42769762ff3cbb0db379d43baed6ec03fcbe53a4b7f628b7L32


var (
testProjectId = uuid.NewString()
testRegion = "eu01"

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.

can you shift this to const area?

return req
}

func outputResult(p *print.Printer, outputFormat string, showPassword bool, instanceLabel string, resp *opensearch.CredentialsResponse) error {

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: not introduced by this PR so you can just skip it :) but I think instead of outputFormat and showPassword, we can parse here the model and then read the values in the function.

@GokceGK GokceGK changed the title opensearch sdk migration feat(opensearch): region adjustments and migration to new SDK structure Jul 14, 2026
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.

2 participants