Преглед изворни кода

Update compat.go to prefer the right region label

Also stops it being hardcoded as a string
Michael Dresser пре 5 година
родитељ
комит
2c1e4cb4ae
1 измењених фајлова са 5 додато и 3 уклоњено
  1. 5 3
      pkg/util/compat.go

+ 5 - 3
pkg/util/compat.go

@@ -4,11 +4,13 @@ import (
 	v1 "k8s.io/api/core/v1"
 )
 
+// See https://kubernetes.io/docs/reference/labels-annotations-taints/
+
 func GetRegion(labels map[string]string) (string, bool) {
-	if _, ok := labels[v1.LabelZoneRegion]; ok {
+	if _, ok := labels[v1.LabelTopologyRegion]; ok { // Label as of 1.17
+		return labels[v1.LabelTopologyRegion], true
+	} else if _, ok := labels[v1.LabelZoneRegion]; ok { // deprecated label
 		return labels[v1.LabelZoneRegion], true
-	} else if _, ok := labels["topology.kubernetes.io/region"]; ok { // Label as of 1.17
-		return labels["topology.kubernetes.io/region"], true
 	} else {
 		return "", false
 	}