From 292f6c40d33c8028184756318fe276b5b46c37c5 Mon Sep 17 00:00:00 2001 From: pauhull Date: Tue, 7 Nov 2023 12:58:49 +0100 Subject: [PATCH] fix(primary-ip): updating the name resets auto-delete (#604) 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. --- internal/cmd/primaryip/update.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/cmd/primaryip/update.go b/internal/cmd/primaryip/update.go index 190a6c39..d9ed6935 100644 --- a/internal/cmd/primaryip/update.go +++ b/internal/cmd/primaryip/update.go @@ -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