Changed size on default node pool to ForceNew
This commit is contained in:
parent
40fc725564
commit
042e60ff6b
|
@ -1,3 +1,4 @@
|
|||
.envrc
|
||||
*.dll
|
||||
*.exe
|
||||
.DS_Store
|
||||
|
|
|
@ -31,9 +31,6 @@ func resourceDigitalOceanKubernetesNodePool() *schema.Resource {
|
|||
func nodePoolResourceSchema() map[string]*schema.Schema {
|
||||
s := nodePoolSchema()
|
||||
|
||||
// for a node pool resource name is not computed
|
||||
s["name"].Computed = false
|
||||
|
||||
// add the cluster id
|
||||
s["cluster_id"] = &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -42,6 +39,8 @@ func nodePoolResourceSchema() map[string]*schema.Schema {
|
|||
ForceNew: true,
|
||||
}
|
||||
|
||||
// remove the id when this is used in a specific resource
|
||||
// not as a child
|
||||
delete(s, "id")
|
||||
|
||||
return s
|
||||
|
@ -62,6 +61,7 @@ func nodePoolSchema() map[string]*schema.Schema {
|
|||
"size": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
ValidateFunc: validation.NoZeroValues,
|
||||
},
|
||||
|
||||
|
|
|
@ -254,29 +254,10 @@ func resourceDigitalOceanKubernetesClusterUpdate(d *schema.ResourceData, meta in
|
|||
}
|
||||
|
||||
old, new := d.GetChange("node_pool")
|
||||
//pretty.Println(old)
|
||||
//pretty.Println(new)
|
||||
|
||||
// has the size changed if so we need to create a new pool and then destroy the old one
|
||||
oldPool := old.([]interface{})[0].(map[string]interface{})
|
||||
newPool := new.([]interface{})[0].(map[string]interface{})
|
||||
|
||||
if oldPool["size"] != newPool["size"] {
|
||||
// create a new pool
|
||||
_, err := digitaloceanKubernetesNodePoolCreate(client, newPool, d.Id(), digitaloceanKubernetesDefaultNodePoolTag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = digitaloceanKubernetesNodePoolDelete(client, d.Id(), oldPool["id"].(string))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return resourceDigitalOceanKubernetesClusterRead(d, meta)
|
||||
}
|
||||
|
||||
// only update the existing default pool
|
||||
// update the existing default pool
|
||||
_, err := digitaloceanKubernetesNodePoolUpdate(client, newPool, d.Id(), oldPool["id"].(string), digitaloceanKubernetesDefaultNodePoolTag)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue