You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2018/09/20 15:25:27 UTC
[trafficcontrol] branch master updated: Fix TO Servers validation
to allow "" ipv6
This is an automated email from the ASF dual-hosted git repository.
mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new a1ed630 Fix TO Servers validation to allow "" ipv6
a1ed630 is described below
commit a1ed630612bc3fe93b41c4945dd36af276edbf45
Author: Robert Butts <ro...@apache.org>
AuthorDate: Thu Sep 20 08:56:53 2018 -0600
Fix TO Servers validation to allow "" ipv6
Fixes #2844
---
lib/go-tc/tovalidate/rules.go | 2 +-
traffic_ops/traffic_ops_golang/server/servers.go | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/go-tc/tovalidate/rules.go b/lib/go-tc/tovalidate/rules.go
index 3ea3ae1..f155810 100644
--- a/lib/go-tc/tovalidate/rules.go
+++ b/lib/go-tc/tovalidate/rules.go
@@ -154,7 +154,7 @@ func IsValidIPv6CIDROrAddress(value interface{}) error {
}
}
}
- return fmt.Errorf("unable to parse an IPv6 address or CIDR from: %s", v)
+ return fmt.Errorf("unable to parse an IPv6 address or CIDR from: %s", *v)
default:
return fmt.Errorf("IsValidIPv6CIDROrAddress validation failure: unknown type %T", value)
}
diff --git a/traffic_ops/traffic_ops_golang/server/servers.go b/traffic_ops/traffic_ops_golang/server/servers.go
index 0d9590c..5e60a20 100644
--- a/traffic_ops/traffic_ops_golang/server/servers.go
+++ b/traffic_ops/traffic_ops_golang/server/servers.go
@@ -91,8 +91,14 @@ func (server *TOServer) GetType() string {
return "server"
}
-func (server *TOServer) Validate() error {
+func (server *TOServer) Sanitize() {
+ if server.IP6Address != nil && *server.IP6Address == "" {
+ server.IP6Address = nil
+ }
+}
+func (server *TOServer) Validate() error {
+ server.Sanitize()
noSpaces := validation.NewStringRule(tovalidate.NoSpaces, "cannot contain spaces")
validateErrs := validation.Errors{