forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add oracle_database_cloud_vm_cluster datasource (GoogleCloudPla…
- Loading branch information
1 parent
4b873f8
commit 6f59300
Showing
4 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...d_party/terraform/services/oracledatabase/data_source_oracle_database_cloud_vm_cluster.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
44 changes: 44 additions & 0 deletions
44
...ty/terraform/services/oracledatabase/data_source_oracle_database_cloud_vm_cluster_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
`) | ||
} |
34 changes: 34 additions & 0 deletions
34
...d_party/terraform/website/docs/d/oracle_database_cloud_vm_cluster.html.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |