mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 10:53:34 +00:00
vendor updates
This commit is contained in:
50
vendor/k8s.io/kubernetes/pkg/apis/componentconfig/helpers.go
generated
vendored
50
vendor/k8s.io/kubernetes/pkg/apis/componentconfig/helpers.go
generated
vendored
@ -20,6 +20,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@ -61,6 +62,55 @@ func (v IPVar) Type() string {
|
||||
return "ip"
|
||||
}
|
||||
|
||||
// IPPortVar allows IP or IP:port formats.
|
||||
type IPPortVar struct {
|
||||
Val *string
|
||||
}
|
||||
|
||||
func (v IPPortVar) Set(s string) error {
|
||||
if len(s) == 0 {
|
||||
v.Val = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
if v.Val == nil {
|
||||
// it's okay to panic here since this is programmer error
|
||||
panic("the string pointer passed into IPPortVar should not be nil")
|
||||
}
|
||||
|
||||
// Both IP and IP:port are valid.
|
||||
// Attempt to parse into IP first.
|
||||
if net.ParseIP(s) != nil {
|
||||
*v.Val = s
|
||||
return nil
|
||||
}
|
||||
|
||||
// Can not parse into IP, now assume IP:port.
|
||||
host, port, err := net.SplitHostPort(s)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%q is not in a valid format (ip or ip:port): %v", s, err)
|
||||
}
|
||||
if net.ParseIP(host) == nil {
|
||||
return fmt.Errorf("%q is not a valid IP address", host)
|
||||
}
|
||||
if _, err := strconv.Atoi(port); err != nil {
|
||||
return fmt.Errorf("%q is not a valid number", port)
|
||||
}
|
||||
*v.Val = s
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v IPPortVar) String() string {
|
||||
if v.Val == nil {
|
||||
return ""
|
||||
}
|
||||
return *v.Val
|
||||
}
|
||||
|
||||
func (v IPPortVar) Type() string {
|
||||
return "ipport"
|
||||
}
|
||||
|
||||
type PortRangeVar struct {
|
||||
Val *string
|
||||
}
|
||||
|
Reference in New Issue
Block a user