Skip to content

Commit

Permalink
fix(primary-ip): updating the name resets auto-delete
Browse files Browse the repository at this point in the history
Due to not correctly checking if the auto-delete flag was set, every time the update command was called and the auto-delete flag wasn't set, auto deletion was erroneously disabled.
  • Loading branch information
phm07 committed Nov 7, 2023
1 parent ee8e6ed commit 864a220
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/cmd/primaryip/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ var updateCmd = base.UpdateCmd{
updOpts := hcloud.PrimaryIPUpdateOpts{
Name: flags["name"].String(),
}
autoDelete, _ := cmd.Flags().GetBool("auto-delete")
if primaryIP.AutoDelete != autoDelete {
updOpts.AutoDelete = hcloud.Bool(autoDelete)

if cmd.Flags().Changed("auto-delete") {
autoDelete, _ := cmd.Flags().GetBool("auto-delete")
updOpts.AutoDelete = hcloud.Ptr(autoDelete)
}

_, _, err := client.PrimaryIP().Update(ctx, primaryIP, updOpts)
if err != nil {
return err
Expand Down

0 comments on commit 864a220

Please sign in to comment.