drop locality for now

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2020-03-05 17:33:35 +01:00
parent 3e5b7d77ea
commit deb582259a
8 changed files with 47 additions and 210 deletions

View File

@@ -149,57 +149,3 @@ func parseTraffic(c *caddy.Controller) (*Traffic, error) {
t.hosts = toHosts
return t, nil
}
// parseLocality parses string s into loc's. Each loc must be space separated from the other, inside
// a loc we have region,zone,subzone, where subzone or subzone and zone maybe empty. If specified
// they must be comma separate (not spaces or anything).
func parseLocality(s string) ([]xds.Locality, error) {
sets := strings.Fields(s)
if len(sets) == 0 {
return nil, nil
}
locs := []xds.Locality{}
for _, s := range sets {
l := strings.Split(s, ",")
switch len(l) {
default:
return nil, fmt.Errorf("too many location specifiers: %q", s)
case 1:
l0 := strings.TrimSpace(l[0])
if l0 == "" {
return nil, fmt.Errorf("empty location specifer: %q", l[0])
}
locs = append(locs, xds.Locality{Region: l0})
continue
case 2:
l0 := strings.TrimSpace(l[0])
if l0 == "" {
return nil, fmt.Errorf("empty location specifer: %q", l[0])
}
l1 := strings.TrimSpace(l[1])
if l1 == "" {
return nil, fmt.Errorf("empty location specifer: %q", l[1])
}
locs = append(locs, xds.Locality{Region: l0, Zone: l1})
continue
case 3:
l0 := strings.TrimSpace(l[0])
if l0 == "" {
return nil, fmt.Errorf("empty location specifer: %q", l[0])
}
l1 := strings.TrimSpace(l[1])
if l1 == "" {
return nil, fmt.Errorf("empty location specifer: %q", l[1])
}
l2 := strings.TrimSpace(l[2])
if l2 == "" {
return nil, fmt.Errorf("empty location specifer: %q", l[2])
}
locs = append(locs, xds.Locality{Region: l0, Zone: l1, SubZone: l2})
continue
}
}
return locs, nil
}