Skip to content

Commit c58e759

Browse files
committed
allow enabling protection during create
1 parent cefc417 commit c58e759

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

internal/cmd/storagebox/create.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ var CreateCmd = base.CreateCmd[*hcloud.StorageBox]{
5959
password, _ := cmd.Flags().GetString("password")
6060
sshKeys, _ := cmd.Flags().GetStringArray("ssh-key")
6161
labels, _ := cmd.Flags().GetStringToString("label")
62+
protection, _ := cmd.Flags().GetStringSlice("enable-protection")
63+
64+
protectionOpts, err := getChangeProtectionOpts(true, protection)
65+
if err != nil {
66+
return nil, nil, err
67+
}
6268

6369
enableSamba, _ := cmd.Flags().GetBool("enable-samba")
6470
enableSSH, _ := cmd.Flags().GetBool("enable-ssh")
@@ -99,7 +105,12 @@ var CreateCmd = base.CreateCmd[*hcloud.StorageBox]{
99105
return nil, nil, fmt.Errorf("Storage Box not found: %d", result.StorageBox.ID)
100106
}
101107

102-
// TODO change protection here once change-protection is implemented
108+
if len(protection) > 0 {
109+
// TODO this check can be removed once delete protection is made nullable
110+
if err := changeProtection(s, cmd, storageBox, true, protectionOpts); err != nil {
111+
return nil, nil, err
112+
}
113+
}
103114

104115
return storageBox, util.Wrap("storage_box", hcloud.SchemaFromStorageBox(result.StorageBox)), nil
105116
},

0 commit comments

Comments
 (0)