diff --git a/civo/datasource_kubernetes_cluster.go b/civo/datasource_kubernetes_cluster.go index 8d84be9..2390254 100644 --- a/civo/datasource_kubernetes_cluster.go +++ b/civo/datasource_kubernetes_cluster.go @@ -143,6 +143,11 @@ func dataSourcenodePoolSchema() *schema.Schema { Description: "A list of the instance in the pool", Elem: &schema.Schema{Type: schema.TypeString}, }, + "public_ip_node_pool": { + Type: schema.TypeBool, + Computed: true, + Description: "Node pool belongs to the public ip node pool", + }, }, }, } @@ -246,10 +251,11 @@ func flattenDataSourceNodePool(cluster *civogo.KubernetesCluster) []interface{} poolInstanceNames = append(poolInstanceNames, pool.InstanceNames...) rawPool := map[string]interface{}{ - "label": pool.ID, - "node_count": pool.Count, - "size": pool.Size, - "instance_names": poolInstanceNames, + "label": pool.ID, + "node_count": pool.Count, + "size": pool.Size, + "instance_names": poolInstanceNames, + "public_ip_node_pool": pool.PublicIPNodePool, } flattenedPool = append(flattenedPool, rawPool) } diff --git a/civo/resource_kubernetes_cluster.go b/civo/resource_kubernetes_cluster.go index 18e974b..255dce2 100644 --- a/civo/resource_kubernetes_cluster.go +++ b/civo/resource_kubernetes_cluster.go @@ -183,6 +183,12 @@ func nodePoolSchema() *schema.Schema { Elem: &schema.Schema{Type: schema.TypeString}, Description: "Instance names in the nodepool", }, + "public_ip_node_pool": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Node pool belongs to the public ip node pool", + }, }, }, } @@ -495,10 +501,11 @@ func flattenNodePool(cluster *civogo.KubernetesCluster) []interface{} { poolInstanceNames = append(poolInstanceNames, cluster.Pools[0].InstanceNames...) rawPool := map[string]interface{}{ - "label": cluster.Pools[0].ID, - "node_count": cluster.Pools[0].Count, - "size": cluster.Pools[0].Size, - "instance_names": poolInstanceNames, + "label": cluster.Pools[0].ID, + "node_count": cluster.Pools[0].Count, + "size": cluster.Pools[0].Size, + "instance_names": poolInstanceNames, + "public_ip_node_pool": cluster.Pools[0].PublicIPNodePool, } flattenedPool = append(flattenedPool, rawPool) @@ -543,6 +550,11 @@ func expandNodePools(nodePools []interface{}) []civogo.KubernetesClusterPoolConf Size: pool["size"].(string), Count: pool["node_count"].(int), } + + if pool["public_ip_node_pool"].(bool) { + cr.PublicIPNodePool = pool["public_ip_node_pool"].(bool) + } + expandedNodePools = append(expandedNodePools, cr) } diff --git a/civo/resource_kubernetes_cluster_nodepool.go b/civo/resource_kubernetes_cluster_nodepool.go index 6092587..aa8326b 100644 --- a/civo/resource_kubernetes_cluster_nodepool.go +++ b/civo/resource_kubernetes_cluster_nodepool.go @@ -72,6 +72,12 @@ func resourceKubernetesClusterNodePool() *schema.Resource { }, Description: "Instance names in the nodepool", }, + "public_ip_node_pool": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Node pool belongs to the public ip node pool", + }, }, CreateContext: resourceKubernetesClusterNodePoolCreate, ReadContext: resourceKubernetesClusterNodePoolRead, @@ -129,7 +135,13 @@ func resourceKubernetesClusterNodePoolCreate(ctx context.Context, d *schema.Reso newPool = append(newPool, civogo.KubernetesClusterPoolConfig{ID: v.ID, Count: v.Count, Size: v.Size}) } - newPool = append(newPool, civogo.KubernetesClusterPoolConfig{ID: nodePoolLabel, Count: count, Size: size}) + pool := civogo.KubernetesClusterPoolConfig{ID: nodePoolLabel, Count: count, Size: size} + + if value, ok := d.GetOk("public_ip_node_pool"); ok { + pool.PublicIPNodePool = value.(bool) + } + + newPool = append(newPool, pool) log.Printf("[INFO] configuring kubernetes cluster %s to add pool %s", getKubernetesCluster.ID, nodePoolLabel) config := &civogo.KubernetesClusterConfig{ @@ -184,6 +196,10 @@ func resourceKubernetesClusterNodePoolRead(_ context.Context, d *schema.Resource d.Set("node_count", resp.Pools[poolIndex].Count) d.Set("size", resp.Pools[poolIndex].Size) + if resp.Pools[poolIndex].PublicIPNodePool { + d.Set("public_ip_node_pool", resp.Pools[poolIndex].PublicIPNodePool) + } + poolInstanceNames := make([]string, 0) poolInstanceNames = append(poolInstanceNames, resp.Pools[poolIndex].InstanceNames...) @@ -321,6 +337,9 @@ func resourceKubernetesClusterNodePoolImport(d *schema.ResourceData, m interface d.Set("node_count", v.Count) d.Set("size", v.Size) d.Set("region", currentRegionCode) + if v.PublicIPNodePool { + d.Set("public_ip_node_pool", v.PublicIPNodePool) + } } } } diff --git a/examples/data-sources/civo_database_version/data-source.tf b/examples/data-sources/civo_database_version/data-source.tf index 3149981..2f49ae3 100644 --- a/examples/data-sources/civo_database_version/data-source.tf +++ b/examples/data-sources/civo_database_version/data-source.tf @@ -1,36 +1,36 @@ # Example for mysql -data civo_database_version "mysql" { +data "civo_database_version" "mysql" { filter { - key = "engine" - values = ["mysql"] - } + key = "engine" + values = ["mysql"] + } } # Example for postgresql -data civo_database_version "postgresql" { +data "civo_database_version" "postgresql" { filter { - key = "engine" - values = ["postgresql"] - } + key = "engine" + values = ["postgresql"] + } } data "civo_size" "small" { - filter { - key = "name" - values = ["db.small"] - match_by = "re" - } - filter { - key = "type" - values = ["database"] - } + filter { + key = "name" + values = ["db.small"] + match_by = "re" + } + filter { + key = "type" + values = ["database"] + } } # To use this data source, make sure you have a database cluster created. resource "civo_database" "custom_database" { - name = "custom_database" - size = element(data.civo_size.small.sizes, 0).name - nodes = 2 - engine = element(data.civo_database_version.mysql.versions, 0).engine - version = element(data.civo_database_version.mysql.versions, 0).version -} \ No newline at end of file + name = "custom_database" + size = element(data.civo_size.small.sizes, 0).name + nodes = 2 + engine = element(data.civo_database_version.mysql.versions, 0).engine + version = element(data.civo_database_version.mysql.versions, 0).version +} diff --git a/examples/resources/civo_database/resource.tf b/examples/resources/civo_database/resource.tf index 457c68b..66806f6 100644 --- a/examples/resources/civo_database/resource.tf +++ b/examples/resources/civo_database/resource.tf @@ -1,26 +1,26 @@ data "civo_size" "small" { - filter { - key = "name" - values = ["db.small"] - match_by = "re" - } - filter { - key = "type" - values = ["database"] - } + filter { + key = "name" + values = ["db.small"] + match_by = "re" + } + filter { + key = "type" + values = ["database"] + } } -data civo_database_version "mysql" { +data "civo_database_version" "mysql" { filter { - key = "engine" - values = ["mysql"] - } + key = "engine" + values = ["mysql"] + } } resource "civo_database" "custom_database" { - name = "custom_database" - size = element(data.civo_size.small.sizes, 0).name - nodes = 2 - engine = element(data.civo_database_version.mysql.versions, 0).engine - version = element(data.civo_database_version.mysql.versions, 0).version -} \ No newline at end of file + name = "custom_database" + size = element(data.civo_size.small.sizes, 0).name + nodes = 2 + engine = element(data.civo_database_version.mysql.versions, 0).engine + version = element(data.civo_database_version.mysql.versions, 0).version +} diff --git a/go.mod b/go.mod index 149ed66..94c3a78 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/civo/terraform-provider-civo require ( github.com/agext/levenshtein v1.2.3 // indirect - github.com/civo/civogo v0.3.36 + github.com/civo/civogo v0.3.42 github.com/go-logr/logr v1.2.4 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.3.0 diff --git a/go.sum b/go.sum index fcff14c..67d2ae2 100644 --- a/go.sum +++ b/go.sum @@ -33,8 +33,8 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/civo/civogo v0.3.36 h1:hewtVJ0aA7/K2o15STFaX3mIio1iNQPrrOjdadhraO0= -github.com/civo/civogo v0.3.36/go.mod h1:ovGwXtszFiTsVq1OgKG9CtE8q8TPm+4bwE13KuJBr9E= +github.com/civo/civogo v0.3.42 h1:+9W/EFGtk37l0WzD/evktrGbqXE6/MM4TtHuJ5hnPd0= +github.com/civo/civogo v0.3.42/go.mod h1:54lv/FOf7gh6wE9ZwVdw4yBehk8V1CvU9aWa4v6dvW0= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=