mitchell852 closed pull request #2845: Fix TO Servers validation to allow "" 
ipv6
URL: https://github.com/apache/trafficcontrol/pull/2845
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/lib/go-tc/tovalidate/rules.go b/lib/go-tc/tovalidate/rules.go
index 3ea3ae17d..f15581086 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 1f768750d..16b252e09 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{


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to