Skip to content

Commit

Permalink
Fix node pool default tag lookup in kubernetes read (#528)
Browse files Browse the repository at this point in the history
Co-authored-by: tbabs <tbabs@ayagroup.pro>
  • Loading branch information
timurbabs and tbabs authored Nov 22, 2024
1 parent da906ce commit 7e22cb3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions vultr/resource_vultr_kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,21 @@ func resourceVultrKubernetesRead(ctx context.Context, d *schema.ResourceData, me
}

// Look for the node pool with the tag `tf-vke-default`
found := false
for i := range vke.NodePools {
if tfVKEDefault == vke.NodePools[i].Tag {
if err := d.Set("node_pools", flattenNodePool(&vke.NodePools[i])); err != nil {
return diag.Errorf("unable to set resource kubernetes `node_pools` read value: %v", err)
}
found = true
break
} else {
// no node pool with the default tag was found. mostly only relevant to importing
return diag.Errorf(`unable to set resource kubernetes default node pool with tag %s for %v.
You must set the default tag on one node pool before importing.`,
tfVKEDefault, d.Id())
}
}
if !found {
return diag.Errorf(`unable to set resource kubernetes default node pool with tag %s for %v.
You must set the default tag on one node pool before importing.`,
tfVKEDefault, d.Id())
}

if err := d.Set("region", vke.Region); err != nil {
return diag.Errorf("unable to set resource kubernetes `region` read value: %v", err)
Expand Down

0 comments on commit 7e22cb3

Please sign in to comment.