Skip to content

Commit

Permalink
Feat: Add oracle_database_cloud_vm_cluster datasource (GoogleCloudPla…
Browse files Browse the repository at this point in the history
  • Loading branch information
tulika-aakriti authored Oct 15, 2024
1 parent 2ee6a3c commit 6777493
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ var handwrittenDatasources = map[string]*schema.Resource{
"google_monitoring_uptime_check_ips": monitoring.DataSourceGoogleMonitoringUptimeCheckIps(),
"google_netblock_ip_ranges": resourcemanager.DataSourceGoogleNetblockIpRanges(),
"google_oracle_database_db_servers": oracledatabase.DataSourceOracleDatabaseDbServers(),
"google_oracle_database_cloud_vm_cluster": oracledatabase.DataSourceOracleDatabaseCloudVmCluster(),
"google_oracle_database_cloud_exadata_infrastructure":oracledatabase.DataSourceOracleDatabaseCloudExadataInfrastructure(),
"google_organization": resourcemanager.DataSourceGoogleOrganization(),
"google_privateca_certificate_authority": privateca.DataSourcePrivatecaCertificateAuthority(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package oracledatabase

import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
)

func DataSourceOracleDatabaseCloudVmCluster() *schema.Resource {
dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceOracleDatabaseCloudVmCluster().Schema)
tpgresource.AddRequiredFieldsToSchema(dsSchema, "location", "cloud_vm_cluster_id")
tpgresource.AddOptionalFieldsToSchema(dsSchema, "project")
return &schema.Resource{
Read: dataSourceOracleDatabaseCloudVmClusterRead,
Schema: dsSchema,
}

}

func dataSourceOracleDatabaseCloudVmClusterRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*transport_tpg.Config)

id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/cloudVmClusters/{{cloud_vm_cluster_id}}")
if err != nil {
return fmt.Errorf("Error constructing id: %s", err)
}
err = resourceOracleDatabaseCloudVmClusterRead(d, meta)
if err != nil {
return err
}
d.SetId(id)

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package oracledatabase_test

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-google/google/acctest"
)

func TestAccOracleDatabaseCloudVmCluster_basic(t *testing.T) {
t.Parallel()
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccOracleDatabaseCloudVmCluster_basic(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "display_name"),
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "exadata_infrastructure"),
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "cidr"),
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.#"),
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.cpu_core_count"),
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.cluster_name"),
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "gcp_oracle_zone", "us-east4-b-r1"),
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.node_count", "2"),
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.state", "AVAILABLE"),
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.shape", "Exadata.X9M"),
),
},
},
})
}

func testAccOracleDatabaseCloudVmCluster_basic() string {
return fmt.Sprintf(`
data "google_oracle_database_cloud_vm_cluster" "my-vmcluster"{
cloud_vm_cluster_id = "ofake-do-not-delete-tf-vmcluster"
project = "oci-terraform-testing"
location = "us-east4"
}
`)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
subcategory: "Oracle Database"
description: |-
Get information about a CloudVmCluster.
---

# google_oracle_database_cloud_vm_cluster

Get information about a CloudVmCluster.

## Example Usage

```hcl
data "google_oracle_database_cloud_vm_cluster" "my-vmcluster"{
location = "us-east4"
cloud_vm_cluster_id = "vmcluster-id"
}
```

## Argument Reference

The following arguments are supported:

* `cloud_vm_cluster_id` - (Required) The ID of the VM Cluster.

* `location` - (Required) The location of the resource.

- - -
* `project` - (Optional) The project in which the resource belongs. If it
is not provided, the provider project is used.

## Attributes Reference

See [google_oracle_database_cloud_vm_cluster](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_oracle_database_cloud_vm_cluster#argument-reference) resource for details of the available attributes.

0 comments on commit 6777493

Please sign in to comment.