Browse Source

ensure decisions from CAPI have proper case (#848)

Thibault "bui" Koechlin 4 years ago
parent
commit
b6ee006078
1 changed files with 8 additions and 0 deletions
  1. 8 0
      pkg/apiserver/apic.go

+ 8 - 0
pkg/apiserver/apic.go

@@ -276,6 +276,14 @@ func (a *apic) PullTop() error {
 		var start_ip, start_sfx, end_ip, end_sfx int64
 		var start_ip, start_sfx, end_ip, end_sfx int64
 		var sz int
 		var sz int
 
 
+		/*CAPI might send lower case scopes, unify it.*/
+		switch strings.ToLower(*decision.Scope) {
+		case "ip":
+			*decision.Scope = types.Ip
+		case "range":
+			*decision.Scope = types.Range
+		}
+
 		/*if the scope is IP or Range, convert the value to integers */
 		/*if the scope is IP or Range, convert the value to integers */
 		if strings.ToLower(*decision.Scope) == "ip" || strings.ToLower(*decision.Scope) == "range" {
 		if strings.ToLower(*decision.Scope) == "ip" || strings.ToLower(*decision.Scope) == "range" {
 			sz, start_ip, start_sfx, end_ip, end_sfx, err = types.Addr2Ints(*decision.Value)
 			sz, start_ip, start_sfx, end_ip, end_sfx, err = types.Addr2Ints(*decision.Value)