Skip to content

Commit

Permalink
Set default of rocket_storage to 0 (#422)
Browse files Browse the repository at this point in the history
* set default of rocket_storage to 0

rocket_storage=0 means rocket_storage is disabled. This prevents inconsistency between the backend and terraform state.

* Set rocket storage = 0 in create/update payload when it's not specified
  • Loading branch information
nvthongswansea authored Jan 24, 2025
1 parent aa44bb8 commit f8f3e22
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions gridscale/resource_gridscale_k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func (rgk8sm *ResourceGridscaleK8sModeler) buildInputSchema() map[string]*schema
"rocket_storage": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
Description: "Rocket storage per worker node (in GiB).",
},
}
Expand Down Expand Up @@ -928,11 +929,8 @@ func resourceGridscaleK8sCreate(d *schema.ResourceData, meta interface{}) error
nodePool["cores"] = d.Get(fmt.Sprintf("node_pool.%d.cores", index))
nodePool["storage"] = d.Get(fmt.Sprintf("node_pool.%d.storage", index))
nodePool["storage_type"] = d.Get(fmt.Sprintf("node_pool.%d.storage_type", index))
nodePool["rocket_storage"] = d.Get(fmt.Sprintf("node_pool.%d.rocket_storage", index))

// Set rocket storage if it is set
if rocketStorage, isRocketStorageSet := d.GetOk(fmt.Sprintf("node_pool.%d.rocket_storage", index)); isRocketStorageSet {
nodePool["rocket_storage"] = rocketStorage
}
nodePools = append(nodePools, nodePool)
}
parameters["pools"] = nodePools
Expand Down Expand Up @@ -1095,11 +1093,8 @@ func resourceGridscaleK8sUpdate(d *schema.ResourceData, meta interface{}) error
nodePool["cores"] = d.Get(fmt.Sprintf("node_pool.%d.cores", index))
nodePool["storage"] = d.Get(fmt.Sprintf("node_pool.%d.storage", index))
nodePool["storage_type"] = d.Get(fmt.Sprintf("node_pool.%d.storage_type", index))
nodePool["rocket_storage"] = d.Get(fmt.Sprintf("node_pool.%d.rocket_storage", index))

// Set rocket storage if it is set
if rocketStorage, isRocketStorageSet := d.GetOk(fmt.Sprintf("node_pool.%d.rocket_storage", index)); isRocketStorageSet {
nodePool["rocket_storage"] = rocketStorage
}
nodePools = append(nodePools, nodePool)
}
parameters["pools"] = nodePools
Expand Down

0 comments on commit f8f3e22

Please sign in to comment.