-
Notifications
You must be signed in to change notification settings - Fork 33
feat(iaas): List NICs for Project #1242
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
relates to STACKITCLI-307 and #1214
Fixed tests and linter relates to STACKITCLI-307 and #1214
relates to STACKITCLI-307 and #1214 tests added network ids included in list of project NICs
Merging this branch will increase overall coverage
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 err != nil { | ||
| return fmt.Errorf("list network interfaces: %w", err) | ||
| } | ||
| if model.NetworkId == "" { |
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.
Since model.NetworkId is optional now, it should be defined as type *string instead of string in the inputModel struct type. nil will mean the flag wasn't set, non-nil will mean the flag was set by the user.
| } | ||
|
|
||
| // Truncate output | ||
| items := *resp.Items |
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, take care of it please
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.
| Args: args.NoArgs, | ||
| Example: examples.Build( | ||
| examples.NewExample( | ||
| `Lists all network interfaces in your current project`, |
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.
| `Lists all network interfaces in your current project`, | |
| `Lists all network interfaces`, |
That's the default to list the stuff of your current project, you can leave that out
| } | ||
|
|
||
| sort.SliceStable(nics, func(i, j int) bool { | ||
| result := bytes.Compare([]byte(*nics[i].NetworkId), []byte(*nics[j].NetworkId)) |
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.
Why all the overkill with byte conversions?
slices.SortFunc(nics, func(a, b iaas.NIC) int {
return cmp.Compare(*a.NetworkId, *b.NetworkId)
})| Long: "Lists all network interfaces of a network.", | ||
| Args: args.NoArgs, | ||
| Example: examples.Build( | ||
| examples.NewExample( |
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.
Maybe leave some general note at the top of this file that this subcommand implementation is cursed because it uses two different API endpoints in the background. So it's documented properly for the future.
Please also note it down in the list for our next sync with IaaS that we report this weird API design so they consider changing it on the next API version bump.
Description
relates to STACKITCLI-307 and #1214
Checklist
make fmtmake generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)