mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-21 00:45:11 +00:00
Convert for util.IP to just use a net.IP
pflag can handle IP addresses so use the pflag code instead of doing it ourselves. This means our code just uses net.IP and we don't have all of the useless casting back and forth!
This commit is contained in:
@@ -17,30 +17,10 @@ limitations under the License.
|
||||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// IP adapts net.IP for use as a flag.
|
||||
type IP net.IP
|
||||
|
||||
func (ip IP) String() string {
|
||||
return net.IP(ip).String()
|
||||
}
|
||||
|
||||
func (ip *IP) Set(value string) error {
|
||||
*ip = IP(net.ParseIP(strings.TrimSpace(value)))
|
||||
if *ip == nil {
|
||||
return fmt.Errorf("invalid IP address: '%s'", value)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*IP) Type() string {
|
||||
return "ip"
|
||||
}
|
||||
|
||||
// IPNet adapts net.IPNet for use as a flag.
|
||||
type IPNet net.IPNet
|
||||
|
||||
|
||||
Reference in New Issue
Block a user