From 78694ffb7be2c403960d2176c680c1d847c3684f Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Thu, 25 Apr 2019 14:46:06 -0700 Subject: [PATCH] Move AlertPolicy labels to user_labels and make them a map (#1685) Merged PR #1685. --- build/terraform | 2 +- build/terraform-beta | 2 +- build/terraform-mapper | 2 +- products/monitoring/api.yaml | 12 ++++++---- products/monitoring/terraform.yaml | 1 + .../monitoring_alert_policy_basic.tf.erb | 4 ++++ .../extra_schema_entry/alert_policy.erb | 22 +++++++++++++++++++ 7 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 templates/terraform/extra_schema_entry/alert_policy.erb diff --git a/build/terraform b/build/terraform index d28bfc7aafd5..2e7d7a6fb3e5 160000 --- a/build/terraform +++ b/build/terraform @@ -1 +1 @@ -Subproject commit d28bfc7aafd59f9b089a9029707cac39a416134e +Subproject commit 2e7d7a6fb3e58362267ff46c8bf0d831f274efe4 diff --git a/build/terraform-beta b/build/terraform-beta index bffe09815b76..3c88de74e766 160000 --- a/build/terraform-beta +++ b/build/terraform-beta @@ -1 +1 @@ -Subproject commit bffe09815b762662f596dbbc67f276e6999ac3e3 +Subproject commit 3c88de74e766571986a6b32ad26330f06d4418f9 diff --git a/build/terraform-mapper b/build/terraform-mapper index b1796f57768e..75f2821efd51 160000 --- a/build/terraform-mapper +++ b/build/terraform-mapper @@ -1 +1 @@ -Subproject commit b1796f57768ef71f732d35903bd1783cb038553a +Subproject commit 75f2821efd51418c30dc0762a0817471ff0b2064 diff --git a/products/monitoring/api.yaml b/products/monitoring/api.yaml index 1f5f9ab23296..0fb96159b8ac 100644 --- a/products/monitoring/api.yaml +++ b/products/monitoring/api.yaml @@ -702,10 +702,14 @@ objects: entries in this field is `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]` item_type: Api::Type::String - - !ruby/object:Api::Type::Array - name: 'labels' - description: 'User-supplied key/value data to be used for organizing AlertPolicy objects.' - item_type: Api::Type::String + - !ruby/object:Api::Type::KeyValuePairs + name: userLabels + description: | + This field is intended to be used for organizing and identifying the AlertPolicy + objects.The field can contain up to 64 entries. Each key and value is limited + to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values + can contain only lowercase letters, numerals, underscores, and dashes. Keys + must begin with a letter. - !ruby/object:Api::Type::NestedObject name: documentation description: | diff --git a/products/monitoring/terraform.yaml b/products/monitoring/terraform.yaml index 0c4adb1550ec..3e33e2f1e0d1 100644 --- a/products/monitoring/terraform.yaml +++ b/products/monitoring/terraform.yaml @@ -25,6 +25,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides custom_code: !ruby/object:Provider::Terraform::CustomCode custom_import: templates/terraform/custom_import/self_link_as_name.erb post_create: templates/terraform/post_create/set_computed_name.erb + extra_schema_entry: templates/terraform/extra_schema_entry/alert_policy.erb Group: !ruby/object:Overrides::Terraform::ResourceOverride id_format: "{{name}}" import_format: ["{{name}}"] diff --git a/templates/terraform/examples/monitoring_alert_policy_basic.tf.erb b/templates/terraform/examples/monitoring_alert_policy_basic.tf.erb index df319b2b93ba..b87a791c9158 100644 --- a/templates/terraform/examples/monitoring_alert_policy_basic.tf.erb +++ b/templates/terraform/examples/monitoring_alert_policy_basic.tf.erb @@ -13,4 +13,8 @@ resource "google_monitoring_alert_policy" "<%= ctx[:primary_resource_id] %>" { } } } + + user_labels = { + foo = "bar" + } } diff --git a/templates/terraform/extra_schema_entry/alert_policy.erb b/templates/terraform/extra_schema_entry/alert_policy.erb new file mode 100644 index 000000000000..241f6e1f319e --- /dev/null +++ b/templates/terraform/extra_schema_entry/alert_policy.erb @@ -0,0 +1,22 @@ +<%# The license inside this block applies to this file. + # Copyright 2018 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. +-%> +"labels": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Deprecated: "labels is removed as it was never used. See user_labels for the correct field", +}, \ No newline at end of file