Skip to content

Commit

Permalink
Instance: Fix instance protection flag update zone context
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Emmanuel Jacquier <[email protected]>
  • Loading branch information
pierre-emmanuelJ committed Nov 5, 2024
1 parent 550b40f commit 0853f05
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/instance_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,25 @@ 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)
if err != nil {
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 {
Expand Down

0 comments on commit 0853f05

Please sign in to comment.