Skip to content

Commit

Permalink
Fix error introduce in the last release
Browse files Browse the repository at this point in the history
Close #104

Signed-off-by: Alejandro J. Nuñez Madrazo <alejandrojnm@gmail.com>
  • Loading branch information
alejandrojnm committed Nov 2, 2021
1 parent 31df91f commit a89b476
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions civo/resource_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ func nodePoolSchema() *schema.Schema {
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Description: "Nodepool ID",
},
"count": {
Type: schema.TypeInt,
Computed: true,
Expand Down Expand Up @@ -543,6 +548,7 @@ func flattenInstances(instances []civogo.KubernetesInstance) []interface{} {

// function to flatten all instances inside the cluster
func flattenNodePool(cluster *civogo.KubernetesCluster) []interface{} {

if cluster.Pools == nil {
return nil
}
Expand All @@ -552,14 +558,12 @@ func flattenNodePool(cluster *civogo.KubernetesCluster) []interface{} {
flattenedPoolInstance := make([]interface{}, 0)
for _, v := range pool.Instances {

instanceData := searchInstance(cluster.Instances, v.Hostname)

rawPoolInstance := map[string]interface{}{
"hostname": v.Hostname,
"size": pool.Size,
"cpu_cores": instanceData.CPUCores,
"ram_mb": instanceData.RAMMegabytes,
"disk_gb": instanceData.DiskGigabytes,
"cpu_cores": v.CPUCores,
"ram_mb": v.RAMMegabytes,
"disk_gb": v.DiskGigabytes,
"status": v.Status,
"tags": v.Tags,
}
Expand Down Expand Up @@ -601,13 +605,4 @@ func flattenInstalledApplication(apps []civogo.KubernetesInstalledApplication) [
}

return flattenedInstalledApplication
}

func searchInstance(instanceList []civogo.KubernetesInstance, hostname string) civogo.KubernetesInstance {
for _, v := range instanceList {
if strings.Contains(v.Hostname, hostname) {
return v
}
}
return civogo.KubernetesInstance{}
}
}

0 comments on commit a89b476

Please sign in to comment.