Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add standard type vmwareengine network #9416

Merged
merged 5 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions mmv1/products/vmwareengine/Network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -119,6 +121,7 @@ properties:
VMware Engine network type.
values:
- :LEGACY
- :STANDARD

- !ruby/object:Api::Type::String
name: "uid"
Expand Down
3 changes: 3 additions & 0 deletions mmv1/products/vmwareengine/product.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ resource "time_sleep" "wait_60_seconds" {
depends_on = [google_project.acceptance]

create_duration = "60s"
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<% autogen_exception -%>
package vmwareengine
<% unless version == 'ga' -%>

import (
"fmt"

Expand All @@ -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,
Expand All @@ -40,4 +38,3 @@ func dataSourceVmwareengineNetworkRead(d *schema.ResourceData, meta interface{})
}
return nil
}
<% end -%>
Original file line number Diff line number Diff line change
@@ -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)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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": {},
Expand Down Expand Up @@ -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}"
Expand All @@ -67,15 +63,13 @@ 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}"
}

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
Expand All @@ -89,4 +83,3 @@ resource "time_sleep" "wait_60_seconds" {
}
`, context)
}
<% end -%>
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ 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)

## Example Usage

```hcl
data "google_vmwareengine_network" "my_nw" {
provider = google-beta
name = "us-central1-default"
location = "us-central1"
}
Expand Down