From 36592559da7fd8e03315aa1b92b9993cf8f7ce6d Mon Sep 17 00:00:00 2001 From: Esha Goel Date: Tue, 27 Feb 2024 05:33:41 +0000 Subject: [PATCH 1/9] Add new resource for Application for Apphub --- mmv1/products/apphub/Application.yaml | 199 +++++++++++ mmv1/products/apphub/product.yaml | 23 ++ .../examples/apphub_application_basic.tf.erb | 7 + .../examples/apphub_application_full.tf.erb | 29 ++ .../apphub/resource_application_test.go | 320 ++++++++++++++++++ 5 files changed, 578 insertions(+) create mode 100644 mmv1/products/apphub/Application.yaml create mode 100644 mmv1/products/apphub/product.yaml create mode 100644 mmv1/templates/terraform/examples/apphub_application_basic.tf.erb create mode 100644 mmv1/templates/terraform/examples/apphub_application_full.tf.erb create mode 100644 mmv1/third_party/terraform/services/apphub/resource_application_test.go diff --git a/mmv1/products/apphub/Application.yaml b/mmv1/products/apphub/Application.yaml new file mode 100644 index 000000000000..6f462f68e4cd --- /dev/null +++ b/mmv1/products/apphub/Application.yaml @@ -0,0 +1,199 @@ +# Copyright 2024 Google Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- !ruby/object:Api::Resource +base_url: projects/{{project}}/locations/{{location}}/applications +create_url: projects/{{project}}/locations/{{location}}/applications?applicationId={{application_id}} +self_link: projects/{{project}}/locations/{{location}}/applications/{{application_id}} +id_format: projects/{{project}}/locations/{{location}}/applications/{{application_id}} +import_format: + - projects/{{project}}/locations/{{location}}/applications/{{application_id}} +name: Application +description: Description +autogen_async: true +examples: + - !ruby/object:Provider::Terraform::Examples + name: "application_basic" + primary_resource_id: "example" + config_path: "templates/terraform/examples/apphub_application_basic.tf.erb" + skip_test: true + vars: + location: "us-east1" + application_id: "example-application" + scope_type: "REGIONAL" + - !ruby/object:Provider::Terraform::Examples + name: "application_basic" + primary_resource_id: "example" + config_path: "templates/terraform/examples/apphub_application_basic.tf.erb" + skip_docs: true + vars: + application_id: "example-application" + - !ruby/object:Provider::Terraform::Examples + name: "application_full" + primary_resource_id: "example2" + config_path: "templates/terraform/examples/apphub_application_full.tf.erb" + vars: + application_id: "example-application" + display_name: "Application Full" + description: "Application for testing" + business_name: "Alice" + business_email: "alice@google.com" + developer_name: "Bob" + developer_email: "bob@google.com" + operator_name: "Charlie" + operator_email: "charlie@google.com" +properties: + - !ruby/object:Api::Type::String + name: name + output: true + description: "Identifier. The resource name of an Application. Format:\n\"projects/{host-project-id}/locations/{location}/applications/{application-id}\" " + - !ruby/object:Api::Type::String + name: displayName + description: 'Optional. User-defined name for the Application. ' + - !ruby/object:Api::Type::String + name: description + description: 'Optional. User-defined description of an Application. ' + - !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::Enum + name: type + description: 'Criticality type. ' + required: true + values: + - :TYPE_UNSPECIFIED + - :MISSION_CRITICAL + - :HIGH + - :MEDIUM + - :LOW + name: criticality + description: 'Criticality of the Application, Service, or Workload ' + - !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::Enum + name: type + description: 'Environment type. ' + required: true + values: + - :TYPE_UNSPECIFIED + - :PRODUCTION + - :STAGING + - :TEST + - :DEVELOPMENT + name: environment + description: 'Environment of the Application, Service, or Workload ' + - !ruby/object:Api::Type::Array + name: developerOwners + item_type: !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::String + name: displayName + description: 'Optional. Contact''s name. ' + - !ruby/object:Api::Type::String + name: email + description: 'Required. Email address of the contacts. ' + required: true + description: 'Optional. Developer team that owns development and coding. ' + - !ruby/object:Api::Type::Array + name: operatorOwners + item_type: !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::String + name: displayName + description: 'Optional. Contact''s name. ' + - !ruby/object:Api::Type::String + name: email + description: 'Required. Email address of the contacts. ' + description: 'Optional. Operator team that ensures runtime and operations. ' + - !ruby/object:Api::Type::Array + name: businessOwners + item_type: !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::String + name: displayName + description: 'Optional. Contact''s name. ' + - !ruby/object:Api::Type::String + name: email + description: 'Required. Email address of the contacts. ' + description: 'Optional. Business team that ensures user needs are met and value + is delivered ' + name: attributes + description: 'Consumer provided attributes. ' + - !ruby/object:Api::Type::String + name: createTime + description: 'Output only. Create time. ' + output: true + - !ruby/object:Api::Type::String + name: updateTime + description: 'Output only. Update time. ' + output: true + - !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::Enum + name: type + description: "Required. Scope Type. \n Possible values:\n TYPE_UNSPECIFIED\nREGIONAL" + required: true + values: + - :TYPE_UNSPECIFIED + - :REGIONAL + name: scope + description: 'Scope of an application. ' + required: true + - !ruby/object:Api::Type::String + name: uid + description: 'Output only. A universally unique identifier (in UUID4 format) for + the `Application`. ' + output: true + - !ruby/object:Api::Type::Enum + name: state + description: "Output only. Application state. \n Possible values:\n STATE_UNSPECIFIED\nCREATING\nACTIVE\nDELETING" + output: true + values: + - :STATE_UNSPECIFIED + - :CREATING + - :ACTIVE + - :DELETING +parameters: + - !ruby/object:Api::Type::String + name: location + description: 'Part of `parent`. See documentation of `projectsId`. ' + url_param_only: true + required: true + immutable: true + - !ruby/object:Api::Type::String + name: applicationId + description: 'Required. The Application identifier. ' + url_param_only: true + required: true + immutable: true +async: !ruby/object:Api::OpAsync + operation: !ruby/object:Api::OpAsync::Operation + path: name + base_url: "{{op_id}}" + wait_ms: 1000 + timeouts: + result: !ruby/object:Api::OpAsync::Result + path: response + resource_inside_response: true + status: !ruby/object:Api::OpAsync::Status + path: done + complete: true + allowed: + - true + - false + error: !ruby/object:Api::OpAsync::Error + path: error + message: message +update_verb: :PATCH +update_mask: true diff --git a/mmv1/products/apphub/product.yaml b/mmv1/products/apphub/product.yaml new file mode 100644 index 000000000000..4df439355736 --- /dev/null +++ b/mmv1/products/apphub/product.yaml @@ -0,0 +1,23 @@ +# Copyright 2024 Google Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +--- !ruby/object:Api::Product +name: Apphub +display_name: App Hub +versions: + - !ruby/object:Api::Product::Version + name: ga + base_url: https://apphub.googleapis.com/v1/ +scopes: + - https://www.googleapis.com/auth/cloud-platform diff --git a/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb b/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb new file mode 100644 index 000000000000..7b7c50231dca --- /dev/null +++ b/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb @@ -0,0 +1,7 @@ +resource "google_apphub_application" "<%= ctx[:primary_resource_id] %>" { + location = "us-east1" + application_id = "<%= ctx[:vars]['application_id'] %>" + scope { + type = "REGIONAL" + } +} diff --git a/mmv1/templates/terraform/examples/apphub_application_full.tf.erb b/mmv1/templates/terraform/examples/apphub_application_full.tf.erb new file mode 100644 index 000000000000..42d9de520464 --- /dev/null +++ b/mmv1/templates/terraform/examples/apphub_application_full.tf.erb @@ -0,0 +1,29 @@ +resource "google_apphub_application" "<%= ctx[:primary_resource_id] %>" { + location = "us-east1" + application_id = "<%= ctx[:vars]['application_id'] %>" + display_name = "<%= ctx[:vars]['display_name'] %>" + scope { + type = "REGIONAL" + } + description = "<%= ctx[:vars]['description'] %>" + attributes { + environment { + type = "STAGING" + } + criticality { + type = "MISSION_CRITICAL" + } + business_owners { + display_name = "<%= ctx[:vars]['business_name'] %>" + email = "<%= ctx[:vars]['business_email'] %>" + } + developer_owners { + display_name = "<%= ctx[:vars]['developer_name'] %>" + email = "<%= ctx[:vars]['developer_email'] %>" + } + operator_owners { + display_name = "<%= ctx[:vars]['operator_name'] %>" + email = "<%= ctx[:vars]['operator_email'] %>" + } + } +} diff --git a/mmv1/third_party/terraform/services/apphub/resource_application_test.go b/mmv1/third_party/terraform/services/apphub/resource_application_test.go new file mode 100644 index 000000000000..7a2766d0159d --- /dev/null +++ b/mmv1/third_party/terraform/services/apphub/resource_application_test.go @@ -0,0 +1,320 @@ +package apphub_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + "github.com/hashicorp/terraform-provider-google/google/acctest" +) + +func TestAccApphubApplication_applicationUpdateBasic(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: testAccCheckApphubApplicationDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccApphubApplication_applicationBasicExample(context), + }, + { + ResourceName: "google_apphub_application.example", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"location", "application_id"}, + }, + { + Config: testAccApphubApplication_applicationUpdateBasic(context), + }, + { + ResourceName: "google_apphub_application.example", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"location", "application_id"}, + }, + }, + }) +} + +func testAccApphubApplication_applicationUpdateBasic(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_apphub_application" "example" { + location = "us-east1" + application_id = "tf-test-example-application-2%{random_suffix}" + scope { + type = "REGIONAL" + } +} +`, context) +} + +func TestAccApphubApplication_applicationUpdateFull(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: testAccCheckApphubApplicationDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccApphubApplication_applicationFullExample(context), + }, + { + ResourceName: "google_apphub_application.example2", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"location", "application_id"}, + }, + { + Config: testAccApphubApplication_applicationUpdateFull(context), + }, + { + ResourceName: "google_apphub_application.example2", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"location", "application_id"}, + }, + }, + }) +} + +func testAccApphubApplication_applicationUpdateFull(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_apphub_application" "example2" { + location = "us-east1" + application_id = "tf-test-example-application-2%{random_suffix}" + display_name = "Application Full%{random_suffix}" + description = "Application for testing" + scope { + type = "REGIONAL" + } + attributes { + environment { + type = "STAGING" + } + criticality { + type = "MISSION_CRITICAL" + } + business_owners { + display_name = "Alice%{random_suffix}" + email = "alice@google.com%{random_suffix}" + } + developer_owners { + display_name = "Bob%{random_suffix}" + email = "bob@google.com%{random_suffix}" + } + operator_owners { + display_name = "Charlie%{random_suffix}" + email = "charlie@google.com%{random_suffix}" + } + } +} +`, context) +} + +func TestAccApphubApplication_applicationUpdateAttributes(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: testAccCheckApphubApplicationDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccApphubApplication_applicationFullExample(context), + }, + { + ResourceName: "google_apphub_application.example2", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"location", "application_id"}, + }, + { + Config: testAccApphubApplication_applicationUpdateDisplayName(context), + }, + { + ResourceName: "google_apphub_application.example2", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"location", "application_id"}, + }, + { + Config: testAccApphubApplication_applicationUpdateEnvironment(context), + }, + { + ResourceName: "google_apphub_application.example2", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"location", "application_id"}, + }, + { + Config: testAccApphubApplication_applicationUpdateCriticality(context), + }, + { + ResourceName: "google_apphub_application.example2", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"location", "application_id"}, + }, + { + Config: testAccApphubApplication_applicationUpdateOwners(context), + }, + { + ResourceName: "google_apphub_application.example2", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"location", "application_id"}, + }, + }, + }) +} + +func testAccApphubApplication_applicationUpdateDisplayName(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_apphub_application" "example2" { + location = "us-east1" + application_id = "tf-test-example-application%{random_suffix}" + display_name = "Application Full New%{random_suffix}" + scope { + type = "REGIONAL" + } + attributes { + environment { + type = "STAGING" + } + criticality { + type = "MISSION_CRITICAL" + } + business_owners { + display_name = "Alice%{random_suffix}" + email = "alice@google.com%{random_suffix}" + } + developer_owners { + display_name = "Bob%{random_suffix}" + email = "bob@google.com%{random_suffix}" + } + operator_owners { + display_name = "Charlie%{random_suffix}" + email = "charlie@google.com%{random_suffix}" + } + } +} +`, context) +} + +func testAccApphubApplication_applicationUpdateEnvironment(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_apphub_application" "example2" { + location = "us-east1" + application_id = "tf-test-example-application%{random_suffix}" + display_name = "Application Full New%{random_suffix}" + scope { + type = "REGIONAL" + } + attributes { + environment { + type = "TEST" + } + criticality { + type = "MISSION_CRITICAL" + } + business_owners { + display_name = "Alice%{random_suffix}" + email = "alice@google.com%{random_suffix}" + } + developer_owners { + display_name = "Bob%{random_suffix}" + email = "bob@google.com%{random_suffix}" + } + operator_owners { + display_name = "Charlie%{random_suffix}" + email = "charlie@google.com%{random_suffix}" + } + } +} +`, context) +} + +func testAccApphubApplication_applicationUpdateCriticality(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_apphub_application" "example2" { + location = "us-east1" + application_id = "tf-test-example-application%{random_suffix}" + display_name = "Application Full New%{random_suffix}" + scope { + type = "REGIONAL" + } + attributes { + environment { + type = "TEST" + } + criticality { + type = "MEDIUM" + } + business_owners { + display_name = "Alice%{random_suffix}" + email = "alice@google.com%{random_suffix}" + } + developer_owners { + display_name = "Bob%{random_suffix}" + email = "bob@google.com%{random_suffix}" + } + operator_owners { + display_name = "Charlie%{random_suffix}" + email = "charlie@google.com%{random_suffix}" + } + } +} +`, context) +} + +func testAccApphubApplication_applicationUpdateOwners(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_apphub_application" "example2" { + location = "us-east1" + application_id = "tf-test-example-application%{random_suffix}" + display_name = "Application Full New%{random_suffix}" + scope { + type = "REGIONAL" + } + attributes { + environment { + type = "TEST" + } + criticality { + type = "MEDIUM" + } + business_owners { + display_name = "Alice%{random_suffix}" + email = "alice@google.com%{random_suffix}" + } + developer_owners { + display_name = "Bob%{random_suffix}" + email = "bob@google.com%{random_suffix}" + } + developer_owners { + display_name = "Derek%{random_suffix}" + email = "derek@google.com%{random_suffix}" + } + operator_owners { + display_name = "Charlie%{random_suffix}" + email = "charlie@google.com%{random_suffix}" + } + } +} +`, context) +} From 4d6058100ca6b0c291736cb340a1ef1f354e5c23 Mon Sep 17 00:00:00 2001 From: Esha Goel Date: Tue, 27 Feb 2024 05:33:41 +0000 Subject: [PATCH 2/9] Add new resource for Application for Apphub --- .../examples/apphub_application_basic.tf.erb | 8 + .../examples/apphub_application_full.tf.erb | 8 + ...go => resource_apphub_application_test.go} | 146 ++++-------------- 3 files changed, 48 insertions(+), 114 deletions(-) rename mmv1/third_party/terraform/services/apphub/{resource_application_test.go => resource_apphub_application_test.go} (63%) diff --git a/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb b/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb index 7b7c50231dca..ee688f93a701 100644 --- a/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb +++ b/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb @@ -1,7 +1,15 @@ +data "google_project" "host_project" {} + +resource "google_project_service" "apphub" { + project = data.google_project.host_project.project_id + service = "apphub.googleapis.com" +} + resource "google_apphub_application" "<%= ctx[:primary_resource_id] %>" { location = "us-east1" application_id = "<%= ctx[:vars]['application_id'] %>" scope { type = "REGIONAL" } + depends_on = [google_project_service.apphub] } diff --git a/mmv1/templates/terraform/examples/apphub_application_full.tf.erb b/mmv1/templates/terraform/examples/apphub_application_full.tf.erb index 42d9de520464..14692f8fb176 100644 --- a/mmv1/templates/terraform/examples/apphub_application_full.tf.erb +++ b/mmv1/templates/terraform/examples/apphub_application_full.tf.erb @@ -1,3 +1,10 @@ +data "google_project" "host_project" {} + +resource "google_project_service" "apphub" { + project = data.google_project.host_project.project_id + service = "apphub.googleapis.com" +} + resource "google_apphub_application" "<%= ctx[:primary_resource_id] %>" { location = "us-east1" application_id = "<%= ctx[:vars]['application_id'] %>" @@ -26,4 +33,5 @@ resource "google_apphub_application" "<%= ctx[:primary_resource_id] %>" { email = "<%= ctx[:vars]['operator_email'] %>" } } + depends_on = [google_project_service.apphub] } diff --git a/mmv1/third_party/terraform/services/apphub/resource_application_test.go b/mmv1/third_party/terraform/services/apphub/resource_apphub_application_test.go similarity index 63% rename from mmv1/third_party/terraform/services/apphub/resource_application_test.go rename to mmv1/third_party/terraform/services/apphub/resource_apphub_application_test.go index 7a2766d0159d..65f5cb73422f 100644 --- a/mmv1/third_party/terraform/services/apphub/resource_application_test.go +++ b/mmv1/third_party/terraform/services/apphub/resource_apphub_application_test.go @@ -8,52 +8,6 @@ import ( "github.com/hashicorp/terraform-provider-google/google/acctest" ) -func TestAccApphubApplication_applicationUpdateBasic(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: testAccCheckApphubApplicationDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccApphubApplication_applicationBasicExample(context), - }, - { - ResourceName: "google_apphub_application.example", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "application_id"}, - }, - { - Config: testAccApphubApplication_applicationUpdateBasic(context), - }, - { - ResourceName: "google_apphub_application.example", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "application_id"}, - }, - }, - }) -} - -func testAccApphubApplication_applicationUpdateBasic(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_apphub_application" "example" { - location = "us-east1" - application_id = "tf-test-example-application-2%{random_suffix}" - scope { - type = "REGIONAL" - } -} -`, context) -} - func TestAccApphubApplication_applicationUpdateFull(t *testing.T) { t.Parallel() @@ -61,74 +15,6 @@ func TestAccApphubApplication_applicationUpdateFull(t *testing.T) { "random_suffix": acctest.RandString(t, 10), } - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckApphubApplicationDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccApphubApplication_applicationFullExample(context), - }, - { - ResourceName: "google_apphub_application.example2", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "application_id"}, - }, - { - Config: testAccApphubApplication_applicationUpdateFull(context), - }, - { - ResourceName: "google_apphub_application.example2", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "application_id"}, - }, - }, - }) -} - -func testAccApphubApplication_applicationUpdateFull(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_apphub_application" "example2" { - location = "us-east1" - application_id = "tf-test-example-application-2%{random_suffix}" - display_name = "Application Full%{random_suffix}" - description = "Application for testing" - scope { - type = "REGIONAL" - } - attributes { - environment { - type = "STAGING" - } - criticality { - type = "MISSION_CRITICAL" - } - business_owners { - display_name = "Alice%{random_suffix}" - email = "alice@google.com%{random_suffix}" - } - developer_owners { - display_name = "Bob%{random_suffix}" - email = "bob@google.com%{random_suffix}" - } - operator_owners { - display_name = "Charlie%{random_suffix}" - email = "charlie@google.com%{random_suffix}" - } - } -} -`, context) -} - -func TestAccApphubApplication_applicationUpdateAttributes(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), @@ -185,6 +71,13 @@ func TestAccApphubApplication_applicationUpdateAttributes(t *testing.T) { func testAccApphubApplication_applicationUpdateDisplayName(context map[string]interface{}) string { return acctest.Nprintf(` +data "google_project" "host_project" {} + +resource "google_project_service" "apphub" { + project = data.google_project.host_project.project_id + service = "apphub.googleapis.com" +} + resource "google_apphub_application" "example2" { location = "us-east1" application_id = "tf-test-example-application%{random_suffix}" @@ -212,12 +105,20 @@ resource "google_apphub_application" "example2" { email = "charlie@google.com%{random_suffix}" } } + depends_on = [google_project_service.apphub] } `, context) } func testAccApphubApplication_applicationUpdateEnvironment(context map[string]interface{}) string { return acctest.Nprintf(` +data "google_project" "host_project" {} + +resource "google_project_service" "apphub" { + project = data.google_project.host_project.project_id + service = "apphub.googleapis.com" +} + resource "google_apphub_application" "example2" { location = "us-east1" application_id = "tf-test-example-application%{random_suffix}" @@ -245,12 +146,20 @@ resource "google_apphub_application" "example2" { email = "charlie@google.com%{random_suffix}" } } + depends_on = [google_project_service.apphub] } `, context) } func testAccApphubApplication_applicationUpdateCriticality(context map[string]interface{}) string { return acctest.Nprintf(` +data "google_project" "host_project" {} + +resource "google_project_service" "apphub" { + project = data.google_project.host_project.project_id + service = "apphub.googleapis.com" +} + resource "google_apphub_application" "example2" { location = "us-east1" application_id = "tf-test-example-application%{random_suffix}" @@ -278,12 +187,20 @@ resource "google_apphub_application" "example2" { email = "charlie@google.com%{random_suffix}" } } + depends_on = [google_project_service.apphub] } `, context) } func testAccApphubApplication_applicationUpdateOwners(context map[string]interface{}) string { return acctest.Nprintf(` +data "google_project" "host_project" {} + +resource "google_project_service" "apphub" { + project = data.google_project.host_project.project_id + service = "apphub.googleapis.com" +} + resource "google_apphub_application" "example2" { location = "us-east1" application_id = "tf-test-example-application%{random_suffix}" @@ -315,6 +232,7 @@ resource "google_apphub_application" "example2" { email = "charlie@google.com%{random_suffix}" } } + depends_on = [google_project_service.apphub] } `, context) } From 5ec417d18876b8c01d68da10cbde8780633e09bf Mon Sep 17 00:00:00 2001 From: Esha Goel Date: Thu, 29 Feb 2024 06:32:57 +0000 Subject: [PATCH 3/9] Enable Apphub API in test cases --- mmv1/products/apphub/Application.yaml | 2 +- .../examples/apphub_application_basic.tf.erb | 1 + .../examples/apphub_application_full.tf.erb | 1 + .../resource_apphub_application_test.go | 44 +++++++------------ 4 files changed, 19 insertions(+), 29 deletions(-) diff --git a/mmv1/products/apphub/Application.yaml b/mmv1/products/apphub/Application.yaml index 6f462f68e4cd..3e0e52c9f3bf 100644 --- a/mmv1/products/apphub/Application.yaml +++ b/mmv1/products/apphub/Application.yaml @@ -43,7 +43,7 @@ examples: primary_resource_id: "example2" config_path: "templates/terraform/examples/apphub_application_full.tf.erb" vars: - application_id: "example-application" + application_id: "example-application" display_name: "Application Full" description: "Application for testing" business_name: "Alice" diff --git a/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb b/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb index ee688f93a701..bc7c74a9ef2e 100644 --- a/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb +++ b/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb @@ -3,6 +3,7 @@ data "google_project" "host_project" {} resource "google_project_service" "apphub" { project = data.google_project.host_project.project_id service = "apphub.googleapis.com" + disable_on_destroy = false } resource "google_apphub_application" "<%= ctx[:primary_resource_id] %>" { diff --git a/mmv1/templates/terraform/examples/apphub_application_full.tf.erb b/mmv1/templates/terraform/examples/apphub_application_full.tf.erb index 14692f8fb176..c99b3297016b 100644 --- a/mmv1/templates/terraform/examples/apphub_application_full.tf.erb +++ b/mmv1/templates/terraform/examples/apphub_application_full.tf.erb @@ -3,6 +3,7 @@ data "google_project" "host_project" {} resource "google_project_service" "apphub" { project = data.google_project.host_project.project_id service = "apphub.googleapis.com" + disable_on_destroy = false } resource "google_apphub_application" "<%= ctx[:primary_resource_id] %>" { diff --git a/mmv1/third_party/terraform/services/apphub/resource_apphub_application_test.go b/mmv1/third_party/terraform/services/apphub/resource_apphub_application_test.go index 65f5cb73422f..c9af86670e01 100644 --- a/mmv1/third_party/terraform/services/apphub/resource_apphub_application_test.go +++ b/mmv1/third_party/terraform/services/apphub/resource_apphub_application_test.go @@ -70,13 +70,7 @@ func TestAccApphubApplication_applicationUpdateFull(t *testing.T) { } func testAccApphubApplication_applicationUpdateDisplayName(context map[string]interface{}) string { - return acctest.Nprintf(` -data "google_project" "host_project" {} - -resource "google_project_service" "apphub" { - project = data.google_project.host_project.project_id - service = "apphub.googleapis.com" -} + return enableApphubAPI(context) + acctest.Nprintf(` resource "google_apphub_application" "example2" { location = "us-east1" @@ -111,13 +105,7 @@ resource "google_apphub_application" "example2" { } func testAccApphubApplication_applicationUpdateEnvironment(context map[string]interface{}) string { - return acctest.Nprintf(` -data "google_project" "host_project" {} - -resource "google_project_service" "apphub" { - project = data.google_project.host_project.project_id - service = "apphub.googleapis.com" -} + return enableApphubAPI(context) + acctest.Nprintf(` resource "google_apphub_application" "example2" { location = "us-east1" @@ -152,13 +140,7 @@ resource "google_apphub_application" "example2" { } func testAccApphubApplication_applicationUpdateCriticality(context map[string]interface{}) string { - return acctest.Nprintf(` -data "google_project" "host_project" {} - -resource "google_project_service" "apphub" { - project = data.google_project.host_project.project_id - service = "apphub.googleapis.com" -} + return enableApphubAPI(context) + acctest.Nprintf(` resource "google_apphub_application" "example2" { location = "us-east1" @@ -193,13 +175,7 @@ resource "google_apphub_application" "example2" { } func testAccApphubApplication_applicationUpdateOwners(context map[string]interface{}) string { - return acctest.Nprintf(` -data "google_project" "host_project" {} - -resource "google_project_service" "apphub" { - project = data.google_project.host_project.project_id - service = "apphub.googleapis.com" -} + return enableApphubAPI(context) + acctest.Nprintf(` resource "google_apphub_application" "example2" { location = "us-east1" @@ -236,3 +212,15 @@ resource "google_apphub_application" "example2" { } `, context) } + +func enableApphubAPI(context map[string]interface{}) string { + return acctest.Nprintf(` +data "google_project" "host_project" {} + +resource "google_project_service" "apphub" { + project = data.google_project.host_project.project_id + service = "apphub.googleapis.com" + disable_on_destroy = false +} +`, context) +} From 90f54bc341254a2ca93755e1f125fec0232f4451 Mon Sep 17 00:00:00 2001 From: Esha Goel Date: Mon, 4 Mar 2024 13:25:54 +0000 Subject: [PATCH 4/9] Fix precheck error --- .../terraform/.teamcity/components/inputs/services_ga.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt b/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt index 51f98ed08a05..08ce6c2ee82f 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt @@ -48,6 +48,11 @@ var ServicesListGa = mapOf( "displayName" to "Appengine", "path" to "./google/services/appengine" ), + "apphub" to mapOf( + "name" to "apphub", + "displayName" to "Apphub", + "path" to "./google/services/apphub" + ), "artifactregistry" to mapOf( "name" to "artifactregistry", "displayName" to "Artifactregistry", From 67630fb839d2b2c0f42d5427f5b73f37f188075c Mon Sep 17 00:00:00 2001 From: Esha Goel Date: Mon, 4 Mar 2024 13:25:54 +0000 Subject: [PATCH 5/9] Fix precheck error --- .../terraform/.teamcity/components/inputs/services_beta.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt b/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt index 27550dabce13..9e771e833493 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt @@ -48,6 +48,11 @@ var ServicesListBeta = mapOf( "displayName" to "Appengine", "path" to "./google-beta/services/appengine" ), + "apphub" to mapOf( + "name" to "apphub", + "displayName" to "Apphub", + "path" to "./google/services/apphub" + ), "artifactregistry" to mapOf( "name" to "artifactregistry", "displayName" to "Artifactregistry", From 9a751ebb042a7be7dd364d2e2700c33f2bdc0818 Mon Sep 17 00:00:00 2001 From: Esha Goel Date: Tue, 5 Mar 2024 05:28:35 +0000 Subject: [PATCH 6/9] Resolve comments --- .ci/infra/terraform/main.tf | 1 + mmv1/products/apphub/Application.yaml | 11 ++-- .../examples/apphub_application_basic.tf.erb | 9 --- .../examples/apphub_application_full.tf.erb | 9 --- .../components/inputs/services_beta.kt | 2 +- .../resource_apphub_application_test.go | 56 +++++++------------ 6 files changed, 28 insertions(+), 60 deletions(-) diff --git a/.ci/infra/terraform/main.tf b/.ci/infra/terraform/main.tf index a6f8c58a5f69..439d37f5e8b3 100644 --- a/.ci/infra/terraform/main.tf +++ b/.ci/infra/terraform/main.tf @@ -168,6 +168,7 @@ module "project-services" { "apikeys.googleapis.com", "appengine.googleapis.com", "appengineflex.googleapis.com", + "apphub.googleapis.com", "artifactregistry.googleapis.com", "assuredworkloads.googleapis.com", "autoscaling.googleapis.com", diff --git a/mmv1/products/apphub/Application.yaml b/mmv1/products/apphub/Application.yaml index 3e0e52c9f3bf..f7d0f1e2fb2e 100644 --- a/mmv1/products/apphub/Application.yaml +++ b/mmv1/products/apphub/Application.yaml @@ -19,7 +19,8 @@ id_format: projects/{{project}}/locations/{{location}}/applications/{{applicatio import_format: - projects/{{project}}/locations/{{location}}/applications/{{application_id}} name: Application -description: Description +description: 'Application is a functional grouping of Services and Workloads that helps achieve a desired end-to-end business functionality. + Services and Workloads are owned by the Application.' autogen_async: true examples: - !ruby/object:Provider::Terraform::Examples @@ -72,7 +73,6 @@ properties: description: 'Criticality type. ' required: true values: - - :TYPE_UNSPECIFIED - :MISSION_CRITICAL - :HIGH - :MEDIUM @@ -86,7 +86,6 @@ properties: description: 'Environment type. ' required: true values: - - :TYPE_UNSPECIFIED - :PRODUCTION - :STAGING - :TEST @@ -102,6 +101,7 @@ properties: description: 'Optional. Contact''s name. ' - !ruby/object:Api::Type::String name: email + required: true description: 'Required. Email address of the contacts. ' required: true description: 'Optional. Developer team that owns development and coding. ' @@ -114,6 +114,7 @@ properties: description: 'Optional. Contact''s name. ' - !ruby/object:Api::Type::String name: email + required: true description: 'Required. Email address of the contacts. ' description: 'Optional. Operator team that ensures runtime and operations. ' - !ruby/object:Api::Type::Array @@ -125,6 +126,7 @@ properties: description: 'Optional. Contact''s name. ' - !ruby/object:Api::Type::String name: email + required: true description: 'Required. Email address of the contacts. ' description: 'Optional. Business team that ensures user needs are met and value is delivered ' @@ -142,10 +144,9 @@ properties: properties: - !ruby/object:Api::Type::Enum name: type - description: "Required. Scope Type. \n Possible values:\n TYPE_UNSPECIFIED\nREGIONAL" + description: "Required. Scope Type. \n Possible values:\nREGIONAL" required: true values: - - :TYPE_UNSPECIFIED - :REGIONAL name: scope description: 'Scope of an application. ' diff --git a/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb b/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb index bc7c74a9ef2e..7b7c50231dca 100644 --- a/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb +++ b/mmv1/templates/terraform/examples/apphub_application_basic.tf.erb @@ -1,16 +1,7 @@ -data "google_project" "host_project" {} - -resource "google_project_service" "apphub" { - project = data.google_project.host_project.project_id - service = "apphub.googleapis.com" - disable_on_destroy = false -} - resource "google_apphub_application" "<%= ctx[:primary_resource_id] %>" { location = "us-east1" application_id = "<%= ctx[:vars]['application_id'] %>" scope { type = "REGIONAL" } - depends_on = [google_project_service.apphub] } diff --git a/mmv1/templates/terraform/examples/apphub_application_full.tf.erb b/mmv1/templates/terraform/examples/apphub_application_full.tf.erb index c99b3297016b..42d9de520464 100644 --- a/mmv1/templates/terraform/examples/apphub_application_full.tf.erb +++ b/mmv1/templates/terraform/examples/apphub_application_full.tf.erb @@ -1,11 +1,3 @@ -data "google_project" "host_project" {} - -resource "google_project_service" "apphub" { - project = data.google_project.host_project.project_id - service = "apphub.googleapis.com" - disable_on_destroy = false -} - resource "google_apphub_application" "<%= ctx[:primary_resource_id] %>" { location = "us-east1" application_id = "<%= ctx[:vars]['application_id'] %>" @@ -34,5 +26,4 @@ resource "google_apphub_application" "<%= ctx[:primary_resource_id] %>" { email = "<%= ctx[:vars]['operator_email'] %>" } } - depends_on = [google_project_service.apphub] } diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt b/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt index 9e771e833493..443987885a6f 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt @@ -51,7 +51,7 @@ var ServicesListBeta = mapOf( "apphub" to mapOf( "name" to "apphub", "displayName" to "Apphub", - "path" to "./google/services/apphub" + "path" to "./google-beta/services/apphub" ), "artifactregistry" to mapOf( "name" to "artifactregistry", diff --git a/mmv1/third_party/terraform/services/apphub/resource_apphub_application_test.go b/mmv1/third_party/terraform/services/apphub/resource_apphub_application_test.go index c9af86670e01..3e68916cc73e 100644 --- a/mmv1/third_party/terraform/services/apphub/resource_apphub_application_test.go +++ b/mmv1/third_party/terraform/services/apphub/resource_apphub_application_test.go @@ -70,7 +70,7 @@ func TestAccApphubApplication_applicationUpdateFull(t *testing.T) { } func testAccApphubApplication_applicationUpdateDisplayName(context map[string]interface{}) string { - return enableApphubAPI(context) + acctest.Nprintf(` + return acctest.Nprintf(` resource "google_apphub_application" "example2" { location = "us-east1" @@ -82,30 +82,29 @@ resource "google_apphub_application" "example2" { attributes { environment { type = "STAGING" - } - criticality { + } + criticality { type = "MISSION_CRITICAL" - } - business_owners { - display_name = "Alice%{random_suffix}" - email = "alice@google.com%{random_suffix}" - } - developer_owners { - display_name = "Bob%{random_suffix}" - email = "bob@google.com%{random_suffix}" - } - operator_owners { - display_name = "Charlie%{random_suffix}" - email = "charlie@google.com%{random_suffix}" - } + } + business_owners { + display_name = "Alice%{random_suffix}" + email = "alice@google.com%{random_suffix}" + } + developer_owners { + display_name = "Bob%{random_suffix}" + email = "bob@google.com%{random_suffix}" + } + operator_owners { + display_name = "Charlie%{random_suffix}" + email = "charlie@google.com%{random_suffix}" + } } - depends_on = [google_project_service.apphub] } `, context) } func testAccApphubApplication_applicationUpdateEnvironment(context map[string]interface{}) string { - return enableApphubAPI(context) + acctest.Nprintf(` + return acctest.Nprintf(` resource "google_apphub_application" "example2" { location = "us-east1" @@ -134,13 +133,12 @@ resource "google_apphub_application" "example2" { email = "charlie@google.com%{random_suffix}" } } - depends_on = [google_project_service.apphub] } `, context) } func testAccApphubApplication_applicationUpdateCriticality(context map[string]interface{}) string { - return enableApphubAPI(context) + acctest.Nprintf(` + return acctest.Nprintf(` resource "google_apphub_application" "example2" { location = "us-east1" @@ -169,13 +167,12 @@ resource "google_apphub_application" "example2" { email = "charlie@google.com%{random_suffix}" } } - depends_on = [google_project_service.apphub] } `, context) } func testAccApphubApplication_applicationUpdateOwners(context map[string]interface{}) string { - return enableApphubAPI(context) + acctest.Nprintf(` + return acctest.Nprintf(` resource "google_apphub_application" "example2" { location = "us-east1" @@ -202,25 +199,12 @@ resource "google_apphub_application" "example2" { developer_owners { display_name = "Derek%{random_suffix}" email = "derek@google.com%{random_suffix}" - } + } operator_owners { display_name = "Charlie%{random_suffix}" email = "charlie@google.com%{random_suffix}" } } - depends_on = [google_project_service.apphub] -} -`, context) -} - -func enableApphubAPI(context map[string]interface{}) string { - return acctest.Nprintf(` -data "google_project" "host_project" {} - -resource "google_project_service" "apphub" { - project = data.google_project.host_project.project_id - service = "apphub.googleapis.com" - disable_on_destroy = false } `, context) } From 9c862f2fba2fc170c1d57c6c0e270303ba3e68f2 Mon Sep 17 00:00:00 2001 From: Esha Goel Date: Tue, 5 Mar 2024 06:46:39 +0000 Subject: [PATCH 7/9] Fix lint error --- mmv1/products/apphub/Application.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mmv1/products/apphub/Application.yaml b/mmv1/products/apphub/Application.yaml index f7d0f1e2fb2e..b0a3bbea1ab7 100644 --- a/mmv1/products/apphub/Application.yaml +++ b/mmv1/products/apphub/Application.yaml @@ -19,7 +19,7 @@ id_format: projects/{{project}}/locations/{{location}}/applications/{{applicatio import_format: - projects/{{project}}/locations/{{location}}/applications/{{application_id}} name: Application -description: 'Application is a functional grouping of Services and Workloads that helps achieve a desired end-to-end business functionality. +description: 'Application is a functional grouping of Services and Workloads that helps achieve a desired end-to-end business functionality. Services and Workloads are owned by the Application.' autogen_async: true examples: @@ -103,7 +103,6 @@ properties: name: email required: true description: 'Required. Email address of the contacts. ' - required: true description: 'Optional. Developer team that owns development and coding. ' - !ruby/object:Api::Type::Array name: operatorOwners From ce29615c811dc37bea9f32f9779232f2be5ac28d Mon Sep 17 00:00:00 2001 From: Esha Goel Date: Tue, 5 Mar 2024 18:54:16 +0000 Subject: [PATCH 8/9] Fix examples --- mmv1/products/apphub/Application.yaml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/mmv1/products/apphub/Application.yaml b/mmv1/products/apphub/Application.yaml index b0a3bbea1ab7..fbac56d6ba63 100644 --- a/mmv1/products/apphub/Application.yaml +++ b/mmv1/products/apphub/Application.yaml @@ -27,16 +27,6 @@ examples: name: "application_basic" primary_resource_id: "example" config_path: "templates/terraform/examples/apphub_application_basic.tf.erb" - skip_test: true - vars: - location: "us-east1" - application_id: "example-application" - scope_type: "REGIONAL" - - !ruby/object:Provider::Terraform::Examples - name: "application_basic" - primary_resource_id: "example" - config_path: "templates/terraform/examples/apphub_application_basic.tf.erb" - skip_docs: true vars: application_id: "example-application" - !ruby/object:Provider::Terraform::Examples From aa5bcffc499464b874800b275c579c1817482478 Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Wed, 6 Mar 2024 08:51:45 -0500 Subject: [PATCH 9/9] Remove apphub from teamcity config This causes PR build failures, I'll add it later --- .ci/infra/terraform/main.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/.ci/infra/terraform/main.tf b/.ci/infra/terraform/main.tf index 439d37f5e8b3..a6f8c58a5f69 100644 --- a/.ci/infra/terraform/main.tf +++ b/.ci/infra/terraform/main.tf @@ -168,7 +168,6 @@ module "project-services" { "apikeys.googleapis.com", "appengine.googleapis.com", "appengineflex.googleapis.com", - "apphub.googleapis.com", "artifactregistry.googleapis.com", "assuredworkloads.googleapis.com", "autoscaling.googleapis.com",