@@ -4,6 +4,7 @@ package container
4
4
5
5
import (
6
6
"log"
7
+ "strings"
7
8
"time"
8
9
9
10
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -233,10 +234,11 @@ func schemaNodeConfig() *schema.Schema {
233
234
},
234
235
235
236
"resource_labels" : {
236
- Type : schema .TypeMap ,
237
- Optional : true ,
238
- Elem : & schema.Schema {Type : schema .TypeString },
239
- Description : `The GCE resource labels (a map of key/value pairs) to be applied to the node pool.` ,
237
+ Type : schema .TypeMap ,
238
+ Optional : true ,
239
+ Elem : & schema.Schema {Type : schema .TypeString },
240
+ DiffSuppressFunc : containerNodePoolResourceLabelsDiffSuppress ,
241
+ Description : `The GCE resource labels (a map of key/value pairs) to be applied to the node pool.` ,
240
242
},
241
243
242
244
"local_ssd_count" : {
@@ -1692,6 +1694,21 @@ func flattenWorkloadMetadataConfig(c *container.WorkloadMetadataConfig) []map[st
1692
1694
return result
1693
1695
}
1694
1696
1697
+ func containerNodePoolResourceLabelsDiffSuppress (k , old , new string , d * schema.ResourceData ) bool {
1698
+ // Suppress diffs for server-specified labels prefixed with "goog-gke"
1699
+ if strings .Contains (k , "resource_labels.goog-gke" ) && new == "" {
1700
+ return true
1701
+ }
1702
+
1703
+ // Let diff be determined by resource_labels (above)
1704
+ if strings .Contains (k , "resource_labels.%" ) {
1705
+ return true
1706
+ }
1707
+
1708
+ // For other keys, don't suppress diff.
1709
+ return false
1710
+ }
1711
+
1695
1712
func flattenKubeletConfig (c * container.NodeKubeletConfig ) []map [string ]interface {} {
1696
1713
result := []map [string ]interface {}{}
1697
1714
if c != nil {
0 commit comments