From 230b9e41d2c8ea43bed9612a09fe33f489a84c3d Mon Sep 17 00:00:00 2001 From: Swamita Gupta <55314843+swamitagupta@users.noreply.github.com> Date: Wed, 22 Nov 2023 04:06:33 +0530 Subject: [PATCH] add standard type vmwareengine network (#9416) --- mmv1/products/vmwareengine/Network.yaml | 7 +- mmv1/products/vmwareengine/product.yaml | 3 + .../vmware_engine_network_legacy.tf.erb | 2 +- .../vmware_engine_network_standard.tf.erb | 6 ++ .../provider/provider_mmv1_resources.go.erb | 2 +- ...ata_source_google_vmwareengine_network.go} | 5 +- ...source_google_vmwareengine_network_test.go | 49 +++++++++++ ...ce_google_vmwareengine_network_test.go.erb | 87 ------------------- ... => resource_vmwareengine_network_test.go} | 11 +-- .../docs/d/vmwareengine_network.html.markdown | 4 - 10 files changed, 68 insertions(+), 108 deletions(-) create mode 100644 mmv1/templates/terraform/examples/vmware_engine_network_standard.tf.erb rename mmv1/third_party/terraform/services/vmwareengine/{data_source_google_vmwareengine_network.go.erb => data_source_google_vmwareengine_network.go} (94%) create mode 100644 mmv1/third_party/terraform/services/vmwareengine/data_source_google_vmwareengine_network_test.go delete mode 100644 mmv1/third_party/terraform/services/vmwareengine/data_source_google_vmwareengine_network_test.go.erb rename mmv1/third_party/terraform/services/vmwareengine/{resource_vmwareengine_network_test.go.erb => resource_vmwareengine_network_test.go} (92%) diff --git a/mmv1/products/vmwareengine/Network.yaml b/mmv1/products/vmwareengine/Network.yaml index 16c4dee0f92f..8d260ac7dccb 100644 --- a/mmv1/products/vmwareengine/Network.yaml +++ b/mmv1/products/vmwareengine/Network.yaml @@ -14,7 +14,6 @@ --- !ruby/object:Api::Resource name: "Network" -min_version: beta base_url: "projects/{{project}}/locations/{{location}}/vmwareEngineNetworks" self_link: "projects/{{project}}/locations/{{location}}/vmwareEngineNetworks/{{name}}" create_url: "projects/{{project}}/locations/{{location}}/vmwareEngineNetworks?vmwareEngineNetworkId={{name}}" @@ -45,11 +44,14 @@ import_format: ["projects/{{project}}/locations/{{location}}/vmwareEngineNetworks/{{name}}"] autogen_async: true examples: + - !ruby/object:Provider::Terraform::Examples + name: "vmware_engine_network_standard" + primary_resource_id: "vmw-engine-network" - !ruby/object:Provider::Terraform::Examples name: "vmware_engine_network_legacy" pull_external: true - min_version: beta primary_resource_id: "vmw-engine-network" + skip_test: true # update tests will take care of create and update. Legacy network needs to be created on an isolated project. vars: proj_id: "vmw-proj" test_env_vars: @@ -119,6 +121,7 @@ properties: VMware Engine network type. values: - :LEGACY + - :STANDARD - !ruby/object:Api::Type::String name: "uid" diff --git a/mmv1/products/vmwareengine/product.yaml b/mmv1/products/vmwareengine/product.yaml index 5d6e08562005..4e2c2b4f8663 100644 --- a/mmv1/products/vmwareengine/product.yaml +++ b/mmv1/products/vmwareengine/product.yaml @@ -15,6 +15,9 @@ name: Vmwareengine display_name: Cloud VMware Engine versions: + - !ruby/object:Api::Product::Version + name: ga + base_url: https://vmwareengine.googleapis.com/v1/ - !ruby/object:Api::Product::Version name: beta base_url: https://vmwareengine.googleapis.com/v1/ diff --git a/mmv1/templates/terraform/examples/vmware_engine_network_legacy.tf.erb b/mmv1/templates/terraform/examples/vmware_engine_network_legacy.tf.erb index 152363dbd104..04aa17580f98 100644 --- a/mmv1/templates/terraform/examples/vmware_engine_network_legacy.tf.erb +++ b/mmv1/templates/terraform/examples/vmware_engine_network_legacy.tf.erb @@ -30,4 +30,4 @@ resource "time_sleep" "wait_60_seconds" { depends_on = [google_project.acceptance] create_duration = "60s" -} +} \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/vmware_engine_network_standard.tf.erb b/mmv1/templates/terraform/examples/vmware_engine_network_standard.tf.erb new file mode 100644 index 000000000000..1c889bb09f78 --- /dev/null +++ b/mmv1/templates/terraform/examples/vmware_engine_network_standard.tf.erb @@ -0,0 +1,6 @@ +resource "google_vmwareengine_network" "<%= ctx[:primary_resource_id] %>" { + name = "standard-nw" + location = "global" # Standard network needs to be global + type = "STANDARD" + description = "VMwareEngine standard network sample" +} diff --git a/mmv1/third_party/terraform/provider/provider_mmv1_resources.go.erb b/mmv1/third_party/terraform/provider/provider_mmv1_resources.go.erb index 14b20dc56094..6a06e716b915 100644 --- a/mmv1/third_party/terraform/provider/provider_mmv1_resources.go.erb +++ b/mmv1/third_party/terraform/provider/provider_mmv1_resources.go.erb @@ -196,8 +196,8 @@ var handwrittenDatasources = map[string]*schema.Resource{ "google_vpc_access_connector": vpcaccess.DataSourceVPCAccessConnector(), "google_redis_instance": redis.DataSourceGoogleRedisInstance(), "google_vertex_ai_index": vertexai.DataSourceVertexAIIndex(), - <% unless version == 'ga' -%> "google_vmwareengine_network": vmwareengine.DataSourceVmwareengineNetwork(), + <% unless version == 'ga' -%> "google_vmwareengine_private_cloud": vmwareengine.DataSourceVmwareenginePrivateCloud(), "google_vmwareengine_cluster": vmwareengine.DataSourceVmwareengineCluster(), <% end -%> diff --git a/mmv1/third_party/terraform/services/vmwareengine/data_source_google_vmwareengine_network.go.erb b/mmv1/third_party/terraform/services/vmwareengine/data_source_google_vmwareengine_network.go similarity index 94% rename from mmv1/third_party/terraform/services/vmwareengine/data_source_google_vmwareengine_network.go.erb rename to mmv1/third_party/terraform/services/vmwareengine/data_source_google_vmwareengine_network.go index 87465bef390a..dc6c0a8ce0aa 100644 --- a/mmv1/third_party/terraform/services/vmwareengine/data_source_google_vmwareengine_network.go.erb +++ b/mmv1/third_party/terraform/services/vmwareengine/data_source_google_vmwareengine_network.go @@ -1,6 +1,5 @@ -<% autogen_exception -%> package vmwareengine -<% unless version == 'ga' -%> + import ( "fmt" @@ -14,7 +13,6 @@ func DataSourceVmwareengineNetwork() *schema.Resource { dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceVmwareengineNetwork().Schema) tpgresource.AddRequiredFieldsToSchema(dsSchema, "location", "name") tpgresource.AddOptionalFieldsToSchema(dsSchema, "project") - return &schema.Resource{ Read: dataSourceVmwareengineNetworkRead, Schema: dsSchema, @@ -40,4 +38,3 @@ func dataSourceVmwareengineNetworkRead(d *schema.ResourceData, meta interface{}) } return nil } -<% end -%> \ No newline at end of file diff --git a/mmv1/third_party/terraform/services/vmwareengine/data_source_google_vmwareengine_network_test.go b/mmv1/third_party/terraform/services/vmwareengine/data_source_google_vmwareengine_network_test.go new file mode 100644 index 000000000000..2f1685ae4f7f --- /dev/null +++ b/mmv1/third_party/terraform/services/vmwareengine/data_source_google_vmwareengine_network_test.go @@ -0,0 +1,49 @@ +package vmwareengine_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-provider-google/google/acctest" +) + +func TestAccDataSourceVmwareEngineNetwork_basic(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": acctest.RandString(t, 10), + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckVmwareengineNetworkDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccDataSourceVmwareEngineNetworkConfig(context), + Check: resource.ComposeTestCheckFunc( + acctest.CheckDataSourceStateMatchesResourceStateWithIgnores("data.google_vmwareengine_network.ds", "google_vmwareengine_network.nw", map[string]struct{}{}), + ), + }, + }, + }) +} + +func testAccDataSourceVmwareEngineNetworkConfig(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_vmwareengine_network" "nw" { + name = "tf-test-sample-network%{random_suffix}" + location = "global" # Standard network needs to be global + type = "STANDARD" + description = "VMwareEngine standard network sample" +} + +data "google_vmwareengine_network" "ds" { + name = google_vmwareengine_network.nw.name + location = "global" + depends_on = [ + google_vmwareengine_network.nw, + ] +} +`, context) +} diff --git a/mmv1/third_party/terraform/services/vmwareengine/data_source_google_vmwareengine_network_test.go.erb b/mmv1/third_party/terraform/services/vmwareengine/data_source_google_vmwareengine_network_test.go.erb deleted file mode 100644 index f5c534afedd0..000000000000 --- a/mmv1/third_party/terraform/services/vmwareengine/data_source_google_vmwareengine_network_test.go.erb +++ /dev/null @@ -1,87 +0,0 @@ -<% autogen_exception -%> -package vmwareengine_test -<% unless version == 'ga' -%> - -import ( - "github.com/hashicorp/terraform-provider-google/google/acctest" - "github.com/hashicorp/terraform-provider-google/google/envvar" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccDataSourceVmwareEngineNetwork_basic(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "region": envvar.GetTestRegionFromEnv(), - "random_suffix": acctest.RandString(t, 10), - "organization": envvar.GetTestOrgFromEnv(t), - "billing_account": envvar.GetTestBillingAccountFromEnv(t), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), - CheckDestroy: testAccCheckVmwareengineNetworkDestroyProducer(t), - ExternalProviders: map[string]resource.ExternalProvider{ - "time": {}, - }, - Steps: []resource.TestStep{ - { - Config: testAccDataSourceVmwareEngineNetworkConfig(context), - Check: resource.ComposeTestCheckFunc( - acctest.CheckDataSourceStateMatchesResourceStateWithIgnores("data.google_vmwareengine_network.ds", "google_vmwareengine_network.nw", map[string]struct{}{}), - ), - }, - }, - }) -} - -func testAccDataSourceVmwareEngineNetworkConfig(context map[string]interface{}) string { - return acctest.Nprintf(` - # there can be only 1 Legacy network per region for a given project, so creating new project to isolate tests. -resource "google_project" "acceptance" { - name = "tf-test-%{random_suffix}" - provider = google-beta - project_id = "tf-test-%{random_suffix}" - org_id = "%{organization}" - billing_account = "%{billing_account}" -} - -resource "google_project_service" "acceptance" { - project = google_project.acceptance.project_id - provider = google-beta - service = "vmwareengine.googleapis.com" - - # Needed for CI tests for permissions to propagate, should not be needed for actual usage - depends_on = [time_sleep.wait_60_seconds] -} - -resource "time_sleep" "wait_60_seconds" { - depends_on = [google_project.acceptance] - - create_duration = "60s" -} - -resource "google_vmwareengine_network" "nw" { - project = google_project_service.acceptance.project - name = "%{region}-default" #Legacy network IDs are in the format: {region-id}-default - provider = google-beta - location = "%{region}" - type = "LEGACY" - description = "VMwareEngine legacy network sample" -} - -data "google_vmwareengine_network" "ds" { - name = google_vmwareengine_network.nw.name - project = google_project_service.acceptance.project - provider = google-beta - location = "%{region}" - depends_on = [ - google_vmwareengine_network.nw, - ] -} -`, context) -} -<% end -%> \ No newline at end of file diff --git a/mmv1/third_party/terraform/services/vmwareengine/resource_vmwareengine_network_test.go.erb b/mmv1/third_party/terraform/services/vmwareengine/resource_vmwareengine_network_test.go similarity index 92% rename from mmv1/third_party/terraform/services/vmwareengine/resource_vmwareengine_network_test.go.erb rename to mmv1/third_party/terraform/services/vmwareengine/resource_vmwareengine_network_test.go index b06c33be4b2b..521210061b86 100644 --- a/mmv1/third_party/terraform/services/vmwareengine/resource_vmwareengine_network_test.go.erb +++ b/mmv1/third_party/terraform/services/vmwareengine/resource_vmwareengine_network_test.go @@ -1,15 +1,12 @@ -<% autogen_exception -%> package vmwareengine_test -<% unless version == 'ga' -%> import ( "fmt" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-provider-google/google/acctest" "github.com/hashicorp/terraform-provider-google/google/envvar" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccVmwareengineNetwork_vmwareEngineNetworkUpdate(t *testing.T) { @@ -24,7 +21,7 @@ func TestAccVmwareengineNetwork_vmwareEngineNetworkUpdate(t *testing.T) { configTemplate := vmwareEngineNetworkConfigTemplate(context) acctest.VcrTest(t, resource.TestCase{ PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), CheckDestroy: testAccCheckVmwareengineNetworkDestroyProducer(t), ExternalProviders: map[string]resource.ExternalProvider{ "random": {}, @@ -56,7 +53,6 @@ func TestAccVmwareengineNetwork_vmwareEngineNetworkUpdate(t *testing.T) { func vmwareEngineNetworkConfigTemplate(context map[string]interface{}) string { return acctest.Nprintf(` resource "google_vmwareengine_network" "default-nw" { - provider = google-beta project = google_project_service.acceptance.project name = "%{region}-default" location = "%{region}" @@ -67,7 +63,6 @@ resource "google_vmwareengine_network" "default-nw" { # there can be only 1 Legacy network per region for a given project, so creating new project to isolate tests. resource "google_project" "acceptance" { name = "tf-test-%{random_suffix}" - provider = google-beta project_id = "tf-test-%{random_suffix}" org_id = "%{organization}" billing_account = "%{billing_account}" @@ -75,7 +70,6 @@ resource "google_project" "acceptance" { resource "google_project_service" "acceptance" { project = google_project.acceptance.project_id - provider = google-beta service = "vmwareengine.googleapis.com" # Needed for CI tests for permissions to propagate, should not be needed for actual usage @@ -89,4 +83,3 @@ resource "time_sleep" "wait_60_seconds" { } `, context) } -<% end -%> \ No newline at end of file diff --git a/mmv1/third_party/terraform/website/docs/d/vmwareengine_network.html.markdown b/mmv1/third_party/terraform/website/docs/d/vmwareengine_network.html.markdown index 6870f7a4080d..2b6a98a48d4b 100644 --- a/mmv1/third_party/terraform/website/docs/d/vmwareengine_network.html.markdown +++ b/mmv1/third_party/terraform/website/docs/d/vmwareengine_network.html.markdown @@ -8,9 +8,6 @@ description: |- Use this data source to get details about a VMwareEngine network resource. -~> **Warning:** This data source is in beta, and should be used with the terraform-provider-google-beta provider. -See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. - To get more information about VMwareEngine Network, see: * [API documentation](https://cloud.google.com/vmware-engine/docs/reference/rest/v1/projects.locations.vmwareEngineNetworks) @@ -18,7 +15,6 @@ To get more information about VMwareEngine Network, see: ```hcl data "google_vmwareengine_network" "my_nw" { - provider = google-beta name = "us-central1-default" location = "us-central1" }