From b741f090a08b2a442047fd0e2a19be6e1259c308 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Wed, 3 Jul 2024 19:12:32 +0000 Subject: [PATCH] fixed permadiffs on `environment_variables` in cloudfunctions2 function (#11092) [upstream:05a0cb385e37a9f76a8f09fbffa3b45ce60e4327] Signed-off-by: Modular Magician --- go.mod | 2 +- go.sum | 4 ++-- .../cloudfunctions2/cloudfunctions2_function.go | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7222bd125..d42912201 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/hashicorp/hcl/v2 v2.19.1 github.com/hashicorp/terraform-json v0.21.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 - github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240703160327-4796d59dbd07 + github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240703190950-3fbe86489a97 github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index cb38515ea..f2b57e232 100644 --- a/go.sum +++ b/go.sum @@ -184,8 +184,8 @@ github.com/hashicorp/terraform-plugin-mux v0.15.0 h1:+/+lDx0WUsIOpkAmdwBIoFU8UP9 github.com/hashicorp/terraform-plugin-mux v0.15.0/go.mod h1:9ezplb1Dyq394zQ+ldB0nvy/qbNAz3mMoHHseMTMaKo= github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh3R4yp6pKksKHcqZx5G8= github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240703160327-4796d59dbd07 h1:KEK+ri5uJRlBdfB1L0/GtcCG1Yf3UZPqcBMHLNvzfr8= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240703160327-4796d59dbd07/go.mod h1:LtqLd41zCL9zNzjz4lld4q9wnK3+MWRvIdoNc/anTZ0= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240703190950-3fbe86489a97 h1:7M88rwo3WtGy4aaAODa4i0XVWqpcxcDtEj4AeLvgEB0= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240703190950-3fbe86489a97/go.mod h1:LtqLd41zCL9zNzjz4lld4q9wnK3+MWRvIdoNc/anTZ0= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= diff --git a/tfplan2cai/converters/google/resources/services/cloudfunctions2/cloudfunctions2_function.go b/tfplan2cai/converters/google/resources/services/cloudfunctions2/cloudfunctions2_function.go index 586f7ec97..822b0ca69 100644 --- a/tfplan2cai/converters/google/resources/services/cloudfunctions2/cloudfunctions2_function.go +++ b/tfplan2cai/converters/google/resources/services/cloudfunctions2/cloudfunctions2_function.go @@ -16,6 +16,7 @@ package cloudfunctions2 import ( "reflect" + "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -24,6 +25,21 @@ import ( transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" ) +// Suppress diffs for the system environment variables +func environmentVariablesDiffSuppress(k, old, new string, d *schema.ResourceData) bool { + if k == "service_config.0.environment_variables.LOG_EXECUTION_ID" && new == "" { + return true + } + + // Let diff be determined by environment_variables (above) + if strings.HasPrefix(k, "service_config.0.environment_variables.%") { + return true + } + + // For other keys, don't suppress diff. + return false +} + const Cloudfunctions2functionAssetType string = "cloudfunctions.googleapis.com/function" func ResourceConverterCloudfunctions2function() cai.ResourceConverter {