@@ -2,9 +2,7 @@ package container
2
2
3
3
import (
4
4
"log"
5
- {{- if ne $.TargetVersionName "ga" }}
6
5
"strings"
7
- {{- end }}
8
6
"time"
9
7
10
8
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -241,10 +239,11 @@ func schemaNodeConfig() *schema.Schema {
241
239
},
242
240
243
241
"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.`,
248
247
},
249
248
250
249
"local_ssd_count": {
@@ -1869,6 +1868,21 @@ func containerNodePoolLabelsSuppress(k, old, new string, d *schema.ResourceData)
1869
1868
}
1870
1869
{{- end }}
1871
1870
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
+
1872
1886
func flattenKubeletConfig(c *container.NodeKubeletConfig) []map[string]interface{} {
1873
1887
result := []map[string]interface{}{}
1874
1888
if c != nil {
0 commit comments