-
Notifications
You must be signed in to change notification settings - Fork 30
Onboard Logs service -instance commands #1184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Merging this branch changes the coverage (1 decrease, 8 increase)
Coverage by fileChanged files (no unit tests)
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
|
| if model.Async { | ||
| operationState = "Triggered deletion of" | ||
| } | ||
| params.Printer.Info("%s instance %q\n", operationState, instanceLabel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for i := range instances { | |
| for _, instance := range instances { |
Saves yourself the next line (instance := instances[i])...
| instance := instances[i] | ||
|
|
||
| instanceStatus := "" | ||
| if instance.Status != nil { |
There was a problem hiding this comment.
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
stackit-cli/internal/pkg/utils/utils.go
Lines 24 to 31 in 9660efb
| // 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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential nil pointer dereference
Description
Related to STACKITCLI-292
Checklist
make fmtmake generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)