From 8ede2be139fff660796950357ccfb2c3e87ca9d0 Mon Sep 17 00:00:00 2001 From: Zhenhua Li Date: Mon, 9 Sep 2024 09:40:19 -0700 Subject: [PATCH] Go rewrite diffs fix (#11659) --- mmv1/products/securitycenterv2/ProjectMuteConfig.yaml | 2 +- mmv1/templates/terraform/env_var_context.go.tmpl | 3 +++ .../terraform/examples/base_configs/test_file.go.tmpl | 2 +- mmv1/templates/terraform/iam/go/iam_context.go.tmpl | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mmv1/products/securitycenterv2/ProjectMuteConfig.yaml b/mmv1/products/securitycenterv2/ProjectMuteConfig.yaml index 6e7beff16a71..8ed9b8ccf008 100644 --- a/mmv1/products/securitycenterv2/ProjectMuteConfig.yaml +++ b/mmv1/products/securitycenterv2/ProjectMuteConfig.yaml @@ -35,7 +35,7 @@ examples: vars: mute_config_id: 'my-config' test_env_vars: - project_id: PROJECT_NAME + project_id: :PROJECT_NAME parameters: - !ruby/object:Api::Type::String name: location diff --git a/mmv1/templates/terraform/env_var_context.go.tmpl b/mmv1/templates/terraform/env_var_context.go.tmpl index 41f63c5245e6..64efd3432ad2 100644 --- a/mmv1/templates/terraform/env_var_context.go.tmpl +++ b/mmv1/templates/terraform/env_var_context.go.tmpl @@ -30,4 +30,7 @@ "{{$varKey}}": envvar.GetTestZoneFromEnv(), {{- end }} {{- end }} + {{- if and $.HasNewLine (gt (len $.TestEnvVars) 0)}} + {{""}} + {{- end}} {{- end }} \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/base_configs/test_file.go.tmpl b/mmv1/templates/terraform/examples/base_configs/test_file.go.tmpl index 061d48563a59..23d37372e804 100644 --- a/mmv1/templates/terraform/examples/base_configs/test_file.go.tmpl +++ b/mmv1/templates/terraform/examples/base_configs/test_file.go.tmpl @@ -44,7 +44,7 @@ func TestAcc{{ $e.TestSlug $.Res.ProductMetadata.Name $.Res.Name }}(t *testing.T t.Parallel() context := map[string]interface{}{ - {{- template "EnvVarContext" $e }} + {{- template "EnvVarContext" dict "TestEnvVars" $e.TestEnvVars "HasNewLine" false}} {{- range $varKey, $varVal := $e.TestVarsOverrides }} "{{$varKey}}": {{$varVal}}, {{- end }} diff --git a/mmv1/templates/terraform/iam/go/iam_context.go.tmpl b/mmv1/templates/terraform/iam/go/iam_context.go.tmpl index 54d105314463..61df201660dd 100644 --- a/mmv1/templates/terraform/iam/go/iam_context.go.tmpl +++ b/mmv1/templates/terraform/iam/go/iam_context.go.tmpl @@ -8,7 +8,7 @@ {{- if $.IamPolicy.TestProjectName }} "project_id" : fmt.Sprintf("{{ $.IamPolicy.TestProjectName }}%s", acctest.RandString(t, 10)), {{- end }} -{{- template "EnvVarContext" $.FirstTestExample }} +{{- template "EnvVarContext" dict "TestEnvVars" $.FirstTestExample.TestEnvVars "HasNewLine" true}} {{- if $.FirstTestExample.TestVarsOverrides }} {{- range $varName, $override := $.FirstTestExample.TestVarsOverrides }} "{{ $varName }}": {{ $override }},