@@ -184,17 +184,22 @@ func NodeIDToZoneAndName(id string) (string, string, error) {
184184}
185185
186186func GetRegionFromZones (zones []string ) (string , error ) {
187+ const tpcPrefix = "u"
187188 regions := sets.String {}
188189 if len (zones ) < 1 {
189190 return "" , fmt .Errorf ("no zones specified" )
190191 }
191192 for _ , zone := range zones {
192193 // Zone expected format {locale}-{region}-{zone}
194+ // TPC zone expected format is u-{}-{}-{}, e.g. u-europe-central2-a. See go/tpc-region-naming.
193195 splitZone := strings .Split (zone , "-" )
194- if len (splitZone ) != 3 {
195- return "" , fmt .Errorf ("zone in unexpected format, expected: {locale}-{region}-{zone}, got: %v" , zone )
196+ if len (splitZone ) == 3 {
197+ regions .Insert (strings .Join (splitZone [0 :2 ], "-" ))
198+ } else if len (splitZone ) == 4 && splitZone [0 ] == tpcPrefix {
199+ regions .Insert (strings .Join (splitZone [0 :3 ], "-" ))
200+ } else {
201+ return "" , fmt .Errorf ("zone in unexpected format, expected: {locale}-{region}-{zone} or u-{locale}-{region}-{zone}, got: %v" , zone )
196202 }
197- regions .Insert (strings .Join (splitZone [0 :2 ], "-" ))
198203 }
199204 if regions .Len () != 1 {
200205 return "" , fmt .Errorf ("multiple or no regions gotten from zones, got: %v" , regions )
0 commit comments