Skip to content

Conversation

@GokceGK
Copy link
Contributor

@GokceGK GokceGK commented Dec 16, 2025

Description

Related to STACKITCLI-292

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 December 16, 2025 15:53
@GokceGK GokceGK marked this pull request as draft December 16, 2025 15:54
@github-actions
Copy link

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

Impacted Packages Coverage Δ 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/beta 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/create 42.37% (+42.37%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/delete 22.45% (+22.45%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/describe 63.89% (+63.89%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/list 36.54% (+36.54%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/update 41.82% (+41.82%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/config/set 90.08% (+0.23%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/config/unset 35.34% (-0.05%) 👎
github.com/stackitcloud/stackit-cli/internal/pkg/config 71.48% (+0.11%) 👍
github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/client 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/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/beta.go 0.00% (ø) 8 (+1) 0 8 (+1)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/create/create.go 42.37% (+42.37%) 59 (+59) 25 (+25) 34 (+34) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/delete/delete.go 22.45% (+22.45%) 49 (+49) 11 (+11) 38 (+38) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/describe/describe.go 63.89% (+63.89%) 36 (+36) 23 (+23) 13 (+13) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/instance.go 0.00% (ø) 8 (+8) 0 8 (+8)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/list/list.go 36.54% (+36.54%) 52 (+52) 19 (+19) 33 (+33) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/update/update.go 41.82% (+41.82%) 55 (+55) 23 (+23) 32 (+32) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/logs.go 0.00% (ø) 4 (+4) 0 4 (+4)
github.com/stackitcloud/stackit-cli/internal/cmd/config/set/set.go 90.08% (+0.23%) 131 (+3) 118 (+3) 13 👍
github.com/stackitcloud/stackit-cli/internal/cmd/config/unset/unset.go 35.34% (-0.05%) 116 (+3) 41 (+1) 75 (+2) 👎
github.com/stackitcloud/stackit-cli/internal/pkg/config/config.go 90.48% (+0.15%) 63 (+1) 57 (+1) 6 👍
github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/client/client.go 0.00% (ø) 1 (+1) 0 1 (+1)
github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/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/logs/instance/create/create_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/delete/delete_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/describe/describe_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/logs/instance/update/update_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/config/unset/unset_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/utils/utils_test.go

if model.Async {
operationState = "Triggered deletion of"
}
params.Printer.Info("%s instance %q\n", operationState, instanceLabel)
Copy link
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\n", operationState, instanceLabel)
params.Printer.Outputf("%s instance %q\n", operationState, instanceLabel)

printer.Info goes to stderr, printer.Outputf goes to stdout 😉

{
name: "empty instance in instances slice",
args: args{
instances: []logs.LogsInstance{},
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
instances: []logs.LogsInstance{},
instances: []logs.LogsInstance{{}},

you have to add an empty instance, currently this is just an empty slice 😄


table := tables.NewTable()
table.SetHeader("NAME", "ID", "STATUS")
for i := range instances {
Copy link
Member

@rubenhoenle rubenhoenle Dec 17, 2025

Choose a reason for hiding this comment

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

Suggested change
for i := range instances {
for _, instance := range instances {

Saves yourself the next line (instance := instances[i])...

instance := instances[i]

instanceStatus := ""
if instance.Status != nil {
Copy link
Member

Choose a reason for hiding this comment

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

No need to do this check here, the utils.PtrString func handles that case for you

// PtrString creates a string representation of a passed object pointer or returns
// an empty string, if the passed object is _nil_.
func PtrString[T any](t *T) string {
if t != nil {
return fmt.Sprintf("%v", *t)
}
return ""
}

return req
}

func outputResult(p *print.Printer, model *inputModel, projectLabel string, instance *logs.LogsInstance) error {
Copy link
Member

Choose a reason for hiding this comment

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

No unit tests for that one? 😞

if err != nil {
return "", fmt.Errorf("get Logs instance: %w", err)
}
return *resp.DisplayName, nil
Copy link
Member

Choose a reason for hiding this comment

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

Potential nil pointer dereference

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.

3 participants