whereabouts/pkg/types/ipsanitizers.go
Miguel Duarte Barroso 6d9ba2defe build, go1.17: backwards compatible unmarshalling of IP / IPNet
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2022-05-26 17:18:31 +02:00

18 lines
306 B
Go

package types
import (
"fmt"
"net"
netutils "k8s.io/utils/net"
)
func sanitizeIP(address string) (net.IP, error) {
sanitizedAddress := netutils.ParseIPSloppy(address)
if sanitizedAddress == nil {
return nil, fmt.Errorf("%s is not a valid IP address", address)
}
return sanitizedAddress, nil
}