From 8281a1976959ac3d9386320f7f9a78e925eaebf1 Mon Sep 17 00:00:00 2001 From: tulika-aakriti Date: Tue, 15 Oct 2024 23:31:20 +0530 Subject: [PATCH] Feat: Add oracle_database_cloud_vm_cluster datasource (#11997) --- .../provider/provider_mmv1_resources.go.tmpl | 1 + ...source_oracle_database_cloud_vm_cluster.go | 36 +++++++++++++++ ...e_oracle_database_cloud_vm_cluster_test.go | 44 +++++++++++++++++++ ...le_database_cloud_vm_cluster.html.markdown | 34 ++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 mmv1/third_party/terraform/services/oracledatabase/data_source_oracle_database_cloud_vm_cluster.go create mode 100644 mmv1/third_party/terraform/services/oracledatabase/data_source_oracle_database_cloud_vm_cluster_test.go create mode 100644 mmv1/third_party/terraform/website/docs/d/oracle_database_cloud_vm_cluster.html.markdown diff --git a/mmv1/third_party/terraform/provider/provider_mmv1_resources.go.tmpl b/mmv1/third_party/terraform/provider/provider_mmv1_resources.go.tmpl index b7a75e87b30e..4d4cf2f26fdd 100644 --- a/mmv1/third_party/terraform/provider/provider_mmv1_resources.go.tmpl +++ b/mmv1/third_party/terraform/provider/provider_mmv1_resources.go.tmpl @@ -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(), diff --git a/mmv1/third_party/terraform/services/oracledatabase/data_source_oracle_database_cloud_vm_cluster.go b/mmv1/third_party/terraform/services/oracledatabase/data_source_oracle_database_cloud_vm_cluster.go new file mode 100644 index 000000000000..9c17579349dc --- /dev/null +++ b/mmv1/third_party/terraform/services/oracledatabase/data_source_oracle_database_cloud_vm_cluster.go @@ -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 +} diff --git a/mmv1/third_party/terraform/services/oracledatabase/data_source_oracle_database_cloud_vm_cluster_test.go b/mmv1/third_party/terraform/services/oracledatabase/data_source_oracle_database_cloud_vm_cluster_test.go new file mode 100644 index 000000000000..4d5f55afba42 --- /dev/null +++ b/mmv1/third_party/terraform/services/oracledatabase/data_source_oracle_database_cloud_vm_cluster_test.go @@ -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" +} +`) +} diff --git a/mmv1/third_party/terraform/website/docs/d/oracle_database_cloud_vm_cluster.html.markdown b/mmv1/third_party/terraform/website/docs/d/oracle_database_cloud_vm_cluster.html.markdown new file mode 100644 index 000000000000..fa669947abc0 --- /dev/null +++ b/mmv1/third_party/terraform/website/docs/d/oracle_database_cloud_vm_cluster.html.markdown @@ -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. \ No newline at end of file