From e61af2ad0bb4f99b3fec60de93592dcc84bf0eb0 Mon Sep 17 00:00:00 2001 From: Cameron Thornton Date: Mon, 9 Sep 2024 07:39:37 -0500 Subject: [PATCH] move go file --- .../folder_access_approval_full.tf.tmpl | 6 +- .../go/folder_access_approval_full.tf.tmpl | 14 - ...p_engine_flexible_app_version_test.go.tmpl | 445 ------------------ ...p_engine_flexible_app_version_test.go.tmpl | 5 +- 4 files changed, 5 insertions(+), 465 deletions(-) delete mode 100644 mmv1/templates/terraform/examples/go/folder_access_approval_full.tf.tmpl delete mode 100644 mmv1/third_party/terraform/services/appengine/go/resource_app_engine_flexible_app_version_test.go.tmpl diff --git a/mmv1/templates/terraform/examples/folder_access_approval_full.tf.tmpl b/mmv1/templates/terraform/examples/folder_access_approval_full.tf.tmpl index 140550f5a161..fc08b3dee4f8 100644 --- a/mmv1/templates/terraform/examples/folder_access_approval_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/folder_access_approval_full.tf.tmpl @@ -1,10 +1,10 @@ resource "google_folder" "my_folder" { - display_name = "<%= ctx[:vars]['folder_name'] %>" - parent = "organizations/<%= ctx[:test_env_vars]['org_id'] %>" + display_name = "{{index $.Vars "folder_name"}}" + parent = "organizations/{{index $.TestEnvVars "org_id"}}" deletion_protection = false } -resource "google_folder_access_approval_settings" "<%= ctx[:primary_resource_id] %>" { +resource "google_folder_access_approval_settings" "{{$.PrimaryResourceId}}" { folder_id = google_folder.my_folder.folder_id notification_emails = ["testuser@example.com", "example.user@example.com"] diff --git a/mmv1/templates/terraform/examples/go/folder_access_approval_full.tf.tmpl b/mmv1/templates/terraform/examples/go/folder_access_approval_full.tf.tmpl deleted file mode 100644 index fc08b3dee4f8..000000000000 --- a/mmv1/templates/terraform/examples/go/folder_access_approval_full.tf.tmpl +++ /dev/null @@ -1,14 +0,0 @@ -resource "google_folder" "my_folder" { - display_name = "{{index $.Vars "folder_name"}}" - parent = "organizations/{{index $.TestEnvVars "org_id"}}" - deletion_protection = false -} - -resource "google_folder_access_approval_settings" "{{$.PrimaryResourceId}}" { - folder_id = google_folder.my_folder.folder_id - notification_emails = ["testuser@example.com", "example.user@example.com"] - - enrolled_services { - cloud_product = "all" - } -} diff --git a/mmv1/third_party/terraform/services/appengine/go/resource_app_engine_flexible_app_version_test.go.tmpl b/mmv1/third_party/terraform/services/appengine/go/resource_app_engine_flexible_app_version_test.go.tmpl deleted file mode 100644 index 141be1e2be7d..000000000000 --- a/mmv1/third_party/terraform/services/appengine/go/resource_app_engine_flexible_app_version_test.go.tmpl +++ /dev/null @@ -1,445 +0,0 @@ -package appengine_test - -{{ if ne $.TargetVersionName `ga` -}} - -import ( - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-google/google/acctest" - "github.com/hashicorp/terraform-provider-google/google/envvar" -) - -func TestAccAppEngineFlexibleAppVersion_update(t *testing.T) { - t.Skip("https://github.com/hashicorp/terraform-provider-google/issues/18239") - t.Parallel() - - context := map[string]interface{}{ - "org_id": envvar.GetTestOrgFromEnv(t), - "billing_account": envvar.GetTestBillingAccountFromEnv(t), - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), - CheckDestroy: testAccCheckAppEngineFlexibleAppVersionDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccAppEngineFlexibleAppVersion_python(context), - }, - { - ResourceName: "google_app_engine_flexible_app_version.foo", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"env_variables", "deployment", "entrypoint", "service", "noop_on_destroy"}, - }, - { - Config: testAccAppEngineFlexibleAppVersion_pythonUpdate(context), - }, - { - ResourceName: "google_app_engine_flexible_app_version.foo", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"env_variables", "deployment", "entrypoint", "service", "delete_service_on_destroy"}, - }, - }, - }) -} - -func testAccAppEngineFlexibleAppVersion_python(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_project" "my_project" { - provider = google-beta - name = "tf-test-appeng-flex%{random_suffix}" - project_id = "tf-test-appeng-flex%{random_suffix}" - org_id = "%{org_id}" - billing_account = "%{billing_account}" - deletion_policy = "DELETE" -} - -resource "google_project_service" "compute" { - provider = google-beta - project = google_project.my_project.project_id - service = "compute.googleapis.com" - - disable_dependent_services = false -} - -resource "google_project_service" "appengineflex" { - provider = google-beta - project = google_project.my_project.project_id - service = "appengineflex.googleapis.com" - - disable_dependent_services = false - depends_on = [google_project_service.compute] -} - -resource "google_compute_network" "network" { - provider = google-beta - project = google_project_service.compute.project - name = "custom" - auto_create_subnetworks = "false" -} - -resource "google_compute_subnetwork" "subnetwork" { - provider = google-beta - project = google_project_service.compute.project - name = "custom" - region = "us-central1" - network = google_compute_network.network.id - ip_cidr_range = "10.0.0.0/16" - private_ip_google_access = true -} - -resource "google_app_engine_application" "app" { - provider = google-beta - project = google_project.my_project.project_id - location_id = "us-central" -} - -resource "google_project_iam_member" "gae_api" { - provider = google-beta - project = google_project_service.appengineflex.project - role = "roles/compute.networkUser" - member = "serviceAccount:service-${google_project.my_project.number}@gae-api-prod.google.com.iam.gserviceaccount.com" -} - -resource "google_app_engine_standard_app_version" "foo" { - provider = google-beta - project = google_project_iam_member.gae_api.project - version_id = "v1" - service = "default" - runtime = "python38" - - entrypoint { - shell = "gunicorn -b :$PORT main:app" - } - - deployment { - files { - name = "main.py" - source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.main.name}" - } - - files { - name = "requirements.txt" - source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.requirements.name}" - } - } - - env_variables = { - port = "8000" - } - - noop_on_destroy = true -} - -resource "google_app_engine_flexible_app_version" "foo" { - provider = google-beta - project = google_project_iam_member.gae_api.project - version_id = "v1" - service = "custom" - runtime = "python" - - runtime_api_version = "1" - - resources { - cpu = 1 - memory_gb = 0.5 - disk_gb = 10 - } - - entrypoint { - shell = "gunicorn -b :$PORT main:app" - } - - flexible_runtime_settings { - operating_system = "ubuntu22" - runtime_version = "3.11" - } - - deployment { - files { - name = "main.py" - source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.main.name}" - } - - files { - name = "requirements.txt" - source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.requirements.name}" - } - - files { - name = "app.yaml" - source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.yaml.name}" - } - } - - liveness_check { - path = "alive" - } - - readiness_check { - path = "ready" - } - - env_variables = { - port = "8000" - } - - network { - name = google_compute_network.network.name - subnetwork = google_compute_subnetwork.subnetwork.name - instance_ip_mode = "EXTERNAL" - } - - instance_class = "B1" - - manual_scaling { - instances = 1 - } - - noop_on_destroy = true - - depends_on = [google_app_engine_standard_app_version.foo] -} - -resource "google_storage_bucket" "bucket" { - provider = google-beta - project = google_project.my_project.project_id - name = "tf-test-%{random_suffix}-flex-ae-bucket" - location = "US" -} - -resource "google_storage_bucket_object" "yaml" { - provider = google-beta - name = "app.yaml" - bucket = google_storage_bucket.bucket.name - source = "./test-fixtures/hello-world-flask/app.yaml" -} - -resource "google_storage_bucket_object" "requirements" { - provider = google-beta - name = "requirements.txt" - bucket = google_storage_bucket.bucket.name - source = "./test-fixtures/hello-world-flask/requirements.txt" -} - -resource "google_storage_bucket_object" "main" { - provider = google-beta - name = "main.py" - bucket = google_storage_bucket.bucket.name - source = "./test-fixtures/hello-world-flask/main.py" -}`, context) -} - -func testAccAppEngineFlexibleAppVersion_pythonUpdate(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_project" "my_project" { - provider = google-beta - name = "tf-test-appeng-flex%{random_suffix}" - project_id = "tf-test-appeng-flex%{random_suffix}" - org_id = "%{org_id}" - billing_account = "%{billing_account}" - deletion_policy = "DELETE" -} - -resource "google_project_service" "compute" { - provider = google-beta - project = google_project.my_project.project_id - service = "compute.googleapis.com" - - disable_dependent_services = false -} - -resource "google_project_service" "appengineflex" { - provider = google-beta - project = google_project.my_project.project_id - service = "appengineflex.googleapis.com" - - disable_dependent_services = false - depends_on = [google_project_service.compute] -} - -resource "google_compute_network" "network" { - provider = google-beta - project = google_project_service.compute.project - name = "custom" - auto_create_subnetworks = "false" -} - -resource "google_compute_subnetwork" "subnetwork" { - provider = google-beta - project = google_project_service.compute.project - name = "custom" - region = "us-central1" - network = google_compute_network.network.id - ip_cidr_range = "10.0.0.0/16" - private_ip_google_access = true -} - -resource "google_app_engine_application" "app" { - provider = google-beta - project = google_project.my_project.project_id - location_id = "us-central" -} - -resource "google_project_iam_member" "gae_api" { - provider = google-beta - project = google_project_service.appengineflex.project - role = "roles/compute.networkUser" - member = "serviceAccount:service-${google_project.my_project.number}@gae-api-prod.google.com.iam.gserviceaccount.com" -} - -resource "google_app_engine_standard_app_version" "foo" { - provider = google-beta - project = google_project_iam_member.gae_api.project - version_id = "v1" - service = "default" - runtime = "python38" - - entrypoint { - shell = "gunicorn -b :$PORT main:app" - } - - deployment { - files { - name = "main.py" - source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.main.name}" - } - - files { - name = "requirements.txt" - source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.requirements.name}" - } - } - - env_variables = { - port = "8000" - } - - noop_on_destroy = true -} - -resource "google_app_engine_flexible_app_version" "foo" { - provider = google-beta - project = google_project_iam_member.gae_api.project - version_id = "v1" - service = "custom" - runtime = "python" - - runtime_api_version = "1" - - resources { - cpu = 1 - memory_gb = 1 - disk_gb = 10 - } - - entrypoint { - shell = "gunicorn -b :$PORT main:app" - } - - flexible_runtime_settings { - operating_system = "ubuntu22" - runtime_version = "3.11" - } - - deployment { - files { - name = "main.py" - source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.main.name}" - } - - files { - name = "requirements.txt" - source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.requirements.name}" - } - - files { - name = "app.yaml" - source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.yaml.name}" - } - } - - liveness_check { - path = "" - } - - readiness_check { - path = "" - } - - env_variables = { - port = "8000" - } - - network { - name = google_compute_network.network.name - subnetwork = google_compute_subnetwork.subnetwork.name - instance_ip_mode = "INTERNAL" - } - - instance_class = "B2" - - manual_scaling { - instances = 2 - } - - delete_service_on_destroy = true - - depends_on = [google_app_engine_standard_app_version.foo] -} - -resource "google_storage_bucket" "bucket" { - provider = google-beta - project = google_project.my_project.project_id - name = "tf-test-%{random_suffix}-flex-ae-bucket" - location = "US" -} - -resource "google_storage_bucket_object" "yaml" { - provider = google-beta - name = "app.yaml" - bucket = google_storage_bucket.bucket.name - source = "./test-fixtures/hello-world-flask/app.yaml" -} - -resource "google_storage_bucket_object" "requirements" { - provider = google-beta - name = "requirements.txt" - bucket = google_storage_bucket.bucket.name - source = "./test-fixtures/hello-world-flask/requirements.txt" -} - -resource "google_storage_bucket_object" "main" { - provider = google-beta - name = "main.py" - bucket = google_storage_bucket.bucket.name - source = "./test-fixtures/hello-world-flask/main.py" -}`, context) -} - -// Remove when generated test is enabled -func testAccCheckAppEngineFlexibleAppVersionDestroyProducer(t *testing.T) func(s *terraform.State) error { - return func(s *terraform.State) error { - for name, rs := range s.RootModule().Resources { - if rs.Type != "google_app_engine_flexible_app_version" { - continue - } - if strings.HasPrefix(name, "data.") { - continue - } - - log.Printf("[DEBUG] Ignoring destroy during test") - } - - return nil - } -} - -{{ end }} diff --git a/mmv1/third_party/terraform/services/appengine/resource_app_engine_flexible_app_version_test.go.tmpl b/mmv1/third_party/terraform/services/appengine/resource_app_engine_flexible_app_version_test.go.tmpl index bd3832d48dd1..141be1e2be7d 100644 --- a/mmv1/third_party/terraform/services/appengine/resource_app_engine_flexible_app_version_test.go.tmpl +++ b/mmv1/third_party/terraform/services/appengine/resource_app_engine_flexible_app_version_test.go.tmpl @@ -1,7 +1,6 @@ -<% autogen_exception -%> package appengine_test -<% unless version == 'ga' -%> +{{ if ne $.TargetVersionName `ga` -}} import ( "log" @@ -443,4 +442,4 @@ func testAccCheckAppEngineFlexibleAppVersionDestroyProducer(t *testing.T) func(s } } -<% end -%> +{{ end }}