Skip to content

Commit 58d85de

Browse files
committed
review fixes
1 parent 7a99d39 commit 58d85de

1 file changed

Lines changed: 5 additions & 16 deletions

File tree

‎internal/cmd/volume/create/create.go‎

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package create
33
import (
44
"context"
55
"fmt"
6-
"reflect"
76

87
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
98

@@ -188,21 +187,11 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
188187
EncryptionServiceAccount: flags.FlagToStringPointer(p, cmd, encryptionServiceAccountFlag),
189188
}
190189

191-
// encryptionKeyPayloadFlag only valid with other encryption flags set
192-
if cmd.Flags().Changed(encryptionKeyPayloadFlag) {
193-
flagToValue := map[string]any{
194-
encryptionKekKeyIdFlag: model.EncryptionKekKeyId,
195-
encryptionKekKeyringIdFlag: model.EncryptionKekKeyringId,
196-
encryptionKekKeyVersionFlag: model.EncryptionKekKeyVersion,
197-
encryptionServiceAccountFlag: model.EncryptionServiceAccount,
198-
}
199-
for key, value := range flagToValue {
200-
if reflect.ValueOf(value).IsNil() {
201-
return nil, &cliErr.FlagValidationError{
202-
Flag: key,
203-
Details: fmt.Sprintf("when using flag %q, flag %q is required", encryptionKeyPayloadFlag, key),
204-
}
205-
}
190+
// Cobra requires the encryption parameters together, so checking one is sufficient.
191+
if cmd.Flags().Changed(encryptionKeyPayloadFlag) && model.EncryptionKekKeyId == nil {
192+
return nil, &cliErr.FlagValidationError{
193+
Flag: encryptionKekKeyIdFlag,
194+
Details: fmt.Sprintf("when using flag %q, flag %q is required", encryptionKeyPayloadFlag, encryptionKekKeyIdFlag),
206195
}
207196
}
208197

0 commit comments

Comments
 (0)