From b2bbc9304bff4cfd6eca547f4cb3756d07ac4913 Mon Sep 17 00:00:00 2001 From: Zhenhua Li Date: Thu, 18 Apr 2024 11:08:37 -0700 Subject: [PATCH] Trim white spaces --- mmv1/main.go | 2 + mmv1/template-converter.go | 326 ++++++++++++++++++ .../cloud_identity_group_membership.go.tmpl | 4 +- .../custom_update/go/secret_version.go.tmpl | 4 +- .../decoders/go/backend_service.go.tmpl | 4 +- .../go/bigquery_data_transfer.go.tmpl | 4 +- .../terraform/decoders/go/cloud_run.go.tmpl | 4 +- ...neranalysis_attestation_field_name.go.tmpl | 10 +- .../go/containeranalysis_occurrence.go.tmpl | 10 +- .../decoders/go/dlp_job_trigger.go.tmpl | 4 +- .../decoders/go/dlp_template_id.go.tmpl | 4 +- .../decoders/go/firestore_document.go.tmpl | 4 +- .../terraform/decoders/go/kms.go.tmpl | 4 +- .../go/long_name_to_self_link.go.tmpl | 4 +- .../go/monitoring_monitored_project.go.tmpl | 4 +- .../monitoring_notification_channel.go.tmpl | 4 +- .../decoders/go/network_endpoint.go.tmpl | 4 +- .../decoders/go/network_endpoints.go.tmpl | 4 +- .../go/region_backend_service.go.tmpl | 8 +- .../terraform/decoders/go/snapshot.go.tmpl | 4 +- ...sql_source_representation_instance.go.tmpl | 4 +- .../go/treat_destroyed_state_as_gone.tmpl | 4 +- .../decoders/go/unwrap_global_neg.go.tmpl | 4 +- .../decoders/go/unwrap_resource.go.tmpl | 4 +- .../go/access_level_never_send_parent.go.tmpl | 4 +- .../go/active_directory_domain_trust.go.tmpl | 4 +- .../encoders/go/backend_service.go.tmpl | 4 +- .../go/bigquery_data_transfer.go.tmpl | 4 +- .../encoders/go/bigquery_job.go.tmpl | 4 +- .../encoders/go/bigtable_app_profile.go.tmpl | 10 +- .../go/cloud_run_domain_mapping.go.tmpl | 4 +- .../encoders/go/cloud_run_service.go.tmpl | 4 +- .../go/cloudbuildv2_repository.go.tmpl | 4 +- .../go/clouddomains_registration.go.tmpl | 4 +- .../compute_global_network_endpoint.go.tmpl | 4 +- .../compute_instance_group_membership.go.tmpl | 4 +- .../go/compute_network_endpoint.go.tmpl | 4 +- .../go/compute_network_endpoints.go.tmpl | 4 +- .../go/compute_per_instance_config.go.tmpl | 4 +- .../compute_region_network_endpoint.go.tmpl | 4 +- ...neranalysis_attestation_field_name.go.tmpl | 10 +- .../go/containeranalysis_occurrence.go.tmpl | 10 +- .../encoders/go/datastream_stream.go.tmpl | 4 +- .../templates/terraform/encoders/go/disk.tmpl | 8 +- .../encoders/go/dlp_job_trigger.go.tmpl | 4 +- .../encoders/go/dlp_stored_info_type.go.tmpl | 4 +- .../encoders/go/health_check_type.tmpl | 4 +- .../terraform/encoders/go/index.go.tmpl | 4 +- .../encoders/go/kms_crypto_key.go.tmpl | 4 +- .../encoders/go/location_from_region.go.tmpl | 4 +- .../go/logging_linked_dataset.go.tmpl | 4 +- .../encoders/go/logging_log_view.go.tmpl | 4 +- .../go/monitoring_monitored_project.go.tmpl | 4 +- .../monitoring_notification_channel.go.tmpl | 4 +- .../encoders/go/monitoring_service.go.tmpl | 4 +- .../encoders/go/monitoring_slo.go.tmpl | 4 +- .../go/network_peering_routes_config.go.tmpl | 4 +- .../encoders/go/no_send_name.go.tmpl | 4 +- ...edis_location_id_for_fallback_zone.go.tmpl | 4 +- .../go/region_backend_service.go.tmpl | 8 +- .../encoders/go/spanner_database.go.tmpl | 6 +- ...sql_source_representation_instance.go.tmpl | 4 +- .../terraform/encoders/go/wrap_object.go.tmpl | 4 +- ...t_with_deployment_resource_pool_id.go.tmpl | 4 +- .../go/wrap_object_with_template_id.go.tmpl | 4 +- .../go/bigquery_dataset_access.go.tmpl | 4 +- .../go/bigtable_app_profile.go.tmpl | 4 +- .../extra_schema_entry/go/firewall.tmpl | 4 +- ...cret_version_is_secret_data_base64.go.tmpl | 4 +- .../extra_schema_entry/go/subnetwork.tmpl | 4 +- .../go/bigquery_dataset_access.go.tmpl | 4 +- ...on_backend_service_security_policy.go.tmpl | 4 +- ...te_target_instance_security_policy.go.tmpl | 4 +- .../post_create/go/datastream_stream.go.tmpl | 4 +- .../go/firebase_database_instance.go.tmpl | 4 +- .../terraform/post_create/go/index.go.tmpl | 4 +- .../terraform/post_create/go/labels.tmpl | 12 +- 77 files changed, 504 insertions(+), 176 deletions(-) create mode 100644 mmv1/template-converter.go diff --git a/mmv1/main.go b/mmv1/main.go index 2167e309793c..eb58110cfdcf 100644 --- a/mmv1/main.go +++ b/mmv1/main.go @@ -27,6 +27,8 @@ var version = flag.String("version", "", "optional version name. If specified, t var product = flag.String("product", "", "optional product name. If specified, the resources under the specific product will be generated. Otherwise, resources under all products will be generated.") func main() { + convertTemplates() + flag.Parse() var generateCode = true var generateDocs = true diff --git a/mmv1/template-converter.go b/mmv1/template-converter.go new file mode 100644 index 000000000000..07a827aa62aa --- /dev/null +++ b/mmv1/template-converter.go @@ -0,0 +1,326 @@ +package main + +import ( + "fmt" + "io/ioutil" + "log" + "os" + "path" + "path/filepath" + "regexp" + "strings" + + "github.com/golang/glog" +) + +func find(root, ext string) []string { + var a []string + + files, err := ioutil.ReadDir(root) + if err != nil { + log.Fatal(err) + } + + for _, file := range files { + if filepath.Ext(file.Name()) == ext { + a = append(a, file.Name()) + } + } + return a +} + +func convertTemplates() { + folders := []string{"examples", "constants", "custom_check_destroy", "custom_create", "custom_delete", "custom_import", "custom_update", "decoders", "encoders", "extra_schema_entry", "post_create", "post_create_failure", "post_delete", "post_import", "post_update", "pre_create", "pre_delete", "pre_read", "pre_update", "state_migrations", "update_encoder", "custom_expand", "custom_flatten"} + counts := 0 + for _, folder := range folders { + counts += convertTemplate(folder) + } + log.Printf("%d template files in total", counts) +} + +func convertTemplate(folder string) int { + rubyDir := fmt.Sprintf("templates/terraform/%s", folder) + goDir := fmt.Sprintf("templates/terraform/%s/go", folder) + + // rubyDir := "templates/terraform" + // goDir := "templates/terraform" + if err := os.MkdirAll(goDir, os.ModePerm); err != nil { + glog.Error(fmt.Errorf("error creating directory %v: %v", goDir, err)) + } + + templates := find(rubyDir, ".erb") + // templates := []string{"expand_resource_ref.erb"} + log.Printf("%d template files in folder %s", len(templates), folder) + + for _, file := range templates { + data, err := os.ReadFile(path.Join(rubyDir, file)) + if err != nil { + log.Fatalf("Cannot open the file: %v", file) + } + + // Replace {{}} + r, err := regexp.Compile(`{{(.*?)}}`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{"{{"}}$1{{"}}"}}`)) + + // Replace primary_resource_id + r, err = regexp.Compile(`<%=\s*ctx\[:primary_resource_id\]\s*-?%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte("{{$.PrimaryResourceId}}")) + + // Replace vars + r, err = regexp.Compile(`<%=\s*ctx\[:vars\]\[('|")([a-zA-Z0-9_-]+)('|")\]\s*-?%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{index $.Vars "$2"}}`)) + + // Replace test_env_vars + r, err = regexp.Compile(`<%=\s*ctx\[:test_env_vars\]\[('|")([a-zA-Z0-9_-]+)('|")\]\s*-?%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{index $.TestEnvVars "$2"}}`)) + + // Replace <% unless compiler == "terraformgoogleconversion-codegen" -%> + r, err = regexp.Compile(`<% unless compiler == "terraformgoogleconversion-codegen" -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{- if ne $.Compiler "terraformgoogleconversion-codegen" }}`)) + + // Replace <% unless version == 'ga' -%> + r, err = regexp.Compile(`<% unless version == ['|"]ga['|"] -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{- if ne $.TargetVersionName "ga" }}`)) + + // Replace <% if version == 'ga' -%> + r, err = regexp.Compile(`<% if version == 'ga' -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{- if eq $.TargetVersionName "ga" }}`)) + + // Replace <% else -%> + r, err = regexp.Compile(`<% else -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{- else }}`)) + + // Replace <%= object.name -%> + r, err = regexp.Compile(`<%= object.name -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{$.Name}}`)) + + // Replace <%= object.resource_name -%> + r, err = regexp.Compile(`<%= object.resource_name -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{$.ResourceName}}`)) + + // Replace <%=object.self_link_uri-%> + r, err = regexp.Compile(`<%=object.self_link_uri-%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{$.SelfLinkUri}}`)) + + // Replace <%=object.create_uri-%> + r, err = regexp.Compile(`<%=object.create_uri-%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{$.CreateUri}}`)) + + // Replace <%=object.base_url-%> + r, err = regexp.Compile(`<%=object.base_url-%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{$.BaseUrl}}`)) + + // Replace <%=object.__product.name-%> + r, err = regexp.Compile(`<%=object.__product.name-%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{$.ProductMetadata.Name}}`)) + + // Replace <% if object.name == 'Disk' -%> + r, err = regexp.Compile(`<% if object.name == 'Disk' -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{- if eq $.Name "Disk" }}`)) + + // Replace <% elsif object.name == 'RegionDisk' -%> + r, err = regexp.Compile(`<% elsif object.name == 'RegionDisk' -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{- else if eq $.Name "RegionDisk" }}`)) + + // Replace <% if object.properties.any?{ |p| p.name == "labels" } -%> + r, err = regexp.Compile(`<% if object\.properties.any\?\{ \|p\| p\.name == "labels" \} -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{- if $.HasLabelsField }}`)) + + // Replace <% if object.error_retry_predicates -%> + r, err = regexp.Compile(`<% if object.error_retry_predicates -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{- if $.ErrorRetryPredicates }}`)) + + // Replace <% if object.error_abort_predicates -%> + r, err = regexp.Compile(`<% if object.error_abort_predicates -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{- if $.ErrorAbortPredicates }}`)) + + // Replace <%= object.error_retry_predicates.join(',') -%> + r, err = regexp.Compile(`<%= object.error_retry_predicates.join\(','\) -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(` {{- join $.ErrorRetryPredicates "," -}} `)) + + // Replace <%= object.error_abort_predicates.join(',') -%> + r, err = regexp.Compile(`<%= object.error_abort_predicates.join\(','\) -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(` {{- join $.ErrorAbortPredicates "," -}} `)) + + // Replace <%= object.name.camelize(:lower) -%> + r, err = regexp.Compile(`<%= object.name.camelize\(:lower\) -?%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{camelize $.Name "lower"}}`)) + + // Replace <%= object.name.plural.camelize(:lower) -%> + r, err = regexp.Compile(`<%= object.name.plural.camelize\(:lower\) -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{camelize (plural $.Name) "lower"}}`)) + + // Replace <%= id_format(object) -%> + r, err = regexp.Compile(`<%= id_format\(object\) -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{$.GetIdFormat}}`)) + + // Replace <%= prefix -%> + r, err = regexp.Compile(`<%= prefix -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{$.GetPrefix}}`)) + + // Replace <%= titlelize_property(property) -%> + r, err = regexp.Compile(`<%= titlelize_property\(property\) -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{$.TitlelizeProperty}}`)) + + // Replace <%= build_expand_resource_ref('v.(string)', property, pwd) %> + r, err = regexp.Compile(`<%= build_expand_resource_ref\('v\.\(string\)', property, pwd\) %>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{ template "expandResourceRef" dict "VarName" "v.(string)" "Property" $ }}`)) + + // Replace <%= build_expand_resource_ref('raw.(string)', property.item_type, pwd) %> + r, err = regexp.Compile(`<%= build_expand_resource_ref\('raw\.\(string\)', property\.item_type, pwd\) %>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{ template "expandResourceRef" dict "VarName" "raw.(string)" "Property" $.ItemType }}`)) + + // Replace <%= property.name.underscore -%> + r, err = regexp.Compile(`<%= property.name.underscore -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{underscore $.Name}}`)) + + // Replace <%= resource_type -%> + r, err = regexp.Compile(`<%= resource_type -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{$.ResourceType}}`)) + + // Replace <% if property.is_set -%> + r, err = regexp.Compile(`<% if property.is_set -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{- if $.IsSet }}`)) + + // Replace <% end -%> + r, err = regexp.Compile(`<%\s*end -%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{- end }}`)) + + copyRight := `{{- /* + The license inside this block applies to this file + 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. +*/}}` + // Replace copyright + r, err = regexp.Compile(`(?s)<%[-\s#]*[tT]he license inside this.*?limitations under the License..*?%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(copyRight)) + + // Replace comments + r, err = regexp.Compile(`(?s)<%#-?\s?(.*?)\s?-?%>`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`{{- /* $1 */}}`)) + + // Replace .erb + r, err = regexp.Compile(`\.erb`) + if err != nil { + log.Fatalf("Cannot compile the regular expression: %v", err) + } + data = r.ReplaceAll(data, []byte(`.tmpl`)) + + goTemplate := strings.Replace(file, "erb", "tmpl", 1) + err = ioutil.WriteFile(path.Join(goDir, goTemplate), data, 0644) + if err != nil { + glog.Exit(err) + } + } + + return len(templates) +} diff --git a/mmv1/templates/terraform/custom_update/go/cloud_identity_group_membership.go.tmpl b/mmv1/templates/terraform/custom_update/go/cloud_identity_group_membership.go.tmpl index 8d96645bf54b..c1105aaf3c66 100644 --- a/mmv1/templates/terraform/custom_update/go/cloud_identity_group_membership.go.tmpl +++ b/mmv1/templates/terraform/custom_update/go/cloud_identity_group_membership.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { return err diff --git a/mmv1/templates/terraform/custom_update/go/secret_version.go.tmpl b/mmv1/templates/terraform/custom_update/go/secret_version.go.tmpl index cf1b1c26f112..fcd1f4a1b159 100644 --- a/mmv1/templates/terraform/custom_update/go/secret_version.go.tmpl +++ b/mmv1/templates/terraform/custom_update/go/secret_version.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} _, err := expandSecretManagerSecretVersionEnabled(d.Get("enabled"), d, config) if err != nil { return err diff --git a/mmv1/templates/terraform/decoders/go/backend_service.go.tmpl b/mmv1/templates/terraform/decoders/go/backend_service.go.tmpl index a450b789a2d2..f61950b4226c 100644 --- a/mmv1/templates/terraform/decoders/go/backend_service.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/backend_service.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // We need to pretend IAP isn't there if it's disabled for Terraform to maintain // BC behaviour with the handwritten resource. v, ok := res["iap"] diff --git a/mmv1/templates/terraform/decoders/go/bigquery_data_transfer.go.tmpl b/mmv1/templates/terraform/decoders/go/bigquery_data_transfer.go.tmpl index af0e0c5727ec..41564182db0c 100644 --- a/mmv1/templates/terraform/decoders/go/bigquery_data_transfer.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/bigquery_data_transfer.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} if paramMap, ok := res["params"]; ok { params := paramMap.(map[string]interface{}) for _, sp := range sensitiveParams { diff --git a/mmv1/templates/terraform/decoders/go/cloud_run.go.tmpl b/mmv1/templates/terraform/decoders/go/cloud_run.go.tmpl index 75c7ae2eddc2..e1c05d03d3a1 100644 --- a/mmv1/templates/terraform/decoders/go/cloud_run.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/cloud_run.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // metadata is not present if the API returns an error if obj, ok := res["metadata"]; ok { if meta, ok := obj.(map[string]interface{}); ok { diff --git a/mmv1/templates/terraform/decoders/go/containeranalysis_attestation_field_name.go.tmpl b/mmv1/templates/terraform/decoders/go/containeranalysis_attestation_field_name.go.tmpl index d5e9d57f9bbe..be338c044b6a 100644 --- a/mmv1/templates/terraform/decoders/go/containeranalysis_attestation_field_name.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/containeranalysis_attestation_field_name.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,13 +9,13 @@ 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. -*/ -}} -{{ if eq $.TargetVersionName "ga" -}} +*/}} +{{- if eq $.TargetVersionName "ga" }} // Field was renamed in GA API res["attestationAuthority"] = res["attestation"] delete(res, "attestation") -{{ else -}} +{{- else }} // decoder logic only in GA provider -{{ end -}} +{{- end }} return res, nil diff --git a/mmv1/templates/terraform/decoders/go/containeranalysis_occurrence.go.tmpl b/mmv1/templates/terraform/decoders/go/containeranalysis_occurrence.go.tmpl index e66c69abf682..f246d5331eef 100644 --- a/mmv1/templates/terraform/decoders/go/containeranalysis_occurrence.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/containeranalysis_occurrence.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,8 +9,8 @@ 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. -*/ -}} -{{ if ne $.TargetVersionName "ga" -}} +*/}} +{{- if ne $.TargetVersionName "ga" }} // Resource object was flattened in GA API if nestedResource, ok := res["resource"]; ok { if resObj, ok := nestedResource.(map[string]interface{}); ok { @@ -35,7 +35,7 @@ if attV, ok := res["attestation"]; ok && attV != nil { } } -{{ else -}} +{{- else }} // encoder logic only in non-GA version -{{ end -}} +{{- end }} return res, nil diff --git a/mmv1/templates/terraform/decoders/go/dlp_job_trigger.go.tmpl b/mmv1/templates/terraform/decoders/go/dlp_job_trigger.go.tmpl index d9822e88ccab..3cda81929e95 100644 --- a/mmv1/templates/terraform/decoders/go/dlp_job_trigger.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/dlp_job_trigger.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} config := meta.(*transport_tpg.Config) if err := d.Set("trigger_id", flattenDataLossPrevention{{$.Name}}Name(res["name"], d, config)); err != nil { return nil, fmt.Errorf("Error reading {{$.Name}}: %s", err) diff --git a/mmv1/templates/terraform/decoders/go/dlp_template_id.go.tmpl b/mmv1/templates/terraform/decoders/go/dlp_template_id.go.tmpl index a185e1fc41c2..beb0a871f0ac 100644 --- a/mmv1/templates/terraform/decoders/go/dlp_template_id.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/dlp_template_id.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} config := meta.(*transport_tpg.Config) if err := d.Set("template_id", flattenDataLossPrevention{{$.Name}}Name(res["name"], d, config)); err != nil { return nil, fmt.Errorf("Error reading {{$.Name}}: %s", err) diff --git a/mmv1/templates/terraform/decoders/go/firestore_document.go.tmpl b/mmv1/templates/terraform/decoders/go/firestore_document.go.tmpl index 5b2e6ab08deb..6ad0249ee9c9 100644 --- a/mmv1/templates/terraform/decoders/go/firestore_document.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/firestore_document.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // We use this decoder to add the path field if name, ok := res["name"]; ok { re := regexp.MustCompile("^projects/[^/]+/databases/[^/]+/documents/(.+)$") diff --git a/mmv1/templates/terraform/decoders/go/kms.go.tmpl b/mmv1/templates/terraform/decoders/go/kms.go.tmpl index 2b164f430606..a1f9936efacb 100644 --- a/mmv1/templates/terraform/decoders/go/kms.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/kms.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // Modify the name to be the user specified form. // We can't just ignore_read on `name` as the linter will // complain that the returned `res` is never used afterwards. diff --git a/mmv1/templates/terraform/decoders/go/long_name_to_self_link.go.tmpl b/mmv1/templates/terraform/decoders/go/long_name_to_self_link.go.tmpl index fdc6c379d77e..c03ada0c8390 100644 --- a/mmv1/templates/terraform/decoders/go/long_name_to_self_link.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/long_name_to_self_link.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // Take the returned long form of the name and use it as `self_link`. // Then modify the name to be the user specified form. // We can't just ignore_read on `name` as the linter will diff --git a/mmv1/templates/terraform/decoders/go/monitoring_monitored_project.go.tmpl b/mmv1/templates/terraform/decoders/go/monitoring_monitored_project.go.tmpl index d73a4d9eef33..82c8ab576e83 100644 --- a/mmv1/templates/terraform/decoders/go/monitoring_monitored_project.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/monitoring_monitored_project.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // terraform resource config config := meta.(*transport_tpg.Config) diff --git a/mmv1/templates/terraform/decoders/go/monitoring_notification_channel.go.tmpl b/mmv1/templates/terraform/decoders/go/monitoring_notification_channel.go.tmpl index 7803ca8a892e..e5fad1a3ecf8 100644 --- a/mmv1/templates/terraform/decoders/go/monitoring_notification_channel.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/monitoring_notification_channel.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} if labelmap, ok := res["labels"]; ok { labels := labelmap.(map[string]interface{}) for _, sl := range sensitiveLabels { diff --git a/mmv1/templates/terraform/decoders/go/network_endpoint.go.tmpl b/mmv1/templates/terraform/decoders/go/network_endpoint.go.tmpl index 81512e4897ce..8f14dc675325 100644 --- a/mmv1/templates/terraform/decoders/go/network_endpoint.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/network_endpoint.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} v, ok := res["networkEndpoint"] if !ok || v == nil { return res, nil diff --git a/mmv1/templates/terraform/decoders/go/network_endpoints.go.tmpl b/mmv1/templates/terraform/decoders/go/network_endpoints.go.tmpl index 1a6e010556e7..663a3175d5da 100644 --- a/mmv1/templates/terraform/decoders/go/network_endpoints.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/network_endpoints.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/mmv1/templates/terraform/decoders/go/region_backend_service.go.tmpl b/mmv1/templates/terraform/decoders/go/region_backend_service.go.tmpl index 2bec9468e6f5..a5115fb455ae 100644 --- a/mmv1/templates/terraform/decoders/go/region_backend_service.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/region_backend_service.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // We need to pretend IAP isn't there if it's disabled for Terraform to maintain // BC behaviour with the handwritten resource. v, ok := res["iap"] @@ -22,7 +22,7 @@ if ok && m["enabled"] == false { delete(res, "iap") } -{{ if ne $.TargetVersionName "ga" -}} +{{- if ne $.TargetVersionName "ga" }} // Since we add in a NONE subsetting policy, we need to remove it in some // cases for backwards compatibility with the config v, ok = res["subsetting"] @@ -33,7 +33,7 @@ if ok && v != nil { delete(res, "subsetting") } } -{{ end -}} +{{- end }} // Requests with consistentHash will error for specific values of // localityLbPolicy. However, the API will not remove it if the backend diff --git a/mmv1/templates/terraform/decoders/go/snapshot.go.tmpl b/mmv1/templates/terraform/decoders/go/snapshot.go.tmpl index 8d47ae4cd1c4..f12238dabb2f 100644 --- a/mmv1/templates/terraform/decoders/go/snapshot.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/snapshot.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} if v, ok := res["snapshotEncryptionKey"]; ok { original := v.(map[string]interface{}) transformed := make(map[string]interface{}) diff --git a/mmv1/templates/terraform/decoders/go/sql_source_representation_instance.go.tmpl b/mmv1/templates/terraform/decoders/go/sql_source_representation_instance.go.tmpl index 8a728c49e9e2..381e1903c103 100644 --- a/mmv1/templates/terraform/decoders/go/sql_source_representation_instance.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/sql_source_representation_instance.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} if v, ok := res["onPremisesConfiguration"]; ok { opc := v.(map[string]interface{}) hostPort := opc["hostPort"] diff --git a/mmv1/templates/terraform/decoders/go/treat_destroyed_state_as_gone.tmpl b/mmv1/templates/terraform/decoders/go/treat_destroyed_state_as_gone.tmpl index a553298d2689..2a75e3922480 100644 --- a/mmv1/templates/terraform/decoders/go/treat_destroyed_state_as_gone.tmpl +++ b/mmv1/templates/terraform/decoders/go/treat_destroyed_state_as_gone.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} if v := res["state"]; v == "DESTROYED" { return nil, nil } diff --git a/mmv1/templates/terraform/decoders/go/unwrap_global_neg.go.tmpl b/mmv1/templates/terraform/decoders/go/unwrap_global_neg.go.tmpl index 81512e4897ce..8f14dc675325 100644 --- a/mmv1/templates/terraform/decoders/go/unwrap_global_neg.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/unwrap_global_neg.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} v, ok := res["networkEndpoint"] if !ok || v == nil { return res, nil diff --git a/mmv1/templates/terraform/decoders/go/unwrap_resource.go.tmpl b/mmv1/templates/terraform/decoders/go/unwrap_resource.go.tmpl index e6e3722d5c81..7a798ecda836 100644 --- a/mmv1/templates/terraform/decoders/go/unwrap_resource.go.tmpl +++ b/mmv1/templates/terraform/decoders/go/unwrap_resource.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} v, ok := res["{{camelize $.Name "lower"}}"] if !ok || v == nil { return res, nil diff --git a/mmv1/templates/terraform/encoders/go/access_level_never_send_parent.go.tmpl b/mmv1/templates/terraform/encoders/go/access_level_never_send_parent.go.tmpl index 41ee03cf3cad..7fc837505699 100644 --- a/mmv1/templates/terraform/encoders/go/access_level_never_send_parent.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/access_level_never_send_parent.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,6 +9,6 @@ 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. -*/ -}} +*/}} delete(obj, "parent") return obj, nil diff --git a/mmv1/templates/terraform/encoders/go/active_directory_domain_trust.go.tmpl b/mmv1/templates/terraform/encoders/go/active_directory_domain_trust.go.tmpl index a8caa4f136f6..ab6867c3163f 100644 --- a/mmv1/templates/terraform/encoders/go/active_directory_domain_trust.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/active_directory_domain_trust.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} wrappedReq := map[string]interface{}{ "trust": obj, diff --git a/mmv1/templates/terraform/encoders/go/backend_service.go.tmpl b/mmv1/templates/terraform/encoders/go/backend_service.go.tmpl index 9e5e106529b1..2010d4d0d522 100644 --- a/mmv1/templates/terraform/encoders/go/backend_service.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/backend_service.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // The BackendService API's Update / PUT API is badly formed and behaves like // a PATCH field for at least IAP. When sent a `null` `iap` field, the API // doesn't disable an existing field. To work around this, we need to emulate diff --git a/mmv1/templates/terraform/encoders/go/bigquery_data_transfer.go.tmpl b/mmv1/templates/terraform/encoders/go/bigquery_data_transfer.go.tmpl index 97f0d598ef0d..9b790f9795e6 100644 --- a/mmv1/templates/terraform/encoders/go/bigquery_data_transfer.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/bigquery_data_transfer.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} paramMap, ok := obj["params"] if !ok { paramMap = make(map[string]string) diff --git a/mmv1/templates/terraform/encoders/go/bigquery_job.go.tmpl b/mmv1/templates/terraform/encoders/go/bigquery_job.go.tmpl index 82dd77698012..f9f9dc1b3f09 100644 --- a/mmv1/templates/terraform/encoders/go/bigquery_job.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/bigquery_job.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} project, err := tpgresource.GetProject(d, meta.(*transport_tpg.Config)) if err != nil { return nil, err diff --git a/mmv1/templates/terraform/encoders/go/bigtable_app_profile.go.tmpl b/mmv1/templates/terraform/encoders/go/bigtable_app_profile.go.tmpl index 23906686d722..95655c650282 100644 --- a/mmv1/templates/terraform/encoders/go/bigtable_app_profile.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/bigtable_app_profile.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,10 +9,10 @@ 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. -*/ -}} -{{/* Because instance is a URL param only, it does not get expanded and - the URL is constructed from ResourceData. Set it in - state and use a encoder instead of a field expander */ -}} +*/}} +{{- /* Because instance is a URL param only, it does not get expanded and + # the URL is constructed from ResourceData. Set it in + # state and use a encoder instead of a field expander */}} // Instance is a URL parameter only, so replace self-link/path with resource name only. if err := d.Set("instance", tpgresource.GetResourceNameFromSelfLink(d.Get("instance").(string))); err != nil { return nil, fmt.Errorf("Error setting instance: %s", err) diff --git a/mmv1/templates/terraform/encoders/go/cloud_run_domain_mapping.go.tmpl b/mmv1/templates/terraform/encoders/go/cloud_run_domain_mapping.go.tmpl index c49a7e1d22a5..6a8c49c77d12 100644 --- a/mmv1/templates/terraform/encoders/go/cloud_run_domain_mapping.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/cloud_run_domain_mapping.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} name := d.Get("name").(string) metadata := obj["metadata"].(map[string]interface{}) metadata["name"] = name diff --git a/mmv1/templates/terraform/encoders/go/cloud_run_service.go.tmpl b/mmv1/templates/terraform/encoders/go/cloud_run_service.go.tmpl index c8d14be22d86..931fcc3d8b7a 100644 --- a/mmv1/templates/terraform/encoders/go/cloud_run_service.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/cloud_run_service.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} name := d.Get("name").(string) if obj["metadata"] == nil { obj["metadata"] = make(map[string]interface{}) diff --git a/mmv1/templates/terraform/encoders/go/cloudbuildv2_repository.go.tmpl b/mmv1/templates/terraform/encoders/go/cloudbuildv2_repository.go.tmpl index 774ec930ebc6..6b7753d1833c 100644 --- a/mmv1/templates/terraform/encoders/go/cloudbuildv2_repository.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/cloudbuildv2_repository.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} config := meta.(*transport_tpg.Config) // Extract any empty fields from the parent_connection field. project, err := tpgresource.GetProject(d, config) diff --git a/mmv1/templates/terraform/encoders/go/clouddomains_registration.go.tmpl b/mmv1/templates/terraform/encoders/go/clouddomains_registration.go.tmpl index 2318d7bf745b..b816af3ec4c9 100644 --- a/mmv1/templates/terraform/encoders/go/clouddomains_registration.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/clouddomains_registration.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // Request body is registration object with additional fields // See https://cloud.google.com/domains/docs/reference/rest/v1beta1/projects.locations.registrations/register diff --git a/mmv1/templates/terraform/encoders/go/compute_global_network_endpoint.go.tmpl b/mmv1/templates/terraform/encoders/go/compute_global_network_endpoint.go.tmpl index afdad43d13ac..891aae34803d 100644 --- a/mmv1/templates/terraform/encoders/go/compute_global_network_endpoint.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/compute_global_network_endpoint.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // Network Endpoint Group is a URL parameter only, so replace self-link/path with resource name only. if err := d.Set("global_network_endpoint_group", tpgresource.GetResourceNameFromSelfLink(d.Get("global_network_endpoint_group").(string))); err != nil { return nil, fmt.Errorf("Error setting global_network_endpoint_group: %s", err) diff --git a/mmv1/templates/terraform/encoders/go/compute_instance_group_membership.go.tmpl b/mmv1/templates/terraform/encoders/go/compute_instance_group_membership.go.tmpl index 2b34cfed8496..53133ee4dd63 100644 --- a/mmv1/templates/terraform/encoders/go/compute_instance_group_membership.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/compute_instance_group_membership.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // Instance Group is a URL parameter only, so replace self-link/path with resource name only. if err := d.Set("instance_group", tpgresource.GetResourceNameFromSelfLink(d.Get("instance_group").(string))); err != nil { return nil, fmt.Errorf("Error setting instance_group: %s", err) diff --git a/mmv1/templates/terraform/encoders/go/compute_network_endpoint.go.tmpl b/mmv1/templates/terraform/encoders/go/compute_network_endpoint.go.tmpl index 7eb62eaa6559..561d8442f926 100644 --- a/mmv1/templates/terraform/encoders/go/compute_network_endpoint.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/compute_network_endpoint.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // Network Endpoint Group is a URL parameter only, so replace self-link/path with resource name only. if err := d.Set("network_endpoint_group", tpgresource.GetResourceNameFromSelfLink(d.Get("network_endpoint_group").(string))); err != nil { return nil, fmt.Errorf("Error setting network_endpoint_group: %s", err) diff --git a/mmv1/templates/terraform/encoders/go/compute_network_endpoints.go.tmpl b/mmv1/templates/terraform/encoders/go/compute_network_endpoints.go.tmpl index 0e6a92221795..be414662887d 100644 --- a/mmv1/templates/terraform/encoders/go/compute_network_endpoints.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/compute_network_endpoints.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // Network Endpoint Group is a URL parameter only, so replace self-link/path with resource name only. if err := d.Set("network_endpoint_group", tpgresource.GetResourceNameFromSelfLink(d.Get("network_endpoint_group").(string))); err != nil { return nil, fmt.Errorf("Error setting network_endpoint_group: %s", err) diff --git a/mmv1/templates/terraform/encoders/go/compute_per_instance_config.go.tmpl b/mmv1/templates/terraform/encoders/go/compute_per_instance_config.go.tmpl index 00852f2d73d9..1797a0f90509 100644 --- a/mmv1/templates/terraform/encoders/go/compute_per_instance_config.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/compute_per_instance_config.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} wrappedReq := map[string]interface{}{ "instances": []interface{}{obj}, } diff --git a/mmv1/templates/terraform/encoders/go/compute_region_network_endpoint.go.tmpl b/mmv1/templates/terraform/encoders/go/compute_region_network_endpoint.go.tmpl index ba4ccb7747b7..6bbad31d623c 100644 --- a/mmv1/templates/terraform/encoders/go/compute_region_network_endpoint.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/compute_region_network_endpoint.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // Network Endpoint Group is a URL parameter only, so replace self-link/path with resource name only. if err := d.Set("region_network_endpoint_group", tpgresource.GetResourceNameFromSelfLink(d.Get("region_network_endpoint_group").(string))); err != nil { return nil, fmt.Errorf("Error setting region_network_endpoint_group: %s", err) diff --git a/mmv1/templates/terraform/encoders/go/containeranalysis_attestation_field_name.go.tmpl b/mmv1/templates/terraform/encoders/go/containeranalysis_attestation_field_name.go.tmpl index dcabb68d8820..0ad87829a3b2 100644 --- a/mmv1/templates/terraform/encoders/go/containeranalysis_attestation_field_name.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/containeranalysis_attestation_field_name.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,13 +9,13 @@ 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. -*/ -}} -{{ if eq $.TargetVersionName "ga" -}} +*/}} +{{- if eq $.TargetVersionName "ga" }} // Field was renamed in GA API obj["attestation"] = obj["attestationAuthority"] delete(obj, "attestationAuthority") -{{ else -}} +{{- else }} // encoder logic only in GA provider -{{ end -}} +{{- end }} return obj, nil diff --git a/mmv1/templates/terraform/encoders/go/containeranalysis_occurrence.go.tmpl b/mmv1/templates/terraform/encoders/go/containeranalysis_occurrence.go.tmpl index 3c22971c97e3..b8f8a1148758 100644 --- a/mmv1/templates/terraform/encoders/go/containeranalysis_occurrence.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/containeranalysis_occurrence.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,8 +9,8 @@ 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. -*/ -}} -{{ if ne $.TargetVersionName "ga" -}} +*/}} +{{- if ne $.TargetVersionName "ga" }} // Resource object was flattened in GA API if resourceuri, ok := obj["resourceUri"]; ok { obj["resource"] = map[string]interface{}{ @@ -34,8 +34,8 @@ if v, ok := obj["attestation"]; ok && v != nil { }, } } -{{ else -}} +{{- else }} // encoder logic only in non-GA versions -{{ end -}} +{{- end }} return obj, nil diff --git a/mmv1/templates/terraform/encoders/go/datastream_stream.go.tmpl b/mmv1/templates/terraform/encoders/go/datastream_stream.go.tmpl index 058137dbc15a..1b83ca8f749f 100644 --- a/mmv1/templates/terraform/encoders/go/datastream_stream.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/datastream_stream.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} if d.HasChange("desired_state") { obj["state"] = d.Get("desired_state") } diff --git a/mmv1/templates/terraform/encoders/go/disk.tmpl b/mmv1/templates/terraform/encoders/go/disk.tmpl index fdb08b43318a..d32ecae6a410 100644 --- a/mmv1/templates/terraform/encoders/go/disk.tmpl +++ b/mmv1/templates/terraform/encoders/go/disk.tmpl @@ -10,7 +10,7 @@ if err != nil { return nil, err } -{{ if eq $.Name "Disk" -}} +{{- if eq $.Name "Disk" }} if v, ok := d.GetOk("type"); ok { log.Printf("[DEBUG] Loading disk type: %s", v.(string)) diskType, err := readDiskType(config, d, v.(string)) @@ -22,7 +22,7 @@ if v, ok := d.GetOk("type"); ok { obj["type"] = diskType.RelativeLink() } -{{ else if eq $.Name "RegionDisk" -}} +{{- else if eq $.Name "RegionDisk" }} if v, ok := d.GetOk("type"); ok { log.Printf("[DEBUG] Loading disk type: %s", v.(string)) diskType, err := readRegionDiskType(config, d, v.(string)) @@ -34,9 +34,9 @@ if v, ok := d.GetOk("type"); ok { obj["type"] = diskType.RelativeLink() } -{{ else -}} +{{- else }} raise 'disk.tmpl included in non-disk type {{$.Name}}' -{{ end -}} +{{- end }} if v, ok := d.GetOk("image"); ok { log.Printf("[DEBUG] Resolving image name: %s", v.(string)) diff --git a/mmv1/templates/terraform/encoders/go/dlp_job_trigger.go.tmpl b/mmv1/templates/terraform/encoders/go/dlp_job_trigger.go.tmpl index 9ff45c4939ad..416f7e16229a 100644 --- a/mmv1/templates/terraform/encoders/go/dlp_job_trigger.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/dlp_job_trigger.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} newObj := make(map[string]interface{}) newObj["{{camelize $.Name "lower"}}"] = obj diff --git a/mmv1/templates/terraform/encoders/go/dlp_stored_info_type.go.tmpl b/mmv1/templates/terraform/encoders/go/dlp_stored_info_type.go.tmpl index e67e0d369267..b8d74e40ce77 100644 --- a/mmv1/templates/terraform/encoders/go/dlp_stored_info_type.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/dlp_stored_info_type.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} newObj := make(map[string]interface{}) newObj["config"] = obj storedInfoTypeIdProp, ok := d.GetOk("stored_info_type_id") diff --git a/mmv1/templates/terraform/encoders/go/health_check_type.tmpl b/mmv1/templates/terraform/encoders/go/health_check_type.tmpl index d5504960b75c..f5849366f680 100644 --- a/mmv1/templates/terraform/encoders/go/health_check_type.tmpl +++ b/mmv1/templates/terraform/encoders/go/health_check_type.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} if _, ok := d.GetOk("http_health_check"); ok { hc := d.Get("http_health_check").([]interface{})[0] diff --git a/mmv1/templates/terraform/encoders/go/index.go.tmpl b/mmv1/templates/terraform/encoders/go/index.go.tmpl index f93ed7044eed..231e5124eca3 100644 --- a/mmv1/templates/terraform/encoders/go/index.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/index.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // We've added project / database / collection as split fields of the name, but // the API doesn't expect them. Make sure we remove them from any requests. diff --git a/mmv1/templates/terraform/encoders/go/kms_crypto_key.go.tmpl b/mmv1/templates/terraform/encoders/go/kms_crypto_key.go.tmpl index 256da2e89ab5..66416a0c3ba4 100644 --- a/mmv1/templates/terraform/encoders/go/kms_crypto_key.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/kms_crypto_key.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // if rotationPeriod is set, nextRotationTime must also be set. if d.Get("rotation_period") != "" { rotationPeriod := d.Get("rotation_period").(string) diff --git a/mmv1/templates/terraform/encoders/go/location_from_region.go.tmpl b/mmv1/templates/terraform/encoders/go/location_from_region.go.tmpl index 25ebf51c4de1..e5a0f2cc1b52 100644 --- a/mmv1/templates/terraform/encoders/go/location_from_region.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/location_from_region.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} config := meta.(*transport_tpg.Config) if _, ok := d.GetOk("location"); !ok { location, err := tpgresource.GetRegionFromSchema("region", "zone", d, config) diff --git a/mmv1/templates/terraform/encoders/go/logging_linked_dataset.go.tmpl b/mmv1/templates/terraform/encoders/go/logging_linked_dataset.go.tmpl index bc6ce617c49f..871e6384d2fb 100644 --- a/mmv1/templates/terraform/encoders/go/logging_linked_dataset.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/logging_linked_dataset.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // Extract any empty fields from the bucket field. parent := d.Get("parent").(string) bucket := d.Get("bucket").(string) diff --git a/mmv1/templates/terraform/encoders/go/logging_log_view.go.tmpl b/mmv1/templates/terraform/encoders/go/logging_log_view.go.tmpl index bc6ce617c49f..871e6384d2fb 100644 --- a/mmv1/templates/terraform/encoders/go/logging_log_view.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/logging_log_view.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // Extract any empty fields from the bucket field. parent := d.Get("parent").(string) bucket := d.Get("bucket").(string) diff --git a/mmv1/templates/terraform/encoders/go/monitoring_monitored_project.go.tmpl b/mmv1/templates/terraform/encoders/go/monitoring_monitored_project.go.tmpl index 916a8c72a5bc..76442aa5e446 100644 --- a/mmv1/templates/terraform/encoders/go/monitoring_monitored_project.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/monitoring_monitored_project.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} name := d.Get("name").(string) log.Printf("[DEBUG] Encoded monitored project name: %s", name) name = tpgresource.GetResourceNameFromSelfLink(name) diff --git a/mmv1/templates/terraform/encoders/go/monitoring_notification_channel.go.tmpl b/mmv1/templates/terraform/encoders/go/monitoring_notification_channel.go.tmpl index 5076c9c23729..bde26ac93c37 100644 --- a/mmv1/templates/terraform/encoders/go/monitoring_notification_channel.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/monitoring_notification_channel.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} labelmap, ok := obj["labels"] if !ok { labelmap = make(map[string]string) diff --git a/mmv1/templates/terraform/encoders/go/monitoring_service.go.tmpl b/mmv1/templates/terraform/encoders/go/monitoring_service.go.tmpl index 7361f6a0bb5b..e9b60bab04a1 100644 --- a/mmv1/templates/terraform/encoders/go/monitoring_service.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/monitoring_service.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // Currently only CUSTOM service types can be created, but the // custom identifier block does not actually have fields right now. // Set to empty to indicate manually-created service type is CUSTOM. diff --git a/mmv1/templates/terraform/encoders/go/monitoring_slo.go.tmpl b/mmv1/templates/terraform/encoders/go/monitoring_slo.go.tmpl index 844ceaa28b71..038323202a85 100644 --- a/mmv1/templates/terraform/encoders/go/monitoring_slo.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/monitoring_slo.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // Name/Service Level Objective ID is a query parameter and cannot // be given in data delete(obj, "sloId") diff --git a/mmv1/templates/terraform/encoders/go/network_peering_routes_config.go.tmpl b/mmv1/templates/terraform/encoders/go/network_peering_routes_config.go.tmpl index f1f2a06db843..8bdd678fdf3e 100644 --- a/mmv1/templates/terraform/encoders/go/network_peering_routes_config.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/network_peering_routes_config.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // Stick request in a networkPeering block as in // https://cloud.google.com/compute/docs/reference/rest/v1/networks/updatePeering newObj := make(map[string]interface{}) diff --git a/mmv1/templates/terraform/encoders/go/no_send_name.go.tmpl b/mmv1/templates/terraform/encoders/go/no_send_name.go.tmpl index 9a6953ac7368..0db0a98e867f 100644 --- a/mmv1/templates/terraform/encoders/go/no_send_name.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/no_send_name.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,6 +9,6 @@ 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. -*/ -}} +*/}} delete(obj, "name") return obj, nil diff --git a/mmv1/templates/terraform/encoders/go/redis_location_id_for_fallback_zone.go.tmpl b/mmv1/templates/terraform/encoders/go/redis_location_id_for_fallback_zone.go.tmpl index e8157dcebe7f..7748ca309318 100644 --- a/mmv1/templates/terraform/encoders/go/redis_location_id_for_fallback_zone.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/redis_location_id_for_fallback_zone.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} config := meta.(*transport_tpg.Config) region, err := tpgresource.GetRegionFromSchema("region", "location_id", d, config) if err != nil { diff --git a/mmv1/templates/terraform/encoders/go/region_backend_service.go.tmpl b/mmv1/templates/terraform/encoders/go/region_backend_service.go.tmpl index bdda003112cb..684766841fb7 100644 --- a/mmv1/templates/terraform/encoders/go/region_backend_service.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/region_backend_service.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // The RegionBackendService API's Update / PUT API is badly formed and behaves like // a PATCH field for at least IAP. When sent a `null` `iap` field, the API // doesn't disable an existing field. To work around this, we need to emulate @@ -32,7 +32,7 @@ if d.Get("load_balancing_scheme").(string) == "EXTERNAL_MANAGED" || d.Get("load_ return obj, nil } -{{ if ne $.TargetVersionName "ga" -}} +{{- if ne $.TargetVersionName "ga" }} // To remove subsetting on an ILB, "NONE" must be specified. If subsetting // isn't specified, we set the value to NONE to make this use case work. _, ok := obj["subsetting"] @@ -45,7 +45,7 @@ if !ok { obj["subsetting"] = data } } -{{ end -}} +{{- end }} backendServiceOnlyManagedApiFieldNames := []string{ "capacityScaler", diff --git a/mmv1/templates/terraform/encoders/go/spanner_database.go.tmpl b/mmv1/templates/terraform/encoders/go/spanner_database.go.tmpl index 934d41877d7b..0e8ae39b76cf 100644 --- a/mmv1/templates/terraform/encoders/go/spanner_database.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/spanner_database.go.tmpl @@ -10,10 +10,10 @@ log.Printf("[DEBUG] Preparing to create new Database. Any extra DDL statements w delete(obj, "name") delete(obj, "instance") -{{/* These are added back in post-create, but do not remove for Validator. */ -}} -{{ if ne $.Compiler "terraformgoogleconversion-codegen" }} +{{- /* These are added back in post-create, but do not remove for Validator. */}} +{{- if ne $.Compiler "terraformgoogleconversion-codegen" }} delete(obj, "versionRetentionPeriod") delete(obj, "extraStatements") delete(obj, "enableDropProtection") -{{ end -}} +{{- end }} return obj, nil diff --git a/mmv1/templates/terraform/encoders/go/sql_source_representation_instance.go.tmpl b/mmv1/templates/terraform/encoders/go/sql_source_representation_instance.go.tmpl index 40bc95033f99..68cd0ce41bf6 100644 --- a/mmv1/templates/terraform/encoders/go/sql_source_representation_instance.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/sql_source_representation_instance.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} opc := obj["onPremisesConfiguration"].(map[string]interface{}) opc["hostPort"] = fmt.Sprintf("%v:%v", opc["host"], opc["port"]) delete(opc, "host") diff --git a/mmv1/templates/terraform/encoders/go/wrap_object.go.tmpl b/mmv1/templates/terraform/encoders/go/wrap_object.go.tmpl index 8af64c6f7508..b739d6c24c22 100644 --- a/mmv1/templates/terraform/encoders/go/wrap_object.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/wrap_object.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} newObj := make(map[string]interface{}) newObj["{{camelize $.Name "lower"}}"] = obj return newObj, nil diff --git a/mmv1/templates/terraform/encoders/go/wrap_object_with_deployment_resource_pool_id.go.tmpl b/mmv1/templates/terraform/encoders/go/wrap_object_with_deployment_resource_pool_id.go.tmpl index 0034ffdb7cbd..eccc59bc586e 100644 --- a/mmv1/templates/terraform/encoders/go/wrap_object_with_deployment_resource_pool_id.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/wrap_object_with_deployment_resource_pool_id.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} newObj := make(map[string]interface{}) newObj["deploymentResourcePool"] = obj nameProp, ok := d.GetOk("name") diff --git a/mmv1/templates/terraform/encoders/go/wrap_object_with_template_id.go.tmpl b/mmv1/templates/terraform/encoders/go/wrap_object_with_template_id.go.tmpl index cf14011c3080..efc2e3edc08d 100644 --- a/mmv1/templates/terraform/encoders/go/wrap_object_with_template_id.go.tmpl +++ b/mmv1/templates/terraform/encoders/go/wrap_object_with_template_id.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} newObj := make(map[string]interface{}) newObj["{{camelize $.Name "lower"}}"] = obj templateIdProp, ok := d.GetOk("template_id") diff --git a/mmv1/templates/terraform/extra_schema_entry/go/bigquery_dataset_access.go.tmpl b/mmv1/templates/terraform/extra_schema_entry/go/bigquery_dataset_access.go.tmpl index c89f37598807..ac7abe767b75 100644 --- a/mmv1/templates/terraform/extra_schema_entry/go/bigquery_dataset_access.go.tmpl +++ b/mmv1/templates/terraform/extra_schema_entry/go/bigquery_dataset_access.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} "api_updated_member": { Type: schema.TypeBool, Computed: true, diff --git a/mmv1/templates/terraform/extra_schema_entry/go/bigtable_app_profile.go.tmpl b/mmv1/templates/terraform/extra_schema_entry/go/bigtable_app_profile.go.tmpl index b37e86935e6a..2c13c0f9ff4c 100644 --- a/mmv1/templates/terraform/extra_schema_entry/go/bigtable_app_profile.go.tmpl +++ b/mmv1/templates/terraform/extra_schema_entry/go/bigtable_app_profile.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} "multi_cluster_routing_cluster_ids": { Type: schema.TypeList, Optional: true, diff --git a/mmv1/templates/terraform/extra_schema_entry/go/firewall.tmpl b/mmv1/templates/terraform/extra_schema_entry/go/firewall.tmpl index 9b3dd830052c..43543a0fefba 100644 --- a/mmv1/templates/terraform/extra_schema_entry/go/firewall.tmpl +++ b/mmv1/templates/terraform/extra_schema_entry/go/firewall.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} "enable_logging": { Type: schema.TypeBool, Optional: true, diff --git a/mmv1/templates/terraform/extra_schema_entry/go/secret_version_is_secret_data_base64.go.tmpl b/mmv1/templates/terraform/extra_schema_entry/go/secret_version_is_secret_data_base64.go.tmpl index 976f77eef77d..a3a34cbe89a3 100644 --- a/mmv1/templates/terraform/extra_schema_entry/go/secret_version_is_secret_data_base64.go.tmpl +++ b/mmv1/templates/terraform/extra_schema_entry/go/secret_version_is_secret_data_base64.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} "is_secret_data_base64": { Type: schema.TypeBool, Optional: true, diff --git a/mmv1/templates/terraform/extra_schema_entry/go/subnetwork.tmpl b/mmv1/templates/terraform/extra_schema_entry/go/subnetwork.tmpl index 57f274d4f0c7..07a76118e8b6 100644 --- a/mmv1/templates/terraform/extra_schema_entry/go/subnetwork.tmpl +++ b/mmv1/templates/terraform/extra_schema_entry/go/subnetwork.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} "fingerprint": { Type: schema.TypeString, Computed: true, diff --git a/mmv1/templates/terraform/post_create/go/bigquery_dataset_access.go.tmpl b/mmv1/templates/terraform/post_create/go/bigquery_dataset_access.go.tmpl index 2c15cdeb7094..553c0eb479b1 100644 --- a/mmv1/templates/terraform/post_create/go/bigquery_dataset_access.go.tmpl +++ b/mmv1/templates/terraform/post_create/go/bigquery_dataset_access.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // by default, we are not updating the member if err := d.Set("api_updated_member", false); err != nil { diff --git a/mmv1/templates/terraform/post_create/go/compute_region_backend_service_security_policy.go.tmpl b/mmv1/templates/terraform/post_create/go/compute_region_backend_service_security_policy.go.tmpl index fbddb040f193..e83d020220b5 100644 --- a/mmv1/templates/terraform/post_create/go/compute_region_backend_service_security_policy.go.tmpl +++ b/mmv1/templates/terraform/post_create/go/compute_region_backend_service_security_policy.go.tmpl @@ -1,4 +1,4 @@ -{{ if ne $.TargetVersionName "ga" -}} +{{- if ne $.TargetVersionName "ga" }} // security_policy isn't set by Create if v, ok := d.GetOkExists("security_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, securityPolicyProp)) { err = resourceComputeRegionBackendServiceRead(d, meta) @@ -36,4 +36,4 @@ if v, ok := d.GetOkExists("security_policy"); !tpgresource.IsEmptyValue(reflect. return err } } -{{ end -}} +{{- end }} diff --git a/mmv1/templates/terraform/post_create/go/compute_target_instance_security_policy.go.tmpl b/mmv1/templates/terraform/post_create/go/compute_target_instance_security_policy.go.tmpl index ed74afb95530..e26b30970c46 100644 --- a/mmv1/templates/terraform/post_create/go/compute_target_instance_security_policy.go.tmpl +++ b/mmv1/templates/terraform/post_create/go/compute_target_instance_security_policy.go.tmpl @@ -1,4 +1,4 @@ -{{ if ne $.TargetVersionName "ga" -}} +{{- if ne $.TargetVersionName "ga" }} // security_policy isn't set by Create if v, ok := d.GetOkExists("security_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, securityPolicyProp)) { obj := make(map[string]interface{}) @@ -31,4 +31,4 @@ if v, ok := d.GetOkExists("security_policy"); !tpgresource.IsEmptyValue(reflect. return err } } -{{ end -}} \ No newline at end of file +{{- end }} \ No newline at end of file diff --git a/mmv1/templates/terraform/post_create/go/datastream_stream.go.tmpl b/mmv1/templates/terraform/post_create/go/datastream_stream.go.tmpl index ad6fd4922032..057721e7f21a 100644 --- a/mmv1/templates/terraform/post_create/go/datastream_stream.go.tmpl +++ b/mmv1/templates/terraform/post_create/go/datastream_stream.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} if err := waitForDatastreamStreamReady(d, config, d.Timeout(schema.TimeoutCreate) - time.Minute); err != nil { return fmt.Errorf("Error waiting for Stream %q to be NOT_STARTED or RUNNING during creation: %q", d.Get("name").(string), err) } diff --git a/mmv1/templates/terraform/post_create/go/firebase_database_instance.go.tmpl b/mmv1/templates/terraform/post_create/go/firebase_database_instance.go.tmpl index 4203deeda77f..a9edcacbcac1 100644 --- a/mmv1/templates/terraform/post_create/go/firebase_database_instance.go.tmpl +++ b/mmv1/templates/terraform/post_create/go/firebase_database_instance.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // start of customized code if p, ok := d.GetOk("desired_state"); ok && p.(string) == "DISABLED" { diff --git a/mmv1/templates/terraform/post_create/go/index.go.tmpl b/mmv1/templates/terraform/post_create/go/index.go.tmpl index ca3f40f7b264..46b8313ae398 100644 --- a/mmv1/templates/terraform/post_create/go/index.go.tmpl +++ b/mmv1/templates/terraform/post_create/go/index.go.tmpl @@ -1,4 +1,4 @@ -{{/* +{{- /* The license inside this block applies to this file Copyright 2024 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,7 +9,7 @@ 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. -*/ -}} +*/}} // The operation for this resource contains the generated name that we need // in order to perform a READ. metadata := res["metadata"].(map[string]interface{}) diff --git a/mmv1/templates/terraform/post_create/go/labels.tmpl b/mmv1/templates/terraform/post_create/go/labels.tmpl index 7eb00b94a313..427d911cee87 100644 --- a/mmv1/templates/terraform/post_create/go/labels.tmpl +++ b/mmv1/templates/terraform/post_create/go/labels.tmpl @@ -1,4 +1,4 @@ -{{ if $.HasLabelsField -}} +{{- if $.HasLabelsField }} if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { labels := d.Get("labels") terraformLables := d.Get("terraform_labels") @@ -30,12 +30,12 @@ if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect RawURL: url, UserAgent: userAgent, Body: obj, - {{ if $.ErrorRetryPredicates -}} + {{- if $.ErrorRetryPredicates }} ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{ {{- join $.ErrorRetryPredicates "," -}} }, - {{ end -}} - {{ if $.ErrorAbortPredicates -}} + {{- end }} + {{- if $.ErrorAbortPredicates }} ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{ {{- join $.ErrorAbortPredicates "," -}} }, - {{ end -}} + {{- end }} }) if err != nil { return fmt.Errorf("Error adding labels to {{$.ResourceName}} %q: %s", d.Id(), err) @@ -64,4 +64,4 @@ if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect return fmt.Errorf("Error setting back effective_labels: %s", err) } } -{{ end -}} +{{- end }}