Feat/region adjustment rabbitmq#1449
Conversation
d1de6d1 to
f50c220
Compare
5470441 to
10231b7
Compare
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
|
| MetricsFrequency: flags.FlagToInt32Pointer(p, cmd, metricsFrequencyFlag), | ||
| MetricsPrefix: flags.FlagToStringPointer(p, cmd, metricsPrefixFlag), | ||
| Plugin: flags.FlagToStringSlicePointer(p, cmd, pluginFlag), | ||
| Plugin: flags.FlagToInstanceParametersPluginsInnerSliceValue(p, cmd, pluginFlag), |
There was a problem hiding this comment.
We have some new helpers for enum flags. See for example here, how it can be used:
stackit-cli/internal/cmd/beta/cdn/distribution/create/create.go
Lines 44 to 48 in 0a9b757
Take care that it's part of an open PR and the usage might be a bit different #1441
| Syslog: model.Syslog, | ||
| }, | ||
| PlanId: planId, | ||
| PlanId: *planId, |
There was a problem hiding this comment.
I would change here the type from to a string and get rid of the pointer dereference, which could potentially result in a nil pointer exception
|
|
||
| req = req.CreateInstancePayload(rabbitmq.CreateInstancePayload{ | ||
| InstanceName: model.InstanceName, | ||
| InstanceName: *model.InstanceName, |
There was a problem hiding this comment.
same here, I would change the type behind model.InstanceName to string. Generally I would always use pointer only for optional flags and the value type for required fields. At the moment this isn't consistent for all commands
| metricsFrequency := flags.FlagToInt32Pointer(p, cmd, metricsFrequencyFlag) | ||
| metricsPrefix := flags.FlagToStringPointer(p, cmd, metricsPrefixFlag) | ||
| plugin := flags.FlagToStringSlicePointer(p, cmd, pluginFlag) | ||
| plugin := flags.FlagToInstanceParametersPluginsInnerSliceValue(p, cmd, pluginFlag) |
There was a problem hiding this comment.
same like in the create command with the generic enum flag
| // Returns the flag's value as a []rabbitmq.InstanceParametersPluginsInner. | ||
| // Returns nil if the flag is not set, if its value can not be converted to []rabbitmq.InstanceParametersPluginsInner, or if the flag does not exist. | ||
| func FlagToInstanceParametersPluginsInnerSliceValue(p *print.Printer, cmd *cobra.Command, flag string) []rabbitmq.InstanceParametersPluginsInner { | ||
| stringSlice, err := cmd.Flags().GetStringSlice(flag) | ||
| if err != nil { | ||
| p.Debug(print.ErrorLevel, "convert flag to string slice value: %v", err) | ||
| return nil | ||
| } | ||
| value := make([]rabbitmq.InstanceParametersPluginsInner, len(stringSlice)) | ||
| for i, v := range stringSlice { | ||
| value[i] = rabbitmq.InstanceParametersPluginsInner(v) | ||
| } | ||
| if cmd.Flag(flag).Changed { | ||
| return value | ||
| } | ||
| return nil | ||
| } | ||
|
|
There was a problem hiding this comment.
shouldn't be need when using instead the generic enum flag
Description
Migrates to rabbitmq api v2 and implements appropriate region adjustments
relates to STACKITCLI-407 and STACKITCLI-375
Checklist
make fmtmake generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)