Skip to content

Commit 953f4c3

Browse files
slevenickanoopkverma-google
authored andcommitted
Add DSF on resource_labels in node_config (GoogleCloudPlatform#12877)
1 parent 734c13f commit 953f4c3

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

mmv1/third_party/terraform/services/container/node_config.go.tmpl

+20-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ package container
22

33
import (
44
"log"
5-
{{- if ne $.TargetVersionName "ga" }}
65
"strings"
7-
{{- end }}
86
"time"
97

108
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -241,10 +239,11 @@ func schemaNodeConfig() *schema.Schema {
241239
},
242240

243241
"resource_labels": {
244-
Type: schema.TypeMap,
245-
Optional: true,
246-
Elem: &schema.Schema{Type: schema.TypeString},
247-
Description: `The GCE resource labels (a map of key/value pairs) to be applied to the node pool.`,
242+
Type: schema.TypeMap,
243+
Optional: true,
244+
Elem: &schema.Schema{Type: schema.TypeString},
245+
DiffSuppressFunc: containerNodePoolResourceLabelsDiffSuppress,
246+
Description: `The GCE resource labels (a map of key/value pairs) to be applied to the node pool.`,
248247
},
249248

250249
"local_ssd_count": {
@@ -1869,6 +1868,21 @@ func containerNodePoolLabelsSuppress(k, old, new string, d *schema.ResourceData)
18691868
}
18701869
{{- end }}
18711870

1871+
func containerNodePoolResourceLabelsDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
1872+
// Suppress diffs for server-specified labels prefixed with "goog-gke"
1873+
if strings.Contains(k, "resource_labels.goog-gke") && new == "" {
1874+
return true
1875+
}
1876+
1877+
// Let diff be determined by resource_labels (above)
1878+
if strings.Contains(k, "resource_labels.%") {
1879+
return true
1880+
}
1881+
1882+
// For other keys, don't suppress diff.
1883+
return false
1884+
}
1885+
18721886
func flattenKubeletConfig(c *container.NodeKubeletConfig) []map[string]interface{} {
18731887
result := []map[string]interface{}{}
18741888
if c != nil {

0 commit comments

Comments
 (0)