Skip to content

Commit

Permalink
Fix the diffs for filed environment_variable
Browse files Browse the repository at this point in the history
  • Loading branch information
zli82016 committed Jul 2, 2024
1 parent 0370a3f commit a17e6e9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mmv1/products/cloudfunctions2/Function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import_format:
taint_resource_on_failed_create: true
autogen_async: true
custom_code: !ruby/object:Provider::Terraform::CustomCode
constants: 'templates/terraform/constants/cloudfunctions2_function.go.erb'
encoder: 'templates/terraform/encoders/cloudfunctions2_runtime_update_policy.go.erb'
examples:
- !ruby/object:Provider::Terraform::Examples
Expand Down Expand Up @@ -559,6 +560,7 @@ properties:
description:
'Environment variables that shall be available during function
execution.'
diff_suppress_func: 'environmentVariablesDiffSuppress'
- !ruby/object:Api::Type::Integer
name: 'maxInstanceCount'
description: |
Expand Down
15 changes: 15 additions & 0 deletions mmv1/templates/terraform/constants/cloudfunctions2_function.go.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

// 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
}

0 comments on commit a17e6e9

Please sign in to comment.