From 0853f059558f93a44517fd7ef9f6b7e78a495c56 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com> Date: Tue, 5 Nov 2024 10:56:40 +0000 Subject: [PATCH] Instance: Fix instance protection flag update zone context Signed-off-by: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com> --- cmd/instance_update.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/instance_update.go b/cmd/instance_update.go index 6ba8a6f7..35a8e875 100644 --- a/cmd/instance_update.go +++ b/cmd/instance_update.go @@ -102,6 +102,9 @@ func (c *instanceUpdateCmd) cmdRun(cmd *cobra.Command, _ []string) error { } if cmd.Flags().Changed(mustCLICommandFlagName(c, &c.Protection)) { + var client *egoscale3.Client + client, err = switchClientZoneV3(ctx, globalstate.EgoscaleV3Client, egoscale3.ZoneName(c.Zone)) + var value egoscale3.UUID var op *egoscale3.Operation value, err = egoscale3.ParseUUID(*instance.ID) @@ -109,16 +112,15 @@ func (c *instanceUpdateCmd) cmdRun(cmd *cobra.Command, _ []string) error { return } if c.Protection { - op, err = globalstate.EgoscaleV3Client.AddInstanceProtection(ctx, value) + op, err = client.AddInstanceProtection(ctx, value) } else { - op, err = globalstate.EgoscaleV3Client.RemoveInstanceProtection(ctx, value) + op, err = client.RemoveInstanceProtection(ctx, value) } if err != nil { return } - _, err = globalstate.EgoscaleV3Client.Wait(ctx, op, egoscale3.OperationStateSuccess) + _, err = client.Wait(ctx, op, egoscale3.OperationStateSuccess) } - }) if err != nil {