diff --git a/civo/datasource_instance.go b/civo/datasource_instance.go index e2526b9f..09034d86 100644 --- a/civo/datasource_instance.go +++ b/civo/datasource_instance.go @@ -36,6 +36,18 @@ func dataSourceInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "cpu_cores": { + Type: schema.TypeInt, + Computed: true, + }, + "ram_mb": { + Type: schema.TypeInt, + Computed: true, + }, + "disk_gb": { + Type: schema.TypeInt, + Computed: true, + }, "network_id": { Type: schema.TypeString, Computed: true, @@ -124,6 +136,9 @@ func dataSourceInstanceRead(d *schema.ResourceData, m interface{}) error { d.Set("hostname", foundImage.Hostname) d.Set("reverse_dns", foundImage.ReverseDNS) d.Set("size", foundImage.Size) + d.Set("cpu_cores", foundImage.CPUCores) + d.Set("ram_mb", foundImage.RAMMegabytes) + d.Set("disk_gb", foundImage.DiskGigabytes) d.Set("initial_user", foundImage.InitialUser) d.Set("initial_password", foundImage.InitialPassword) d.Set("sshkey_id", foundImage.SSHKey) diff --git a/civo/datasource_instances.go b/civo/datasource_instances.go index 2e20c510..8275e4ce 100644 --- a/civo/datasource_instances.go +++ b/civo/datasource_instances.go @@ -2,6 +2,7 @@ package civo import ( "fmt" + "github.com/civo/civogo" "github.com/civo/terraform-provider-civo/internal/datalist" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -27,6 +28,18 @@ func dataSourceInstances() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "cpu_cores": { + Type: schema.TypeInt, + Computed: true, + }, + "ram_mb": { + Type: schema.TypeInt, + Computed: true, + }, + "disk_gb": { + Type: schema.TypeInt, + Computed: true, + }, "network_id": { Type: schema.TypeString, Computed: true, @@ -92,6 +105,9 @@ func dataSourceInstances() *schema.Resource { "private_ip", "pseudo_ip", "size", + "cpu_cores", + "ram_mb", + "disk_gb", "template", "created_at", }, @@ -102,6 +118,9 @@ func dataSourceInstances() *schema.Resource { "private_ip", "pseudo_ip", "size", + "cpu_cores", + "ram_mb", + "disk_gb", "template", "created_at", }, @@ -139,6 +158,9 @@ func flattenDataSourceInstances(instance, m interface{}) (map[string]interface{} flattenedInstance["hostname"] = i.Hostname flattenedInstance["reverse_dns"] = i.ReverseDNS flattenedInstance["size"] = i.Size + flattenedInstance["cpu_cores"] = i.CPUCores + flattenedInstance["ram_mb"] = i.RAMMegabytes + flattenedInstance["disk_gb"] = i.DiskGigabytes flattenedInstance["network_id"] = i.NetworkID flattenedInstance["template"] = i.TemplateID flattenedInstance["initial_user"] = i.InitialUser diff --git a/civo/datasource_kubernetes_cluster.go b/civo/datasource_kubernetes_cluster.go index 7ebd33a7..722e5432 100644 --- a/civo/datasource_kubernetes_cluster.go +++ b/civo/datasource_kubernetes_cluster.go @@ -101,6 +101,18 @@ func dataSourceInstanceSchema() *schema.Schema { Type: schema.TypeString, Computed: true, }, + "cpu_cores": { + Type: schema.TypeInt, + Computed: true, + }, + "ram_mb": { + Type: schema.TypeInt, + Computed: true, + }, + "disk_gb": { + Type: schema.TypeInt, + Computed: true, + }, "region": { Type: schema.TypeString, Computed: true, diff --git a/civo/import_dns_domain_record_test.go b/civo/import_dns_domain_record_test.go new file mode 100644 index 00000000..cb2d5c1e --- /dev/null +++ b/civo/import_dns_domain_record_test.go @@ -0,0 +1,48 @@ +package civo + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" +) + +func TestAccCivoDNSDomainRecord_importBasic(t *testing.T) { + resourceName := "civo_dns_domain_record.www" + var domainName = acctest.RandomWithPrefix("tf-test-record") + ".example" + var recordName = acctest.RandomWithPrefix("record") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckCivoDNSDomainNameRecordDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckCivoDNSDomainNameRecordConfigBasic(domainName, recordName), + }, + + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateIdFunc: testAccDNSDomainNameRecordImportID(resourceName), + }, + }, + }) +} + +func testAccDNSDomainNameRecordImportID(n string) resource.ImportStateIdFunc { + return func(s *terraform.State) (string, error) { + rs, ok := s.RootModule().Resources[n] + if !ok { + return "", fmt.Errorf("Not found: %s", n) + } + + domainID := rs.Primary.Attributes["domain_id"] + id := rs.Primary.ID + + return fmt.Sprintf("%s:%s", domainID, id), nil + } +} diff --git a/civo/resource_instance.go b/civo/resource_instance.go index 97e18048..46768103 100644 --- a/civo/resource_instance.go +++ b/civo/resource_instance.go @@ -86,6 +86,18 @@ func resourceInstance() *schema.Resource { ValidateFunc: validation.StringIsNotEmpty, }, // Computed resource + "cpu_cores": { + Type: schema.TypeInt, + Computed: true, + }, + "ram_mb": { + Type: schema.TypeInt, + Computed: true, + }, + "disk_gb": { + Type: schema.TypeInt, + Computed: true, + }, "initial_password": { Type: schema.TypeString, Computed: true, @@ -237,6 +249,9 @@ func resourceInstanceRead(d *schema.ResourceData, m interface{}) error { d.Set("hostname", resp.Hostname) d.Set("reverse_dns", resp.ReverseDNS) d.Set("size", resp.Size) + d.Set("cpu_cores", resp.CPUCores) + d.Set("ram_mb", resp.RAMMegabytes) + d.Set("disk_gb", resp.DiskGigabytes) d.Set("initial_user", resp.InitialUser) d.Set("initial_password", resp.InitialPassword) d.Set("sshkey_id", resp.SSHKey) diff --git a/civo/resource_instance_test.go b/civo/resource_instance_test.go index 1c5d76da..23c17b08 100644 --- a/civo/resource_instance_test.go +++ b/civo/resource_instance_test.go @@ -36,6 +36,9 @@ func TestAccCivoInstance_basic(t *testing.T) { resource.TestCheckResourceAttr(resName, "hostname", instanceHostname), resource.TestCheckResourceAttr(resName, "size", "g2.xsmall"), resource.TestCheckResourceAttr(resName, "initial_user", "civo"), + resource.TestCheckResourceAttr(resName, "cpu_cores", "1"), + resource.TestCheckResourceAttr(resName, "ram_mb", "1024"), + resource.TestCheckResourceAttr(resName, "disk_gb", "25"), resource.TestCheckResourceAttrSet(resName, "initial_password"), resource.TestCheckResourceAttrSet(resName, "private_ip"), resource.TestCheckResourceAttrSet(resName, "public_ip"), @@ -67,6 +70,9 @@ func TestAccCivoInstanceSize_update(t *testing.T) { resource.TestCheckResourceAttr(resName, "hostname", instanceHostname), resource.TestCheckResourceAttr(resName, "size", "g2.xsmall"), resource.TestCheckResourceAttr(resName, "initial_user", "civo"), + resource.TestCheckResourceAttr(resName, "cpu_cores", "1"), + resource.TestCheckResourceAttr(resName, "ram_mb", "1024"), + resource.TestCheckResourceAttr(resName, "disk_gb", "25"), resource.TestCheckResourceAttrSet(resName, "initial_password"), resource.TestCheckResourceAttrSet(resName, "private_ip"), resource.TestCheckResourceAttrSet(resName, "public_ip"), @@ -83,6 +89,9 @@ func TestAccCivoInstanceSize_update(t *testing.T) { resource.TestCheckResourceAttr(resName, "hostname", instanceHostname), resource.TestCheckResourceAttr(resName, "size", "g2.large"), resource.TestCheckResourceAttr(resName, "initial_user", "civo"), + resource.TestCheckResourceAttr(resName, "cpu_cores", "4"), + resource.TestCheckResourceAttr(resName, "ram_mb", "8192"), + resource.TestCheckResourceAttr(resName, "disk_gb", "100"), resource.TestCheckResourceAttrSet(resName, "initial_password"), resource.TestCheckResourceAttrSet(resName, "private_ip"), resource.TestCheckResourceAttrSet(resName, "public_ip"), @@ -114,6 +123,9 @@ func TestAccCivoInstanceNotes_update(t *testing.T) { resource.TestCheckResourceAttr(resName, "hostname", instanceHostname), resource.TestCheckResourceAttr(resName, "size", "g2.xsmall"), resource.TestCheckResourceAttr(resName, "initial_user", "civo"), + resource.TestCheckResourceAttr(resName, "cpu_cores", "1"), + resource.TestCheckResourceAttr(resName, "ram_mb", "1024"), + resource.TestCheckResourceAttr(resName, "disk_gb", "25"), resource.TestCheckResourceAttr(resName, "notes", ""), resource.TestCheckResourceAttrSet(resName, "initial_password"), resource.TestCheckResourceAttrSet(resName, "private_ip"), @@ -131,6 +143,9 @@ func TestAccCivoInstanceNotes_update(t *testing.T) { resource.TestCheckResourceAttr(resName, "hostname", instanceHostname), resource.TestCheckResourceAttr(resName, "size", "g2.xsmall"), resource.TestCheckResourceAttr(resName, "initial_user", "civo"), + resource.TestCheckResourceAttr(resName, "cpu_cores", "1"), + resource.TestCheckResourceAttr(resName, "ram_mb", "1024"), + resource.TestCheckResourceAttr(resName, "disk_gb", "25"), resource.TestCheckResourceAttr(resName, "notes", "the_test_notes"), resource.TestCheckResourceAttrSet(resName, "initial_password"), resource.TestCheckResourceAttrSet(resName, "private_ip"), @@ -164,6 +179,9 @@ func TestAccCivoInstanceFirewall_update(t *testing.T) { resource.TestCheckResourceAttr(resName, "hostname", instanceHostname), resource.TestCheckResourceAttr(resName, "size", "g2.xsmall"), resource.TestCheckResourceAttr(resName, "initial_user", "civo"), + resource.TestCheckResourceAttr(resName, "cpu_cores", "1"), + resource.TestCheckResourceAttr(resName, "ram_mb", "1024"), + resource.TestCheckResourceAttr(resName, "disk_gb", "25"), resource.TestCheckResourceAttrSet(resName, "initial_password"), resource.TestCheckResourceAttrSet(resName, "private_ip"), resource.TestCheckResourceAttrSet(resName, "public_ip"), @@ -181,6 +199,9 @@ func TestAccCivoInstanceFirewall_update(t *testing.T) { resource.TestCheckResourceAttr(resName, "hostname", instanceHostname), resource.TestCheckResourceAttr(resName, "size", "g2.xsmall"), resource.TestCheckResourceAttr(resName, "initial_user", "civo"), + resource.TestCheckResourceAttr(resName, "cpu_cores", "1"), + resource.TestCheckResourceAttr(resName, "ram_mb", "1024"), + resource.TestCheckResourceAttr(resName, "disk_gb", "25"), resource.TestCheckResourceAttrSet(resName, "firewall_id"), resource.TestCheckResourceAttrSet(resName, "initial_password"), resource.TestCheckResourceAttrSet(resName, "private_ip"), diff --git a/civo/resource_kubernetes_cluster.go b/civo/resource_kubernetes_cluster.go index 93015783..e8f36da9 100644 --- a/civo/resource_kubernetes_cluster.go +++ b/civo/resource_kubernetes_cluster.go @@ -111,6 +111,18 @@ func instanceSchema() *schema.Schema { Type: schema.TypeString, Computed: true, }, + "cpu_cores": { + Type: schema.TypeInt, + Computed: true, + }, + "ram_mb": { + Type: schema.TypeInt, + Computed: true, + }, + "disk_gb": { + Type: schema.TypeInt, + Computed: true, + }, "region": { Type: schema.TypeString, Computed: true, @@ -318,6 +330,9 @@ func flattenInstances(instances []civogo.KubernetesInstance) []interface{} { rawInstance := map[string]interface{}{ "hostname": instance.Hostname, "size": instance.Size, + "cpu_cores": instance.CPUCores, + "ram_mb": instance.RAMMegabytes, + "disk_gb": instance.DiskGigabytes, "region": instance.Region, "status": instance.Status, "firewall_id": instance.FirewallID, diff --git a/civo/resource_kubernetes_cluster_test.go b/civo/resource_kubernetes_cluster_test.go index 389b5c34..c8ba7009 100644 --- a/civo/resource_kubernetes_cluster_test.go +++ b/civo/resource_kubernetes_cluster_test.go @@ -36,6 +36,9 @@ func TestAccCivoKubernetesCluster_basic(t *testing.T) { resource.TestCheckResourceAttr(resName, "name", kubernetesClusterName), resource.TestCheckResourceAttr(resName, "num_target_nodes", "2"), resource.TestCheckResourceAttr(resName, "target_nodes_size", "g2.small"), + resource.TestCheckResourceAttr(resName, "instances.0.cpu_cores", "1"), + resource.TestCheckResourceAttr(resName, "instances.0.ram_mb", "2048"), + resource.TestCheckResourceAttr(resName, "instances.0.disk_gb", "25"), // resource.TestCheckResourceAttrSet(resName, "instances"), resource.TestCheckResourceAttrSet(resName, "kubeconfig"), resource.TestCheckResourceAttrSet(resName, "api_endpoint"), diff --git a/go.mod b/go.mod index 5b2cc01d..509c20ed 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/civo/terraform-provider-civo require ( cloud.google.com/go v0.54.0 // indirect github.com/aws/aws-sdk-go v1.29.22 // indirect - github.com/civo/civogo v0.2.11 + github.com/civo/civogo v0.2.12 github.com/fatih/color v1.9.0 // indirect github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 github.com/hashicorp/go-getter v1.4.1 // indirect diff --git a/go.sum b/go.sum index 63dc3e41..c413d7fb 100644 --- a/go.sum +++ b/go.sum @@ -63,6 +63,8 @@ github.com/civo/civogo v0.2.10 h1:hcX3hSEzPAmH+bNwcwAorYKcl4fe81vQEyk4zR+0URg= github.com/civo/civogo v0.2.10/go.mod h1:SR0ZOhABfQHjgNQE3UyfX4gaYsrfslkPFRFMx5P29rg= github.com/civo/civogo v0.2.11 h1:NBWf3048YQSxwgS0+nY+77fh8xCAACUkmL0pXPwYZlw= github.com/civo/civogo v0.2.11/go.mod h1:SR0ZOhABfQHjgNQE3UyfX4gaYsrfslkPFRFMx5P29rg= +github.com/civo/civogo v0.2.12 h1:+Fx1of+LurR6xRUHUghvJfyi7jONkuZR8eYDHriCA74= +github.com/civo/civogo v0.2.12/go.mod h1:SR0ZOhABfQHjgNQE3UyfX4gaYsrfslkPFRFMx5P29rg= 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/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/website/docs/d/instance.html.markdown b/website/docs/d/instance.html.markdown index 9dffac87..796a4fce 100644 --- a/website/docs/d/instance.html.markdown +++ b/website/docs/d/instance.html.markdown @@ -52,6 +52,9 @@ The following attributes are exported: * `hostname` - The Instance hostname. * `reverse_dns` - A fully qualified domain name. * `size` - The name of the size. +* `cpu_cores` - Total cpu of the inatance. +* `ram_mb` - Total ram of the instance. +* `disk_gb` - The size of the disk. * `public_ip_requiered` - This should be either false, true or `move_ip_from:intances_id`. * `network_id` - This will be the ID of the network. * `template` - The ID for the template to used to build the instance. diff --git a/website/docs/d/instances.html.markdown b/website/docs/d/instances.html.markdown index 759e3ecd..bc12f525 100644 --- a/website/docs/d/instances.html.markdown +++ b/website/docs/d/instances.html.markdown @@ -81,7 +81,7 @@ data "civo_instances" "small-with-backups" { `filter` supports the following arguments: * `key` - (Required) Filter the Instances by this key. This may be one of '`id`, `hostname`, `public_ip`, `private_ip`, - `pseudo_ip`, `size`, `template` or `created_at`. + `pseudo_ip`, `size`, `cpu_cores`, `ram_mb`, `disk_gb`, `template` or `created_at`. * `values` - (Required) A list of values to match against the `key` field. Only retrieves Instances where the `key` field takes on one or more of the values provided here. @@ -89,7 +89,7 @@ data "civo_instances" "small-with-backups" { `sort` supports the following arguments: * `key` - (Required) Sort the Instance by this key. This may be one of `id`, `hostname`, `public_ip`, `private_ip`, - `pseudo_ip`, `size`, `template` or `created_at`. + `pseudo_ip`, `size`, `cpu_cores`, `ram_mb`, `disk_gb`, `template` or `created_at`. * `direction` - (Required) The sort direction. This may be either `asc` or `desc`. @@ -101,6 +101,9 @@ data "civo_instances" "small-with-backups" { * `hostname` - The Instance hostname. * `reverse_dns` - A fully qualified domain name. * `size` - The name of the size. +* `cpu_cores` - Total cpu of the inatance. +* `ram_mb` - Total ram of the instance. +* `disk_gb` - The size of the disk. * `public_ip_requiered` - This should be either false, true or `move_ip_from:intances_id`. * `network_id` - This will be the ID of the network. * `template` - The ID for the template to used to build the instance. diff --git a/website/docs/d/kubernetes_cluster.html.md b/website/docs/d/kubernetes_cluster.html.md index 579fc85e..be738e55 100644 --- a/website/docs/d/kubernetes_cluster.html.md +++ b/website/docs/d/kubernetes_cluster.html.md @@ -55,6 +55,9 @@ The following attributes are exported: * `instances` - In addition to the arguments provided, these additional attributes about the cluster's default node instance are exported. - `hostname` - The hostname of the instance. - `size` - The size of the instance. + - `cpu_cores` - Total cpu of the inatance. + - `ram_mb` - Total ram of the instance + - `disk_gb` - The size of the disk. - `region` - The region where instance are. - `status` - The status of the instance. - `created_at` - The date where the instances was created. diff --git a/website/docs/r/instance.html.markdown b/website/docs/r/instance.html.markdown index e6531e84..918ea3e5 100644 --- a/website/docs/r/instance.html.markdown +++ b/website/docs/r/instance.html.markdown @@ -48,6 +48,9 @@ The following attributes are exported: * `hostname` - The Instance hostname. * `reverse_dns` - A fully qualified domain name. * `size` - The name of the size. +* `cpu_cores` - Total cpu of the inatance. +* `ram_mb` - Total ram of the instance. +* `disk_gb` - The size of the disk. * `public_ip_requiered` - This should be either false, true or `move_ip_from:intances_id`. * `network_id` - This will be the ID of the network. * `template` - The ID for the template to used to build the instance. diff --git a/website/docs/r/kubernetes_cluster.html.markdown b/website/docs/r/kubernetes_cluster.html.markdown index 4bd279f1..c904a622 100644 --- a/website/docs/r/kubernetes_cluster.html.markdown +++ b/website/docs/r/kubernetes_cluster.html.markdown @@ -71,6 +71,9 @@ In addition to the arguments listed above, the following additional attributes a * `instances` - In addition to the arguments provided, these additional attributes about the cluster's default node instance are exported. - `hostname` - The hostname of the instance. - `size` - The size of the instance. + - `cpu_cores` - Total cpu of the inatance. + - `ram_mb` - Total ram of the instance. + - `disk_gb` - The size of the disk. - `region` - The region where instance are. - `status` - The status of the instance. - `created_at` - The date where the instances was created.