Skip to content

chore(edge): refactoring and migration to new SDK structure - #1503

Open
GokceGK wants to merge 3 commits into
mainfrom
feat/STACKITCLI-357-edgecloud-sdk-migration
Open

chore(edge): refactoring and migration to new SDK structure#1503
GokceGK wants to merge 3 commits into
mainfrom
feat/STACKITCLI-357-edgecloud-sdk-migration

Conversation

@GokceGK

@GokceGK GokceGK commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Description

relates to STACKITCLI-357

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 July 27, 2026 13:04
@github-actions

Copy link
Copy Markdown

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

Impacted Packages Coverage Δ 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/create 49.15% (-2.85%) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/delete 24.44% (-29.21%) 💀 💀
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/describe 67.39% (-12.89%) 💀
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/list 57.45% (-9.22%) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/update 40.32% (-18.44%) 💀
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/kubeconfig 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/kubeconfig/create 56.25% (-19.72%) 💀
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/plans 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/plans/list 56.52% (-10.14%) 💀
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/token 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/token/create 45.31% (-27.10%) 💀 💀
github.com/stackitcloud/stackit-cli/internal/cmd/git/instance/delete 17.78% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/instance/create 60.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/ske/kubeconfig/create 31.71% (ø)
github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/client 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/common/error 0.00% (-100.00%) 💀 💀 💀 💀 💀
github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/common/instance 0.00% (-100.00%) 💀 💀 💀 💀 💀
github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/common/kubeconfig 82.42% (ø)
github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/common/validation 0.00% (-100.00%) 💀 💀 💀 💀 💀
github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/utils 100.00% (+100.00%) 🌟

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/edge.go 0.00% (ø) 7 0 7
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/create/create.go 49.15% (-2.85%) 59 (-16) 29 (-10) 30 (-6) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/delete/delete.go 24.44% (-29.21%) 45 (-37) 11 (-33) 34 (-4) 💀 💀
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/describe/describe.go 67.39% (-12.89%) 46 (-25) 31 (-26) 15 (+1) 💀
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/instance.go 0.00% (ø) 8 0 8
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/list/list.go 57.45% (-9.22%) 47 (-10) 27 (-11) 20 (+1) 👎
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/update/update.go 40.32% (-18.44%) 62 (-35) 25 (-32) 37 (-3) 💀
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/kubeconfig/create/create.go 56.25% (-19.72%) 112 (-17) 63 (-35) 49 (+18) 💀
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/kubeconfig/kubeconfig.go 0.00% (ø) 4 0 4
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/plans/list/list.go 56.52% (-10.14%) 46 (-11) 26 (-12) 20 (+1) 💀
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/plans/plans.go 0.00% (ø) 4 0 4
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/token/create/create.go 45.31% (-27.10%) 64 (-23) 29 (-34) 35 (+11) 💀 💀
github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/token/token.go 0.00% (ø) 4 0 4
github.com/stackitcloud/stackit-cli/internal/cmd/git/instance/delete/delete.go 17.78% (ø) 45 8 37
github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/instance/create/create.go 60.00% (ø) 100 60 40
github.com/stackitcloud/stackit-cli/internal/cmd/ske/kubeconfig/create/create.go 31.71% (ø) 123 39 84
github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/client/client.go 0.00% (ø) 1 0 1
github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/common/error/error.go 0.00% (-100.00%) 0 (-16) 0 (-16) 0 💀 💀 💀 💀 💀
github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/common/instance/instance.go 0.00% (-100.00%) 0 (-28) 0 (-28) 0 💀 💀 💀 💀 💀
github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/common/kubeconfig/kubeconfig.go 82.42% (ø) 91 75 16
github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/common/validation/input.go 0.00% (-100.00%) 0 (-10) 0 (-10) 0 💀 💀 💀 💀 💀
github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/utils/utils.go 100.00% (+100.00%) 4 (+4) 4 (+4) 0 🌟

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/beta/edge/instance/create/create_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/delete/delete_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/describe/describe_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/update/update_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/kubeconfig/create/create_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/plans/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/token/create/create_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/common/error/error_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/common/instance/instance_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/common/kubeconfig/kubeconfig_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/common/validation/input_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/services/edge/utils/utils_test.go

@rubenhoenle rubenhoenle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a first glance, this thing is big. Will have to take a second look but I have to quit work for today.

// Build request payload
payload := edge.CreateInstancePayload{
DisplayName: &model.DisplayName,
DisplayName: *model.DisplayName,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Both the display name as the plan id are required flags. Why are they pointers in your inputModel struct then? I see only a risk for nil pointers here without any benefit 😅

// Output result based on the configured output format
func outputResult(p *print.Printer, outputFormat string, async bool, projectLabel string, instance *edge.Instance) error {
func outputResult(p *print.Printer, model *inputModel, projectLabel string, instance *edge.Instance) error {
if instance == nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Move this nil check into the callback of p.OutputResult. The JSON/YAML output can handle nil values just fine.

@@ -34,86 +27,17 @@ var (
testPlanId = uuid.NewString()
testDescription = "Initial instance description"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could be const

if model.Async {
operationState = "Triggered deletion of"
}
params.Printer.Info("%s instance %q of project %q.\n", operationState, instanceLabel, projectLabel)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
params.Printer.Info("%s instance %q of project %q.\n", operationState, instanceLabel, projectLabel)
params.Printer.Outputf("%s instance %q of project %q.\n", operationState, instanceLabel, projectLabel)

I hope this is the last time I will have to comment this. Stderr vs. stdout. 😉

// This is only to prevent nil pointer deref.
// As long as the API behaves as defined by it's spec, instance can not be empty (HTTP 200 with an empty body)
return commonErr.NewNoInstanceError("")
return fmt.Errorf("instance response is empty")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here, move this nil check into the callback func please

return string(kubeconfigYAML), nil
default:
return "", fmt.Errorf("%w: %s", commonErr.NewNoIdentifierError(""), format)
return "", fmt.Errorf("format is not JSON or YAML: %s", format)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can't we use p.OutputResult here?

cmd := &cobra.Command{
Use: "create",
Short: "Creates a token for an edge instance",
Use: fmt.Sprintf("create token for %s", instanceIdArg),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Use: fmt.Sprintf("create token for %s", instanceIdArg),
Use: fmt.Sprintf("create"),

Same here. Furthermore we don't use arguments on create commands. The instance id would be a flag.

"An expiration time can be set for the token. The expiration time is set in seconds(s), minutes(m), hours(h), days(d) or months(M). Default is 3600(1h) seconds.",
"Note: the format for the duration is <value><unit>, e.g. 30d for 30 days. You may not combine units."),
Args: args.NoArgs,
Args: args.SingleArg(instanceIdArg, nil),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  1. We don't do that by convention. Instance ID would have to be a flag.
  2. This is a breaking change.

// Output result based on the configured output format
func outputResult(p *print.Printer, outputFormat string, token *edge.Token) error {
if token == nil || token.Token == nil {
if token == nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same as above, move this nil check into the callback for the pretty output

tokenString := token.Token

return p.OutputResult(outputFormat, token, func() error {
p.Outputln(tokenString)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
p.Outputln(tokenString)
p.Outputln(token.Token)

Why a variable for everything?

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