Skip to content

Commit a2b95e3

Browse files
authored
Add diff suppress for empty/default pod_security_policy_config (#1670)
* add diff suppress for pod_security_policy_config * change key comparison to exact
1 parent 81bffe5 commit a2b95e3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

google/resource_container_cluster.go

+15
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ func resourceContainerCluster() *schema.Resource {
389389
},
390390
},
391391
},
392+
DiffSuppressFunc: podSecurityPolicyCfgSuppress,
392393
},
393394

394395
"project": {
@@ -1555,3 +1556,17 @@ func masterAuthClientCertCfgSuppress(k, old, new string, r *schema.ResourceData)
15551556

15561557
return strings.HasSuffix(k, ".issue_client_certificate") && old == "" && new == "true"
15571558
}
1559+
1560+
func podSecurityPolicyCfgSuppress(k, old, new string, r *schema.ResourceData) bool {
1561+
if k == "pod_security_policy_config.#" && old == "1" && new == "0" {
1562+
if v, ok := r.GetOk("pod_security_policy_config"); ok {
1563+
cfgList := v.([]interface{})
1564+
if len(cfgList) > 0 {
1565+
d := cfgList[0].(map[string]interface{})
1566+
// Suppress if old value was {enabled == false}
1567+
return !d["enabled"].(bool)
1568+
}
1569+
}
1570+
}
1571+
return false
1572+
}

0 commit comments

Comments
 (0)