vendor: github.com/docker/cli v23.0.0
full diff: https://github.com/docker/cli/compare/v23.0.0-rc.1...v23.0.0 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
55
vendor/github.com/docker/cli/opts/opts.go
generated
vendored
55
vendor/github.com/docker/cli/opts/opts.go
generated
vendored
@@ -55,7 +55,7 @@ func (opts *ListOpts) Set(value string) error {
|
||||
}
|
||||
value = v
|
||||
}
|
||||
(*opts.values) = append((*opts.values), value)
|
||||
*opts.values = append(*opts.values, value)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func (opts *ListOpts) Set(value string) error {
|
||||
func (opts *ListOpts) Delete(key string) {
|
||||
for i, k := range *opts.values {
|
||||
if k == key {
|
||||
(*opts.values) = append((*opts.values)[:i], (*opts.values)[i+1:]...)
|
||||
*opts.values = append((*opts.values)[:i], (*opts.values)[i+1:]...)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ func (opts *ListOpts) GetMap() map[string]struct{} {
|
||||
|
||||
// GetAll returns the values of slice.
|
||||
func (opts *ListOpts) GetAll() []string {
|
||||
return (*opts.values)
|
||||
return *opts.values
|
||||
}
|
||||
|
||||
// GetAllOrEmpty returns the values of the slice
|
||||
@@ -106,7 +106,7 @@ func (opts *ListOpts) Get(key string) bool {
|
||||
|
||||
// Len returns the amount of element in the slice.
|
||||
func (opts *ListOpts) Len() int {
|
||||
return len((*opts.values))
|
||||
return len(*opts.values)
|
||||
}
|
||||
|
||||
// Type returns a string name for this Option type
|
||||
@@ -165,12 +165,8 @@ func (opts *MapOpts) Set(value string) error {
|
||||
}
|
||||
value = v
|
||||
}
|
||||
vals := strings.SplitN(value, "=", 2)
|
||||
if len(vals) == 1 {
|
||||
(opts.values)[vals[0]] = ""
|
||||
} else {
|
||||
(opts.values)[vals[0]] = vals[1]
|
||||
}
|
||||
k, v, _ := strings.Cut(value, "=")
|
||||
opts.values[k] = v
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -277,16 +273,16 @@ func validateDomain(val string) (string, error) {
|
||||
//
|
||||
// TODO discuss if quotes (and other special characters) should be valid or invalid for keys
|
||||
// TODO discuss if leading/trailing whitespace in keys should be preserved (and valid)
|
||||
func ValidateLabel(val string) (string, error) {
|
||||
arr := strings.SplitN(val, "=", 2)
|
||||
key := strings.TrimLeft(arr[0], whiteSpaces)
|
||||
func ValidateLabel(value string) (string, error) {
|
||||
key, _, _ := strings.Cut(value, "=")
|
||||
key = strings.TrimLeft(key, whiteSpaces)
|
||||
if key == "" {
|
||||
return "", fmt.Errorf("invalid label '%s': empty name", val)
|
||||
return "", fmt.Errorf("invalid label '%s': empty name", value)
|
||||
}
|
||||
if strings.ContainsAny(key, whiteSpaces) {
|
||||
return "", fmt.Errorf("label '%s' contains whitespaces", key)
|
||||
}
|
||||
return val, nil
|
||||
return value, nil
|
||||
}
|
||||
|
||||
// ValidateSysctl validates a sysctl and returns it.
|
||||
@@ -305,20 +301,19 @@ func ValidateSysctl(val string) (string, error) {
|
||||
"net.",
|
||||
"fs.mqueue.",
|
||||
}
|
||||
arr := strings.Split(val, "=")
|
||||
if len(arr) < 2 {
|
||||
return "", fmt.Errorf("sysctl '%s' is not whitelisted", val)
|
||||
k, _, ok := strings.Cut(val, "=")
|
||||
if !ok || k == "" {
|
||||
return "", fmt.Errorf("sysctl '%s' is not allowed", val)
|
||||
}
|
||||
if validSysctlMap[arr[0]] {
|
||||
if validSysctlMap[k] {
|
||||
return val, nil
|
||||
}
|
||||
|
||||
for _, vp := range validSysctlPrefixes {
|
||||
if strings.HasPrefix(arr[0], vp) {
|
||||
if strings.HasPrefix(k, vp) {
|
||||
return val, nil
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("sysctl '%s' is not whitelisted", val)
|
||||
return "", fmt.Errorf("sysctl '%s' is not allowed", val)
|
||||
}
|
||||
|
||||
// FilterOpt is a flag type for validating filters
|
||||
@@ -347,11 +342,12 @@ func (o *FilterOpt) Set(value string) error {
|
||||
if !strings.Contains(value, "=") {
|
||||
return errors.New("bad format of filter (expected name=value)")
|
||||
}
|
||||
f := strings.SplitN(value, "=", 2)
|
||||
name := strings.ToLower(strings.TrimSpace(f[0]))
|
||||
value = strings.TrimSpace(f[1])
|
||||
name, val, _ := strings.Cut(value, "=")
|
||||
|
||||
o.filter.Add(name, value)
|
||||
// TODO(thaJeztah): these options should not be case-insensitive.
|
||||
name = strings.ToLower(strings.TrimSpace(name))
|
||||
val = strings.TrimSpace(val)
|
||||
o.filter.Add(name, val)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -411,10 +407,14 @@ func ParseLink(val string) (string, string, error) {
|
||||
if val == "" {
|
||||
return "", "", fmt.Errorf("empty string specified for links")
|
||||
}
|
||||
arr := strings.Split(val, ":")
|
||||
// We expect two parts, but restrict to three to allow detecting invalid formats.
|
||||
arr := strings.SplitN(val, ":", 3)
|
||||
|
||||
// TODO(thaJeztah): clean up this logic!!
|
||||
if len(arr) > 2 {
|
||||
return "", "", fmt.Errorf("bad format for links: %s", val)
|
||||
}
|
||||
// TODO(thaJeztah): this should trim the "/" prefix as well??
|
||||
if len(arr) == 1 {
|
||||
return val, val, nil
|
||||
}
|
||||
@@ -422,6 +422,7 @@ func ParseLink(val string) (string, string, error) {
|
||||
// from an already created container and the format is not `foo:bar`
|
||||
// but `/foo:/c1/bar`
|
||||
if strings.HasPrefix(arr[0], "/") {
|
||||
// TODO(thaJeztah): clean up this logic!!
|
||||
_, alias := path.Split(arr[1])
|
||||
return arr[0][1:], alias, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user