Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix (typo): rename node_pools to node_pool #407

Merged
merged 6 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions gridscale/resource_gridscale_k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (rgk8sm *ResourceGridscaleK8sModeler) buildInputSchema() map[string]*schema
Description: "PaaS service template identifier for this service.",
Computed: true,
},
"node_pools": {
"node_pool": {
Type: schema.TypeList,
itakouna marked this conversation as resolved.
Show resolved Hide resolved
Optional: true,
Description: `Define a list of pools and their attributes.`,
Expand Down Expand Up @@ -794,7 +794,7 @@ func resourceGridscaleK8sRead(d *schema.ResourceData, meta interface{}) error {
}
}
// Set node pools
if err = d.Set("node_pools", nodePools); err != nil {
if err = d.Set("node_pool", nodePools); err != nil {
return fmt.Errorf("%s error setting node_pool: %v", errorPrefix, err)
}
// Set cluster CIDR if it is set
Expand Down Expand Up @@ -872,21 +872,21 @@ func resourceGridscaleK8sCreate(d *schema.ResourceData, meta interface{}) error
parameters := make(map[string]interface{})

// Iterate over requested node pools to set them
if nodePoolsRequestedInterface, ok := d.GetOk("node_pools"); ok {
if nodePoolsRequestedInterface, ok := d.GetOk("node_pool"); ok {
nodePoolsRequested := nodePoolsRequestedInterface.([]interface{})
nodePools := make([]map[string]interface{}, 0)

for index, _ := range nodePoolsRequested {
nodePool := make(map[string]interface{}, 0)
nodePool["name"] = d.Get(fmt.Sprintf("node_pools.%d.name", index))
nodePool["count"] = d.Get(fmt.Sprintf("node_pools.%d.node_count", index))
nodePool["ram"] = d.Get(fmt.Sprintf("node_pools.%d.memory", index))
nodePool["cores"] = d.Get(fmt.Sprintf("node_pools.%d.cores", index))
nodePool["storage"] = d.Get(fmt.Sprintf("node_pools.%d.storage", index))
nodePool["storage_type"] = d.Get(fmt.Sprintf("node_pools.%d.storage_type", index))
nodePool["name"] = d.Get(fmt.Sprintf("node_pool.%d.name", index))
nodePool["count"] = d.Get(fmt.Sprintf("node_pool.%d.node_count", index))
nodePool["ram"] = d.Get(fmt.Sprintf("node_pool.%d.memory", index))
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))

// Set rocket storage if it is set
if rocketStorage, isRocketStorageSet := d.GetOk(fmt.Sprintf("node_pools.%d.rocket_storage", index)); isRocketStorageSet {
if rocketStorage, isRocketStorageSet := d.GetOk(fmt.Sprintf("node_pool.%d.rocket_storage", index)); isRocketStorageSet {
nodePool["rocket_storage"] = rocketStorage
}
nodePools = append(nodePools, nodePool)
Expand Down Expand Up @@ -1039,21 +1039,21 @@ func resourceGridscaleK8sUpdate(d *schema.ResourceData, meta interface{}) error
parameters := make(map[string]interface{})

// Iterate over requested node pools to set them
if nodePoolsRequestedInterface, ok := d.GetOk("node_pools"); ok {
if nodePoolsRequestedInterface, ok := d.GetOk("node_pool"); ok {
nodePoolsRequested := nodePoolsRequestedInterface.([]interface{})
nodePools := make([]map[string]interface{}, 0)

for index, _ := range nodePoolsRequested {
nodePool := make(map[string]interface{}, 0)
nodePool["name"] = d.Get(fmt.Sprintf("node_pools.%d.name", index))
nodePool["count"] = d.Get(fmt.Sprintf("node_pools.%d.node_count", index))
nodePool["ram"] = d.Get(fmt.Sprintf("node_pools.%d.memory", index))
nodePool["cores"] = d.Get(fmt.Sprintf("node_pools.%d.cores", index))
nodePool["storage"] = d.Get(fmt.Sprintf("node_pools.%d.storage", index))
nodePool["storage_type"] = d.Get(fmt.Sprintf("node_pools.%d.storage_type", index))
nodePool["name"] = d.Get(fmt.Sprintf("node_pool.%d.name", index))
nodePool["count"] = d.Get(fmt.Sprintf("node_pool.%d.node_count", index))
nodePool["ram"] = d.Get(fmt.Sprintf("node_pool.%d.memory", index))
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))

// Set rocket storage if it is set
if rocketStorage, isRocketStorageSet := d.GetOk(fmt.Sprintf("node_pools.%d.rocket_storage", index)); isRocketStorageSet {
if rocketStorage, isRocketStorageSet := d.GetOk(fmt.Sprintf("node_pool.%d.rocket_storage", index)); isRocketStorageSet {
nodePool["rocket_storage"] = rocketStorage
}
nodePools = append(nodePools, nodePool)
Expand Down Expand Up @@ -1206,7 +1206,7 @@ func validateK8sParameters(d *schema.ResourceDiff, template gsclient.PaaSTemplat
return err
}
templateParameterNodePools, templateParameterNodePoolsFound := template.Properties.ParametersSchema["pools"]
nodePoolsRequestedInterface, isNodePoolsRequested := d.GetOk("node_pools")
nodePoolsRequestedInterface, isNodePoolsRequested := d.GetOk("node_pool")

if templateParameterNodePoolsFound && isNodePoolsRequested {
nodePoolsRequested := nodePoolsRequestedInterface.([]interface{})
Expand Down
40 changes: 20 additions & 20 deletions gridscale/resource_gridscale_k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestAccResourceGridscaleK8sBasic(t *testing.T) {

func testAccCheckResourceGridscaleK8sConfigBasic(name string) string {
return fmt.Sprintf(`
variable "node_pools" {
variable "node_pool" {
description = "A list of node pools"
default = [
{
Expand All @@ -59,16 +59,16 @@ variable "node_pools" {
resource "gridscale_k8s" "foopaas" {
name = "%s"
release = "1.30"
dynamic "node_pools" {
for_each = var.node_pools
dynamic "node_pool" {
for_each = var.node_pool
content {
name = node_pools.value.name
node_count = node_pools.value.node_count
cores = node_pools.value.cores
memory = node_pools.value.memory
storage = node_pools.value.storage
storage_type = node_pools.value.storage_type
rocket_storage = node_pools.value.rocket_storage
name = node_pool.value.name
node_count = node_pool.value.node_count
cores = node_pool.value.cores
memory = node_pool.value.memory
storage = node_pool.value.storage
storage_type = node_pool.value.storage_type
rocket_storage = node_pool.value.rocket_storage
}
}
surge_node = false
Expand All @@ -87,7 +87,7 @@ resource "gridscale_k8s" "foopaas" {

func testAccCheckResourceGridscaleK8sConfigBasicUpdate() string {
return `
variable "node_pools" {
variable "node_pool" {
description = "A list of node pools"
nvthongswansea marked this conversation as resolved.
Show resolved Hide resolved
default = [
{
Expand All @@ -105,16 +105,16 @@ variable "node_pools" {
resource "gridscale_k8s" "foopaas" {
name = "newname"
release = "1.30"
dynamic "node_pools" {
for_each = var.node_pools
dynamic "node_pool" {
for_each = var.node_pool
content {
name = node_pools.value.name
node_count = node_pools.value.node_count
cores = node_pools.value.cores
memory = node_pools.value.memory
storage = node_pools.value.storage
storage_type = node_pools.value.storage_type
rocket_storage = node_pools.value.rocket_storage
name = node_pool.value.name
node_count = node_pool.value.node_count
cores = node_pool.value.cores
memory = node_pool.value.memory
storage = node_pool.value.storage
storage_type = node_pool.value.storage_type
rocket_storage = node_pool.value.rocket_storage
}
}
surge_node = false
Expand Down
24 changes: 12 additions & 12 deletions website/docs/r/k8s.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Provides a k8s cluster resource. This can be used to create, modify, and delete
The following example shows how one might use this resource to add a k8s cluster to gridscale:

```terraform
variable "node_pools" {
variable "node_pool" {
description = "A list of node pools"
default = [
{
Expand All @@ -34,16 +34,16 @@ variable "node_pools" {
resource "gridscale_k8s" "k8s-test" {
name = "test"
release = "1.30" # instead, gsk_version can be set.
dynamic "node_pools" {
for_each = var.node_pools
dynamic "node_pool" {
for_each = var.node_pool
content {
name = node_pools.value.name
node_count = node_pools.value.node_count
cores = node_pools.value.cores
memory = node_pools.value.memory
storage = node_pools.value.storage
storage_type = node_pools.value.storage_type
rocket_storage = node_pools.value.rocket_storage
name = node_pool.value.name
node_count = node_pool.value.node_count
cores = node_pool.value.cores
memory = node_pool.value.memory
storage = node_pool.value.storage
storage_type = node_pool.value.storage_type
rocket_storage = node_pool.value.rocket_storage
}
}
}
Expand All @@ -63,7 +63,7 @@ The following arguments are supported:

* `labels` - (Optional) List of labels in the format [ "label1", "label2" ].

* `node_pools` - (Optional) The collection of node pool specifications. **NOTE**: Any node pool specification is not yet mutable (except `node_count`).
* `node_pool` - (Optional) The collection of node pool specifications. **NOTE**: Any node pool specification is not yet mutable (except `node_count`).
* `name` - Name of the node pool.
* `node_count` - Number of worker nodes.
* `cores` - Cores per worker node.
Expand Down Expand Up @@ -121,7 +121,7 @@ This resource exports the following attributes:
* `kubeconfig` - The kubeconfig file content of the k8s cluster.
* `network_uuid` - *DEPRECATED* Network UUID containing security zone, which is linked to the k8s cluster.
* `k8s_private_network_uuid` - Private network UUID which k8s nodes are attached to. It can be used to attach other PaaS/VMs.
* `node_pools` - See Argument Reference above.
* `node_pool` - See Argument Reference above.
* `name` - See Argument Reference above.
* `node_count` - See Argument Reference above.
* `cores` - See Argument Reference above.
Expand Down
Loading