From e109003d0c18f773a242f4d43401abe30e96db17 Mon Sep 17 00:00:00 2001 From: nownabe Date: Tue, 6 Feb 2024 23:42:20 +0900 Subject: [PATCH 1/3] Add IAM resources for Cloud Deploy Target --- mmv1/products/clouddeploy/Target.yaml | 40 +++++++++++++++++++ .../examples/clouddeploy_target_basic.tf.erb | 4 ++ 2 files changed, 44 insertions(+) create mode 100644 mmv1/products/clouddeploy/Target.yaml create mode 100644 mmv1/templates/terraform/examples/clouddeploy_target_basic.tf.erb diff --git a/mmv1/products/clouddeploy/Target.yaml b/mmv1/products/clouddeploy/Target.yaml new file mode 100644 index 000000000000..98c6de0dfaa8 --- /dev/null +++ b/mmv1/products/clouddeploy/Target.yaml @@ -0,0 +1,40 @@ +# 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 +name: 'Target' +description: | + A Target defines a location to which a Skaffold configuration can be deployed. +base_url: 'projects/{{project}}/locations/{{location}}/targets' +self_link: 'projects/{{project}}/locations/{{location}}/targets/{{name}}' +exclude_resource: true +id_format: 'projects/{{project}}/locations/{{location}}/targets/{{name}}' +import_format: + - 'projects/{{project}}/locations/{{location}}/targets/{{name}}' +iam_policy: !ruby/object:Api::Resource::IamPolicy + parent_resource_attribute: 'name' + method_name_separator: ':' + base_url: 'projects/{{project}}/locations/{{location}}/targets/{{name}}' + import_format: ['projects/{{project}}/locations/{{location}}/targets/{{name}}', '{{name}}'] +examples: + - !ruby/object:Provider::Terraform::Examples + name: 'clouddeploy_target_basic' + primary_resource_id: 'default' + primary_resource_name: 'fmt.Sprintf("tf-test-cd-target%s", context["random_suffix"])' + vars: + target: 'cd-target' +properties: + - !ruby/object:Api::Type::String + name: "name" + description: "Dummy property." + required: true diff --git a/mmv1/templates/terraform/examples/clouddeploy_target_basic.tf.erb b/mmv1/templates/terraform/examples/clouddeploy_target_basic.tf.erb new file mode 100644 index 000000000000..5fd51566834c --- /dev/null +++ b/mmv1/templates/terraform/examples/clouddeploy_target_basic.tf.erb @@ -0,0 +1,4 @@ +resource "google_clouddeploy_target" "<%= ctx[:primary_resource_id] %>" { + name = "<%= ctx[:vars]['target'] %>" + location = "us-central1" + } From ce7d828d05066dd78afebf3454c4d9cec2b40990 Mon Sep 17 00:00:00 2001 From: nownabe Date: Sat, 10 Feb 2024 21:38:53 +0900 Subject: [PATCH 2/3] update --- mmv1/products/clouddeploy/Target.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mmv1/products/clouddeploy/Target.yaml b/mmv1/products/clouddeploy/Target.yaml index 98c6de0dfaa8..a85e17933d06 100644 --- a/mmv1/products/clouddeploy/Target.yaml +++ b/mmv1/products/clouddeploy/Target.yaml @@ -14,7 +14,7 @@ --- !ruby/object:Api::Resource name: 'Target' description: | - A Target defines a location to which a Skaffold configuration can be deployed. + The Cloud Deploy `Target` resource. base_url: 'projects/{{project}}/locations/{{location}}/targets' self_link: 'projects/{{project}}/locations/{{location}}/targets/{{name}}' exclude_resource: true @@ -25,7 +25,6 @@ iam_policy: !ruby/object:Api::Resource::IamPolicy parent_resource_attribute: 'name' method_name_separator: ':' base_url: 'projects/{{project}}/locations/{{location}}/targets/{{name}}' - import_format: ['projects/{{project}}/locations/{{location}}/targets/{{name}}', '{{name}}'] examples: - !ruby/object:Provider::Terraform::Examples name: 'clouddeploy_target_basic' From aa56397c082ea2ff9b39264de52ec6ec20aab7d2 Mon Sep 17 00:00:00 2001 From: nownabe Date: Fri, 23 Feb 2024 22:10:28 +0900 Subject: [PATCH 3/3] add back import_format --- mmv1/products/clouddeploy/Target.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/products/clouddeploy/Target.yaml b/mmv1/products/clouddeploy/Target.yaml index a85e17933d06..b8ab9d6fd154 100644 --- a/mmv1/products/clouddeploy/Target.yaml +++ b/mmv1/products/clouddeploy/Target.yaml @@ -25,6 +25,7 @@ iam_policy: !ruby/object:Api::Resource::IamPolicy parent_resource_attribute: 'name' method_name_separator: ':' base_url: 'projects/{{project}}/locations/{{location}}/targets/{{name}}' + import_format: ['projects/{{project}}/locations/{{location}}/targets/{{name}}', '{{name}}'] examples: - !ruby/object:Provider::Terraform::Examples name: 'clouddeploy_target_basic'