diff --git a/mmv1/third_party/terraform/go.mod.erb b/mmv1/third_party/terraform/go.mod.erb index ba3ce10c91e9..f0fffcf237f0 100644 --- a/mmv1/third_party/terraform/go.mod.erb +++ b/mmv1/third_party/terraform/go.mod.erb @@ -3,7 +3,7 @@ module github.com/hashicorp/terraform-provider-google<%= "-" + version unless ve require ( cloud.google.com/go/bigtable v1.10.1 - github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210918014849-ef8e2b337288 + github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210921224745-48b8ffa00a5a github.com/apparentlymart/go-cidr v1.1.0 github.com/client9/misspell v0.3.4 github.com/davecgh/go-spew v1.1.1 diff --git a/mmv1/third_party/terraform/go.sum b/mmv1/third_party/terraform/go.sum index 324062828573..bdcabbe126bd 100644 --- a/mmv1/third_party/terraform/go.sum +++ b/mmv1/third_party/terraform/go.sum @@ -1405,7 +1405,11 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8 rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210920194825-266a1a47abc5 h1:TGTrcrXnhJEM/yrjg6AyyTfYWIEAld7dCP8+085QF/w= +github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210920194825-266a1a47abc5/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU= github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210918014849-ef8e2b337288 h1:mMwzB+vf5cvKCKAl1RocM5CqHhr8NtEKpP8ioSDVhO4= github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210918014849-ef8e2b337288/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU= github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210918014849-ef8e2b337288 h1:mMwzB+vf5cvKCKAl1RocM5CqHhr8NtEKpP8ioSDVhO4= github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210918014849-ef8e2b337288/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU= +github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210921224745-48b8ffa00a5a h1:5G/+2v/atxzGvjxAZloMbAoad19hYRCbmGyW60SyCcE= +github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210921224745-48b8ffa00a5a/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU= diff --git a/mmv1/third_party/terraform/utils/iam.go.erb b/mmv1/third_party/terraform/utils/iam.go.erb index f6ad971b7834..181128798f0a 100644 --- a/mmv1/third_party/terraform/utils/iam.go.erb +++ b/mmv1/third_party/terraform/utils/iam.go.erb @@ -7,6 +7,7 @@ import ( "fmt" "log" "reflect" + "sort" "strings" "time" diff --git a/mmv1/third_party/terraform/utils/provider.go.erb b/mmv1/third_party/terraform/utils/provider.go.erb index 90d1cee31014..c19088b742b4 100644 --- a/mmv1/third_party/terraform/utils/provider.go.erb +++ b/mmv1/third_party/terraform/utils/provider.go.erb @@ -456,7 +456,9 @@ end # products.each do "google_gke_hub_feature": resourceGkeHubFeature(), "google_gke_hub_feature_membership": resourceGkeHubFeatureMembership(), <% end -%> - "google_org_policy_policy": resourceOrgPolicyPolicy(), + "google_monitoring_metrics_scope": resourceMonitoringMetricsScope(), + "google_monitoring_monitored_project": resourceMonitoringMonitoredProject(), + "google_org_policy_policy": resourceOrgPolicyPolicy(), "google_privateca_certificate_template": resourcePrivatecaCertificateTemplate(), }, // ------------------------------------ diff --git a/tpgtools/api/monitoring/beta/metrics_scope.yaml b/tpgtools/api/monitoring/beta/metrics_scope.yaml new file mode 100755 index 000000000000..7b458e0a85cc --- /dev/null +++ b/tpgtools/api/monitoring/beta/metrics_scope.yaml @@ -0,0 +1,94 @@ +# Copyright 2021 Google LLC. All Rights Reserved. +# +# 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. +info: + title: Monitoring/MetricsScope + description: DCL Specification for the Monitoring MetricsScope resource + x-dcl-has-iam: false +paths: + get: + description: The function used to get information about a MetricsScope + parameters: + - name: MetricsScope + required: true + description: A full instance of a MetricsScope + apply: + description: The function used to apply information about a MetricsScope + parameters: + - name: MetricsScope + required: true + description: A full instance of a MetricsScope +components: + schemas: + MetricsScope: + title: MetricsScope + x-dcl-id: locations/global/metricsScopes/{{name}} + x-dcl-locations: + - global + type: object + required: + - name + properties: + createTime: + type: string + format: date-time + x-dcl-go-name: CreateTime + readOnly: true + description: Output only. The time when this `Metrics Scope` was created. + x-kubernetes-immutable: true + monitoredProjects: + type: array + x-dcl-go-name: MonitoredProjects + readOnly: true + description: Output only. The list of projects monitored by this `Metrics + Scope`. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: MetricsScopeMonitoredProjects + properties: + createTime: + type: string + format: date-time + x-dcl-go-name: CreateTime + readOnly: true + description: Output only. The time when this `MonitoredProject` was + created. + x-kubernetes-immutable: true + name: + type: string + x-dcl-go-name: Name + readOnly: true + description: 'Immutable. The resource name of the `MonitoredProject`. + On input, the resource name includes the scoping project ID and + monitored project ID. On output, it contains the equivalent project + numbers. Example: `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}`' + x-kubernetes-immutable: true + name: + type: string + x-dcl-go-name: Name + description: 'Immutable. The resource name of the Monitoring Metrics Scope. + On input, the resource name can be specified with the scoping project + ID or number. On output, the resource name is specified with the scoping + project number. Example: `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}`' + x-kubernetes-immutable: true + updateTime: + type: string + format: date-time + x-dcl-go-name: UpdateTime + readOnly: true + description: Output only. The time when this `Metrics Scope` record was + last updated. + x-kubernetes-immutable: true diff --git a/tpgtools/api/monitoring/beta/monitored_project.yaml b/tpgtools/api/monitoring/beta/monitored_project.yaml new file mode 100755 index 000000000000..c85c5ac7138d --- /dev/null +++ b/tpgtools/api/monitoring/beta/monitored_project.yaml @@ -0,0 +1,86 @@ +# Copyright 2021 Google LLC. All Rights Reserved. +# +# 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. +info: + title: Monitoring/MonitoredProject + description: DCL Specification for the Monitoring MonitoredProject resource + x-dcl-has-iam: false +paths: + get: + description: The function used to get information about a MonitoredProject + parameters: + - name: MonitoredProject + required: true + description: A full instance of a MonitoredProject + apply: + description: The function used to apply information about a MonitoredProject + parameters: + - name: MonitoredProject + required: true + description: A full instance of a MonitoredProject + delete: + description: The function used to delete a MonitoredProject + parameters: + - name: MonitoredProject + required: true + description: A full instance of a MonitoredProject + deleteAll: + description: The function used to delete all MonitoredProject + parameters: + - name: metricsscope + required: true + schema: + type: string + list: + description: The function used to list information about many MonitoredProject + parameters: + - name: metricsscope + required: true + schema: + type: string +components: + schemas: + MonitoredProject: + title: MonitoredProject + x-dcl-id: locations/global/metricsScopes/{{metrics_scope}}/projects/{{name}} + x-dcl-locations: + - global + type: object + required: + - name + - metricsScope + properties: + createTime: + type: string + format: date-time + x-dcl-go-name: CreateTime + readOnly: true + description: Output only. The time when this `MonitoredProject` was created. + x-kubernetes-immutable: true + metricsScope: + type: string + x-dcl-go-name: MetricsScope + description: 'Required. The resource name of the existing Metrics Scope + that will monitor this project. Example: locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}' + x-kubernetes-immutable: true + x-dcl-references: + - resource: Monitoring/MetricsScope + field: name + name: + type: string + x-dcl-go-name: Name + description: 'Immutable. The resource name of the `MonitoredProject`. On + input, the resource name includes the scoping project ID and monitored + project ID. On output, it contains the equivalent project numbers. Example: + `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}`' + x-kubernetes-immutable: true diff --git a/tpgtools/api/monitoring/metrics_scope.yaml b/tpgtools/api/monitoring/metrics_scope.yaml new file mode 100755 index 000000000000..7b458e0a85cc --- /dev/null +++ b/tpgtools/api/monitoring/metrics_scope.yaml @@ -0,0 +1,94 @@ +# Copyright 2021 Google LLC. All Rights Reserved. +# +# 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. +info: + title: Monitoring/MetricsScope + description: DCL Specification for the Monitoring MetricsScope resource + x-dcl-has-iam: false +paths: + get: + description: The function used to get information about a MetricsScope + parameters: + - name: MetricsScope + required: true + description: A full instance of a MetricsScope + apply: + description: The function used to apply information about a MetricsScope + parameters: + - name: MetricsScope + required: true + description: A full instance of a MetricsScope +components: + schemas: + MetricsScope: + title: MetricsScope + x-dcl-id: locations/global/metricsScopes/{{name}} + x-dcl-locations: + - global + type: object + required: + - name + properties: + createTime: + type: string + format: date-time + x-dcl-go-name: CreateTime + readOnly: true + description: Output only. The time when this `Metrics Scope` was created. + x-kubernetes-immutable: true + monitoredProjects: + type: array + x-dcl-go-name: MonitoredProjects + readOnly: true + description: Output only. The list of projects monitored by this `Metrics + Scope`. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: MetricsScopeMonitoredProjects + properties: + createTime: + type: string + format: date-time + x-dcl-go-name: CreateTime + readOnly: true + description: Output only. The time when this `MonitoredProject` was + created. + x-kubernetes-immutable: true + name: + type: string + x-dcl-go-name: Name + readOnly: true + description: 'Immutable. The resource name of the `MonitoredProject`. + On input, the resource name includes the scoping project ID and + monitored project ID. On output, it contains the equivalent project + numbers. Example: `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}`' + x-kubernetes-immutable: true + name: + type: string + x-dcl-go-name: Name + description: 'Immutable. The resource name of the Monitoring Metrics Scope. + On input, the resource name can be specified with the scoping project + ID or number. On output, the resource name is specified with the scoping + project number. Example: `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}`' + x-kubernetes-immutable: true + updateTime: + type: string + format: date-time + x-dcl-go-name: UpdateTime + readOnly: true + description: Output only. The time when this `Metrics Scope` record was + last updated. + x-kubernetes-immutable: true diff --git a/tpgtools/api/monitoring/monitored_project.yaml b/tpgtools/api/monitoring/monitored_project.yaml new file mode 100755 index 000000000000..c85c5ac7138d --- /dev/null +++ b/tpgtools/api/monitoring/monitored_project.yaml @@ -0,0 +1,86 @@ +# Copyright 2021 Google LLC. All Rights Reserved. +# +# 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. +info: + title: Monitoring/MonitoredProject + description: DCL Specification for the Monitoring MonitoredProject resource + x-dcl-has-iam: false +paths: + get: + description: The function used to get information about a MonitoredProject + parameters: + - name: MonitoredProject + required: true + description: A full instance of a MonitoredProject + apply: + description: The function used to apply information about a MonitoredProject + parameters: + - name: MonitoredProject + required: true + description: A full instance of a MonitoredProject + delete: + description: The function used to delete a MonitoredProject + parameters: + - name: MonitoredProject + required: true + description: A full instance of a MonitoredProject + deleteAll: + description: The function used to delete all MonitoredProject + parameters: + - name: metricsscope + required: true + schema: + type: string + list: + description: The function used to list information about many MonitoredProject + parameters: + - name: metricsscope + required: true + schema: + type: string +components: + schemas: + MonitoredProject: + title: MonitoredProject + x-dcl-id: locations/global/metricsScopes/{{metrics_scope}}/projects/{{name}} + x-dcl-locations: + - global + type: object + required: + - name + - metricsScope + properties: + createTime: + type: string + format: date-time + x-dcl-go-name: CreateTime + readOnly: true + description: Output only. The time when this `MonitoredProject` was created. + x-kubernetes-immutable: true + metricsScope: + type: string + x-dcl-go-name: MetricsScope + description: 'Required. The resource name of the existing Metrics Scope + that will monitor this project. Example: locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}' + x-kubernetes-immutable: true + x-dcl-references: + - resource: Monitoring/MetricsScope + field: name + name: + type: string + x-dcl-go-name: Name + description: 'Immutable. The resource name of the `MonitoredProject`. On + input, the resource name includes the scoping project ID and monitored + project ID. On output, it contains the equivalent project numbers. Example: + `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}`' + x-kubernetes-immutable: true diff --git a/tpgtools/api/monitoring/samples/basic.cloudresourcemanager.project.json b/tpgtools/api/monitoring/samples/basic.cloudresourcemanager.project.json new file mode 100755 index 000000000000..ecb8396416a9 --- /dev/null +++ b/tpgtools/api/monitoring/samples/basic.cloudresourcemanager.project.json @@ -0,0 +1,4 @@ +{ + "name": "{{id}}", + "parent": "organizations/{{org_id}}" +} diff --git a/tpgtools/api/monitoring/samples/basic.metrics_scope.json b/tpgtools/api/monitoring/samples/basic.metrics_scope.json new file mode 100755 index 000000000000..c0b0a4e18cc8 --- /dev/null +++ b/tpgtools/api/monitoring/samples/basic.metrics_scope.json @@ -0,0 +1,3 @@ +{ + "name": "{{project}}" +} diff --git a/tpgtools/api/monitoring/samples/basic.monitored_project.json b/tpgtools/api/monitoring/samples/basic.monitored_project.json new file mode 100755 index 000000000000..0be949e1bd24 --- /dev/null +++ b/tpgtools/api/monitoring/samples/basic.monitored_project.json @@ -0,0 +1,4 @@ +{ + "name": "{{ref:basic.cloudresourcemanager.project.json:name}}", + "metricsScope": "{{ref:basic.metrics_scope.json:name}}" +} diff --git a/tpgtools/api/monitoring/samples/basic_metrics_scope.yaml b/tpgtools/api/monitoring/samples/basic_metrics_scope.yaml new file mode 100755 index 000000000000..c5653cd139a5 --- /dev/null +++ b/tpgtools/api/monitoring/samples/basic_metrics_scope.yaml @@ -0,0 +1,23 @@ +# Copyright 2021 Google LLC. All Rights Reserved. +# +# 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. +description: A basic example of a monitoring metrics scope +name: basic_metrics_scope +resource: samples/basic.metrics_scope.json +type: metrics_scope +variables: +- name: project + type: project +versions: +- ga +- beta diff --git a/tpgtools/api/monitoring/samples/basic_monitored_project.yaml b/tpgtools/api/monitoring/samples/basic_monitored_project.yaml new file mode 100755 index 000000000000..ed0aee65a1b3 --- /dev/null +++ b/tpgtools/api/monitoring/samples/basic_monitored_project.yaml @@ -0,0 +1,30 @@ +# Copyright 2021 Google LLC. All Rights Reserved. +# +# 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. +dependencies: +- samples/basic.cloudresourcemanager.project.json +- samples/basic.metrics_scope.json +description: A basic example of a monitoring monitored project +name: basic_monitored_project +resource: samples/basic.monitored_project.json +type: monitored_project +variables: +- name: id + type: resource_name +- name: org_id + type: org_id +- name: project + type: project +versions: +- ga +- beta diff --git a/tpgtools/go.mod b/tpgtools/go.mod index 24160627396d..226c0f76002d 100644 --- a/tpgtools/go.mod +++ b/tpgtools/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( bitbucket.org/creachadair/stringset v0.0.9 - github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210918014849-ef8e2b337288 + github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210921224745-48b8ffa00a5a github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/hashicorp/errwrap v1.0.0 github.com/hashicorp/hcl v1.0.0 diff --git a/tpgtools/go.sum b/tpgtools/go.sum index 89bfe8b4dda0..0c65c48e0909 100644 --- a/tpgtools/go.sum +++ b/tpgtools/go.sum @@ -36,8 +36,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210918014849-ef8e2b337288 h1:mMwzB+vf5cvKCKAl1RocM5CqHhr8NtEKpP8ioSDVhO4= -github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210918014849-ef8e2b337288/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU= +github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210921224745-48b8ffa00a5a h1:5G/+2v/atxzGvjxAZloMbAoad19hYRCbmGyW60SyCcE= +github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210921224745-48b8ffa00a5a/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= diff --git a/tpgtools/override.go b/tpgtools/override.go index 10b39d7636b0..4fd34163ce12 100644 --- a/tpgtools/override.go +++ b/tpgtools/override.go @@ -37,6 +37,7 @@ const ( CustomID = "CUSTOM_ID" CustomizeDiff = "CUSTOMIZE_DIFF" ImportFormat = "IMPORT_FORMAT" + AppendToBasePath = "APPEND_TO_BASE_PATH" Mutex = "MUTEX" PreCreate = "PRE_CREATE_FUNCTION" PostCreate = "POST_CREATE_FUNCTION" @@ -45,7 +46,8 @@ const ( NoSweeper = "NO_SWEEPER" CustomImport = "CUSTOM_IMPORT_FUNCTION" CustomCreateDirective = "CUSTOM_CREATE_DIRECTIVE_FUNCTION" - SkipDelete = "SKIP_DELETE_FUNCTION" + Undeletable = "UNDELETABLE" + SkipDeleteFunction = "SKIP_DELETE_FUNCTION" SerializationOnly = "SERIALIZATION_ONLY" CustomSerializer = "CUSTOM_SERIALIZER" TerraformProductName = "CUSTOM_TERRAFORM_PRODUCT_NAME" diff --git a/tpgtools/override_details.go b/tpgtools/override_details.go index e6d209bdd5fc..3d456dfa5597 100644 --- a/tpgtools/override_details.go +++ b/tpgtools/override_details.go @@ -66,6 +66,12 @@ type CustomImportFunctionDetails struct { Function string } +type AppendToBasePathDetails struct { + // Append to base path appends this string to the end of the resource's + // base path. + String string +} + type CustomizeDiffDetails struct { // Functions is a list of CustomizeDiffFunc to use with // customdiff.All(...). diff --git a/tpgtools/overrides/monitoring/beta/metrics_scope.yaml b/tpgtools/overrides/monitoring/beta/metrics_scope.yaml new file mode 100644 index 000000000000..98723d98f4b8 --- /dev/null +++ b/tpgtools/overrides/monitoring/beta/metrics_scope.yaml @@ -0,0 +1,20 @@ +# Copyright 2021 Google LLC. All Rights Reserved. +# +# 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. + +- type: UNDELETABLE +# need to append version to dcl monitoring since the mm basepath declaration we share +# does not include version https://git.io/Jz4Wn +- type: APPEND_TO_BASE_PATH + details: + string: v1 diff --git a/tpgtools/overrides/monitoring/beta/monitored_project.yaml b/tpgtools/overrides/monitoring/beta/monitored_project.yaml new file mode 100644 index 000000000000..7cf83cf69dcc --- /dev/null +++ b/tpgtools/overrides/monitoring/beta/monitored_project.yaml @@ -0,0 +1,17 @@ +# Copyright 2021 Google LLC. All Rights Reserved. +# +# 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. + +- type: APPEND_TO_BASE_PATH + details: + string: v1 diff --git a/tpgtools/overrides/monitoring/metrics_scope.yaml b/tpgtools/overrides/monitoring/metrics_scope.yaml new file mode 100644 index 000000000000..392a34d8b6b8 --- /dev/null +++ b/tpgtools/overrides/monitoring/metrics_scope.yaml @@ -0,0 +1,18 @@ +# Copyright 2021 Google LLC. All Rights Reserved. +# +# 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. + +- type: UNDELETABLE +- type: APPEND_TO_BASE_PATH + details: + string: v1 diff --git a/tpgtools/overrides/monitoring/monitored_project.yaml b/tpgtools/overrides/monitoring/monitored_project.yaml new file mode 100644 index 000000000000..7cf83cf69dcc --- /dev/null +++ b/tpgtools/overrides/monitoring/monitored_project.yaml @@ -0,0 +1,17 @@ +# Copyright 2021 Google LLC. All Rights Reserved. +# +# 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. + +- type: APPEND_TO_BASE_PATH + details: + string: v1 diff --git a/tpgtools/overrides/monitoring/samples/metricsscope/meta.yaml b/tpgtools/overrides/monitoring/samples/metricsscope/meta.yaml new file mode 100644 index 000000000000..a4fe31c7b534 --- /dev/null +++ b/tpgtools/overrides/monitoring/samples/metricsscope/meta.yaml @@ -0,0 +1,3 @@ +substitutions: + - substitution: "project" + value: ":PROJECT" diff --git a/tpgtools/overrides/monitoring/samples/monitoredproject/meta.yaml b/tpgtools/overrides/monitoring/samples/monitoredproject/meta.yaml new file mode 100644 index 000000000000..700fd218cc00 --- /dev/null +++ b/tpgtools/overrides/monitoring/samples/monitoredproject/meta.yaml @@ -0,0 +1,7 @@ +substitutions: + - substitution: "id" + value: "id" + - substitution: "org_id" + value: ":ORG_ID" + - substitution: "project" + value: ":PROJECT" diff --git a/tpgtools/resource.go b/tpgtools/resource.go index cae9da0402b9..ef70e604041a 100644 --- a/tpgtools/resource.go +++ b/tpgtools/resource.go @@ -47,6 +47,11 @@ type Resource struct { // TODO: if none are set, the resource does not support import. ImportFormats []string + // AppendToBasePath is a string that will be appended to the end of the API base path. + // rarely needed in cases where the shared mm basepath does not include the version + // as in Montioring https://git.io/Jz4Wn + AppendToBasePath string + // title is the name of the resource in snake_case. For example, // "instance", "backend_service". title string @@ -122,6 +127,9 @@ type Resource struct { // call CustomCreateDirectiveFunction *string + // Undeletable is true if this resource has no delete method. + Undeletable bool + // SkipDeleteFunction is the name of a function that takes the // object and config and returns a boolean for if Terraform should make // the delete call for the resource @@ -413,6 +421,16 @@ func createResource(schema *openapi.Schema, typeFetcher *TypeFetcher, overrides res.CustomImportFunction = &cifd.Function } + // Resource Override: Append to Base Path + atbpd := AppendToBasePathDetails{} + atbpOk, err := overrides.ResourceOverrideWithDetails(AppendToBasePath, &atbpd, location) + if err != nil { + return nil, fmt.Errorf("failed to decode append to base path details: %v", err) + } + if atbpOk { + res.AppendToBasePath = atbpd.String + } + // Resource Override: Import formats ifd := ImportFormatDetails{} ifdOk, err := overrides.ResourceOverrideWithDetails(ImportFormat, &ifd, location) @@ -522,11 +540,14 @@ func createResource(schema *openapi.Schema, typeFetcher *TypeFetcher, overrides res.CustomCreateDirectiveFunction = &createDirectiveFunc.Function } + // Resource Override: Undeletable + res.Undeletable = overrides.ResourceOverride(Undeletable, location) + // Resource Override: SkipDeleteFunction skipDeleteFunc := SkipDeleteFunctionDetails{} - skipDeleteFuncOk, err := overrides.ResourceOverrideWithDetails(SkipDelete, &skipDeleteFunc, location) + skipDeleteFuncOk, err := overrides.ResourceOverrideWithDetails(SkipDeleteFunction, &skipDeleteFunc, location) if err != nil { - return nil, fmt.Errorf("failed to decode skip delete function details: %v", err) + return nil, fmt.Errorf("failed to decode skip delete details: %v", err) } if skipDeleteFuncOk { res.SkipDeleteFunction = &skipDeleteFunc.Function diff --git a/tpgtools/serialization.go b/tpgtools/serialization.go index 166705e0d14b..d0f41f770801 100644 --- a/tpgtools/serialization.go +++ b/tpgtools/serialization.go @@ -33,6 +33,8 @@ import ( eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc" eventarcBeta "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc/beta" gkehubBeta "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/gkehub/beta" + monitoring "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/monitoring" + monitoringBeta "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/monitoring/beta" orgpolicy "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy" orgpolicyBeta "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/beta" privateca "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca" @@ -71,6 +73,10 @@ func DCLToTerraformReference(resourceType, version string) (string, error) { return "google_gke_hub_feature", nil case "GkeHubFeatureMembership": return "google_gke_hub_feature_membership", nil + case "MonitoringMetricsScope": + return "google_monitoring_metrics_scope", nil + case "MonitoringMonitoredProject": + return "google_monitoring_monitored_project", nil case "OrgPolicyPolicy": return "google_org_policy_policy", nil case "PrivatecaCertificateTemplate": @@ -99,6 +105,10 @@ func DCLToTerraformReference(resourceType, version string) (string, error) { return "google_dataproc_workflow_template", nil case "EventarcTrigger": return "google_eventarc_trigger", nil + case "MonitoringMetricsScope": + return "google_monitoring_metrics_scope", nil + case "MonitoringMonitoredProject": + return "google_monitoring_monitored_project", nil case "OrgPolicyPolicy": return "google_org_policy_policy", nil case "PrivatecaCertificateTemplate": @@ -132,6 +142,10 @@ func DCLToTerraformSampleName(service, resource string) (string, string, error) return "Dataproc", "WorkflowTemplate", nil case "eventarctrigger": return "Eventarc", "Trigger", nil + case "monitoringmetricsscope": + return "Monitoring", "MetricsScope", nil + case "monitoringmonitoredproject": + return "Monitoring", "MonitoredProject", nil case "orgpolicypolicy": return "OrgPolicy", "Policy", nil case "privatecacertificatetemplate": @@ -224,6 +238,18 @@ func ConvertSampleJSONToHCL(resourceType string, version string, b []byte) (stri return "", err } return GkeHubFeatureMembershipBetaAsHCL(*r) + case "MonitoringMetricsScope": + r := &monitoringBeta.MetricsScope{} + if err := json.Unmarshal(b, r); err != nil { + return "", err + } + return MonitoringMetricsScopeBetaAsHCL(*r) + case "MonitoringMonitoredProject": + r := &monitoringBeta.MonitoredProject{} + if err := json.Unmarshal(b, r); err != nil { + return "", err + } + return MonitoringMonitoredProjectBetaAsHCL(*r) case "OrgPolicyPolicy": r := &orgpolicyBeta.Policy{} if err := json.Unmarshal(b, r); err != nil { @@ -257,7 +283,7 @@ func ConvertSampleJSONToHCL(resourceType string, version string, b []byte) (stri if err := json.Unmarshal(b, r); err != nil { return "", err } - return CloudResourceManagerProjectAsHCL(*r) + return serializeGAProjectToHCL(*r) case "ComputeFirewallPolicy": r := &compute.FirewallPolicy{} if err := json.Unmarshal(b, r); err != nil { @@ -300,6 +326,18 @@ func ConvertSampleJSONToHCL(resourceType string, version string, b []byte) (stri return "", err } return EventarcTriggerAsHCL(*r) + case "MonitoringMetricsScope": + r := &monitoring.MetricsScope{} + if err := json.Unmarshal(b, r); err != nil { + return "", err + } + return MonitoringMetricsScopeAsHCL(*r) + case "MonitoringMonitoredProject": + r := &monitoring.MonitoredProject{} + if err := json.Unmarshal(b, r); err != nil { + return "", err + } + return MonitoringMonitoredProjectAsHCL(*r) case "OrgPolicyPolicy": r := &orgpolicy.Policy{} if err := json.Unmarshal(b, r); err != nil { @@ -2033,6 +2071,45 @@ func convertGkeHubFeatureMembershipBetaConfigmanagementPolicyControllerToHCL(r * return outputConfig + "}" } +// MonitoringMetricsScopeBetaAsHCL returns a string representation of the specified resource in HCL. +// The generated HCL will include every settable field as a literal - that is, no +// variables, no references. This may not be the best possible representation, but +// the crucial point is that `terraform import; terraform apply` will not produce +// any changes. We do not validate that the resource specified will pass terraform +// validation unless is an object returned from the API after an Apply. +func MonitoringMetricsScopeBetaAsHCL(r monitoringBeta.MetricsScope) (string, error) { + outputConfig := "resource \"google_monitoring_metrics_scope\" \"output\" {\n" + if r.Name != nil { + outputConfig += fmt.Sprintf("\tname = %#v\n", *r.Name) + } + return formatHCL(outputConfig + "}") +} + +func convertMonitoringMetricsScopeBetaMonitoredProjectsToHCL(r *monitoringBeta.MetricsScopeMonitoredProjects) string { + if r == nil { + return "" + } + outputConfig := "{\n" + return outputConfig + "}" +} + +// MonitoringMonitoredProjectBetaAsHCL returns a string representation of the specified resource in HCL. +// The generated HCL will include every settable field as a literal - that is, no +// variables, no references. This may not be the best possible representation, but +// the crucial point is that `terraform import; terraform apply` will not produce +// any changes. We do not validate that the resource specified will pass terraform +// validation unless is an object returned from the API after an Apply. +func MonitoringMonitoredProjectBetaAsHCL(r monitoringBeta.MonitoredProject) (string, error) { + outputConfig := "resource \"google_monitoring_monitored_project\" \"output\" {\n" + if r.MetricsScope != nil { + outputConfig += fmt.Sprintf("\tmetrics_scope = %#v\n", *r.MetricsScope) + } + if r.Name != nil { + outputConfig += fmt.Sprintf("\tname = %#v\n", *r.Name) + } + return formatHCL(outputConfig + "}") +} + // OrgPolicyPolicyBetaAsHCL returns a string representation of the specified resource in HCL. // The generated HCL will include every settable field as a literal - that is, no // variables, no references. This may not be the best possible representation, but @@ -3851,6 +3928,45 @@ func convertEventarcTriggerTransportPubsubToHCL(r *eventarc.TriggerTransportPubs return outputConfig + "}" } +// MonitoringMetricsScopeAsHCL returns a string representation of the specified resource in HCL. +// The generated HCL will include every settable field as a literal - that is, no +// variables, no references. This may not be the best possible representation, but +// the crucial point is that `terraform import; terraform apply` will not produce +// any changes. We do not validate that the resource specified will pass terraform +// validation unless is an object returned from the API after an Apply. +func MonitoringMetricsScopeAsHCL(r monitoring.MetricsScope) (string, error) { + outputConfig := "resource \"google_monitoring_metrics_scope\" \"output\" {\n" + if r.Name != nil { + outputConfig += fmt.Sprintf("\tname = %#v\n", *r.Name) + } + return formatHCL(outputConfig + "}") +} + +func convertMonitoringMetricsScopeMonitoredProjectsToHCL(r *monitoring.MetricsScopeMonitoredProjects) string { + if r == nil { + return "" + } + outputConfig := "{\n" + return outputConfig + "}" +} + +// MonitoringMonitoredProjectAsHCL returns a string representation of the specified resource in HCL. +// The generated HCL will include every settable field as a literal - that is, no +// variables, no references. This may not be the best possible representation, but +// the crucial point is that `terraform import; terraform apply` will not produce +// any changes. We do not validate that the resource specified will pass terraform +// validation unless is an object returned from the API after an Apply. +func MonitoringMonitoredProjectAsHCL(r monitoring.MonitoredProject) (string, error) { + outputConfig := "resource \"google_monitoring_monitored_project\" \"output\" {\n" + if r.MetricsScope != nil { + outputConfig += fmt.Sprintf("\tmetrics_scope = %#v\n", *r.MetricsScope) + } + if r.Name != nil { + outputConfig += fmt.Sprintf("\tname = %#v\n", *r.Name) + } + return formatHCL(outputConfig + "}") +} + // OrgPolicyPolicyAsHCL returns a string representation of the specified resource in HCL. // The generated HCL will include every settable field as a literal - that is, no // variables, no references. This may not be the best possible representation, but @@ -5855,6 +5971,28 @@ func convertGkeHubFeatureMembershipBetaConfigmanagementPolicyControllerList(i in return out } +func convertMonitoringMetricsScopeBetaMonitoredProjects(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "createTime": in["create_time"], + "name": in["name"], + } +} + +func convertMonitoringMetricsScopeBetaMonitoredProjectsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertMonitoringMetricsScopeBetaMonitoredProjects(v)) + } + return out +} + func convertOrgPolicyPolicyBetaSpec(i interface{}) map[string]interface{} { if i == nil { return nil @@ -7566,6 +7704,28 @@ func convertEventarcTriggerTransportPubsubList(i interface{}) (out []map[string] return out } +func convertMonitoringMetricsScopeMonitoredProjects(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "createTime": in["create_time"], + "name": in["name"], + } +} + +func convertMonitoringMetricsScopeMonitoredProjectsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertMonitoringMetricsScopeMonitoredProjects(v)) + } + return out +} + func convertOrgPolicyPolicySpec(i interface{}) map[string]interface{} { if i == nil { return nil diff --git a/tpgtools/serialization_helpers.go b/tpgtools/serialization_helpers.go index dd104a5e9f76..34f7cfaf774b 100644 --- a/tpgtools/serialization_helpers.go +++ b/tpgtools/serialization_helpers.go @@ -21,7 +21,6 @@ func serializeBetaProjectToHCL(r cloudresourcemanagerBeta.Project) (string, erro return serializeProjectToHCL(m) } - func serializeGAProjectToHCL(r cloudresourcemanager.Project) (string, error) { b, err := json.Marshal(r) if err != nil { diff --git a/tpgtools/templates/resource.go.tmpl b/tpgtools/templates/resource.go.tmpl index 6a5a1601dfc2..b5d598c0a171 100644 --- a/tpgtools/templates/resource.go.tmpl +++ b/tpgtools/templates/resource.go.tmpl @@ -266,6 +266,9 @@ should be converted to use the DCL's ID method, so normalization can be uniform. billingProject = bp } client := NewDCL{{$.ProductType}}Client(config, userAgent, billingProject) + {{- if $.AppendToBasePath }} + client.Config.BasePath += "{{$.AppendToBasePath}}" + {{- end }} res, err := client.Apply{{$.Type}}(context.Background(), obj, createDirective...) if _, ok := err.(dcl.DiffAfterApplyError); ok { @@ -337,6 +340,9 @@ func resource{{$.PathType}}Read(d *schema.ResourceData, meta interface{}) error billingProject = bp } client := NewDCL{{$.ProductType}}Client(config, userAgent, billingProject) + {{- if $.AppendToBasePath }} + client.Config.BasePath += "{{$.AppendToBasePath}}" + {{- end }} res, err := client.Get{{$.Type}}(context.Background(), obj) if err != nil { resourceName := fmt.Sprintf("{{$.PathType}} %q", d.Id()) @@ -410,6 +416,9 @@ func resource{{$.PathType}}Update(d *schema.ResourceData, meta interface{}) erro billingProject = bp } client := NewDCL{{$.ProductType}}Client(config, userAgent, billingProject) + {{- if $.AppendToBasePath }} + client.Config.BasePath += "{{$.AppendToBasePath}}" + {{- end }} res, err := client.Apply{{$.Type}}(context.Background(), obj, directive...) if _, ok := err.(dcl.DiffAfterApplyError); ok { @@ -427,6 +436,10 @@ func resource{{$.PathType}}Update(d *schema.ResourceData, meta interface{}) erro {{- end }} func resource{{$.PathType}}Delete(d *schema.ResourceData, meta interface{}) error { +{{- if $.Undeletable }} + log.Printf(`[WARNING] {{$.PathType}} resources cannot be deleted from Google Cloud. +The resource %s will be removed from Terraform state, but will still be present on Google Cloud.`, d.Id()) +{{- else }} config := meta.(*Config) {{- range $v := .Properties }} @@ -462,14 +475,14 @@ func resource{{$.PathType}}Delete(d *schema.ResourceData, meta interface{}) erro {{ end }} {{- if $.SkipDeleteFunction }} - skip, err := {{$.SkipDeleteFunction}}(config, obj) - if err != nil { - return fmt.Errorf("error encountered in skip-delete: %v", err) - } - if skip { - return nil - } -{{- end}} + skip, err := {{$.SkipDeleteFunction}}(config, obj) + if err != nil { + return fmt.Errorf("error encountered in skip-delete: %v", err) + } + if skip { + return nil + } +{{- end }} log.Printf("[DEBUG] Deleting {{$.Type}} %q", d.Id()) userAgent, err := generateUserAgentString(d, config.userAgent) @@ -486,11 +499,15 @@ func resource{{$.PathType}}Delete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } client := NewDCL{{$.ProductType}}Client(config, userAgent, billingProject) + {{- if $.AppendToBasePath }} + client.Config.BasePath += "{{$.AppendToBasePath}}" + {{- end }} if err := client.Delete{{$.Type}}(context.Background(), obj); err != nil { return fmt.Errorf("Error deleting {{$.Type}}: %s", err) } log.Printf("[DEBUG] Finished deleting {{$.Type}} %q", d.Id()) +{{- end }} return nil } diff --git a/tpgtools/templates/serialization.go.tmpl b/tpgtools/templates/serialization.go.tmpl index 260700234c7b..0dec8ca53bf6 100644 --- a/tpgtools/templates/serialization.go.tmpl +++ b/tpgtools/templates/serialization.go.tmpl @@ -110,14 +110,18 @@ func ConvertSampleJSONToHCL(resourceType string, version string, b []byte) (stri {{- else }} // If not found in sample version, fallthrough to GA switch resourceType { - {{- range $res := $resList }} + {{- range $res := $resList }} case "{{$res.PathType}}": r := &{{$res.Package}}{{$version.SerializationSuffix}}.{{$res.Type}}{} if err := json.Unmarshal(b, r); err != nil { return "", err } - return {{$res.PathType}}{{$version.SerializationSuffix}}AsHCL(*r) - {{- end }} + {{- if $res.CustomSerializer }} + return {{$res.CustomSerializer}}(*r) + {{- else }} + return {{$res.PathType}}{{$version.SerializationSuffix}}AsHCL(*r) + {{- end }} + {{- end }} default: //return fmt.Sprintf("%s resource not supported in tpgtools", resourceType), nil return "", fmt.Errorf("Error converting sample JSON to HCL: %s not found", resourceType) diff --git a/tpgtools/templates/sweeper.go.tmpl b/tpgtools/templates/sweeper.go.tmpl index 01992e80076e..e2559f2369c9 100644 --- a/tpgtools/templates/sweeper.go.tmpl +++ b/tpgtools/templates/sweeper.go.tmpl @@ -29,13 +29,18 @@ package google import( +{{- if $.Undeletable }} + "log" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +{{- else }} "context" "log" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" {{$.Package}} "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/{{$.DCLPackage}}" - +{{- end }} ) func init() { @@ -45,9 +50,14 @@ func init() { }) } +{{- if $.Undeletable }} +func testSweep{{$.SweeperName}}(region string) error { + log.Print("[INFO][SWEEPER_LOG] No-op sweeper called for undeletable {{$.SweeperName}}") + return nil +} +{{- else }} func testSweep{{$.SweeperName}}(region string) error { - resourceName := "{{ $.SweeperName}}" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s",resourceName) + log.Print("[INFO][SWEEPER_LOG] Starting sweeper for {{$.SweeperName}}") config, err := sharedConfigForRegion(region) if err != nil { @@ -84,3 +94,4 @@ func testSweep{{$.SweeperName}}(region string) error { func isDeletable{{$.SweeperName}}(r *{{$.Package}}.{{$.Type}}) bool { return isSweepableTestResource(*r.Name) } +{{- end }}