diff --git a/pkg/util/validation/validation.go b/pkg/util/validation/validation.go index 0b8a6cb35..6f8a2e26b 100644 --- a/pkg/util/validation/validation.go +++ b/pkg/util/validation/validation.go @@ -19,9 +19,7 @@ package validation import ( "fmt" "math" - "net" "regexp" - "strconv" "strings" "k8s.io/apimachinery/pkg/util/validation/field" @@ -493,18 +491,3 @@ func hasChDirPrefix(value string) []string { } return errs } - -// IsValidSocketAddr checks that string represents a valid socket address -// as defined in RFC 789. (e.g 0.0.0.0:10254 or [::]:10254)) -func IsValidSocketAddr(value string) []string { - var errs []string - ip, port, err := net.SplitHostPort(value) - if err != nil { - errs = append(errs, "must be a valid socket address format, (e.g. 0.0.0.0:10254 or [::]:10254)") - return errs - } - portInt, _ := strconv.Atoi(port) - errs = append(errs, IsValidPortNum(portInt)...) - errs = append(errs, IsValidIP(ip)...) - return errs -} diff --git a/pkg/util/validation/validation_test.go b/pkg/util/validation/validation_test.go index 499b13c73..c439e0398 100644 --- a/pkg/util/validation/validation_test.go +++ b/pkg/util/validation/validation_test.go @@ -710,31 +710,3 @@ func TestIsDomainPrefixedPath(t *testing.T) { } } } - -func TestIsValidSocketAddr(t *testing.T) { - goodValues := []string{ - "0.0.0.0:10254", - "127.0.0.1:8888", - "[2001:db8:1f70::999:de8:7648:6e8]:10254", - "[::]:10254", - } - for _, val := range goodValues { - if errs := IsValidSocketAddr(val); len(errs) != 0 { - t.Errorf("expected no errors for %q: %v", val, errs) - } - } - - badValues := []string{ - "0.0.0.0.0:2020", - "0.0.0.0", - "6.6.6.6:909090", - "2001:db8:1f70::999:de8:7648:6e8:87567:102545", - "", - "*", - } - for _, val := range badValues { - if errs := IsValidSocketAddr(val); len(errs) == 0 { - t.Errorf("expected errors for %q", val) - } - } -}