Skip to content

Commit

Permalink
removed Update context for reservedIPv6
Browse files Browse the repository at this point in the history
  • Loading branch information
imaskm committed Dec 11, 2024
1 parent 646e5e8 commit 1a7fcdc
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions digitalocean/reservedipv6/resource_reserved_ipv6.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
func ResourceDigitalOceanReservedIPV6() *schema.Resource {
return &schema.Resource{
CreateContext: resourceDigitalOceanReservedIPV6Create,
UpdateContext: resourceDigitalOceanReservedIPV6Update,
ReadContext: resourceDigitalOceanReservedIPV6Read,
DeleteContext: resourceDigitalOceanReservedIPV6Delete,
Importer: &schema.ResourceImporter{
Expand Down Expand Up @@ -73,42 +72,6 @@ func resourceDigitalOceanReservedIPV6Create(ctx context.Context, d *schema.Resou
return resourceDigitalOceanReservedIPV6Read(ctx, d, meta)
}

func resourceDigitalOceanReservedIPV6Update(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(*config.CombinedConfig).GodoClient()

if d.HasChange("droplet_id") {
if v, ok := d.GetOk("droplet_id"); ok {
log.Printf("[INFO] Assigning the reserved IPv6 %s to the Droplet %d", d.Id(), v.(int))
action, _, err := client.ReservedIPV6Actions.Assign(context.Background(), d.Id(), v.(int))
if err != nil {
return diag.Errorf(
"Error assigning reserved IPv6 (%s) to the Droplet: %s", d.Id(), err)
}

_, unassignedErr := waitForReservedIPV6Ready(ctx, d, "completed", []string{"new", "in-progress"}, "status", meta, action.ID)
if unassignedErr != nil {
return diag.Errorf(
"Error waiting for reserved IP (%s) to be Assigned: %s", d.Id(), unassignedErr)
}
} else {
log.Printf("[INFO] Unassigning the reserved IP %s", d.Id())
action, _, err := client.ReservedIPV6Actions.Unassign(context.Background(), d.Id())
if err != nil {
return diag.Errorf(
"Error unassigning reserved IP (%s): %s", d.Id(), err)
}

_, unassignedErr := waitForReservedIPV6Ready(ctx, d, "completed", []string{"new", "in-progress"}, "status", meta, action.ID)
if unassignedErr != nil {
return diag.Errorf(
"Error waiting for reserved IP (%s) to be Unassigned: %s", d.Id(), unassignedErr)
}
}
}

return resourceDigitalOceanReservedIPV6Read(ctx, d, meta)
}

func resourceDigitalOceanReservedIPV6Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(*config.CombinedConfig).GodoClient()

Expand Down

0 comments on commit 1a7fcdc

Please sign in to comment.