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:
Sebastiaan van Stijn
2023-02-08 15:32:57 +01:00
parent 260117289b
commit 081447c9b1
26 changed files with 540 additions and 224 deletions

View File

@@ -13,14 +13,15 @@ type ValidatorWeightFctType func(val string) (*blkiodev.WeightDevice, error)
// ValidateWeightDevice validates that the specified string has a valid device-weight format.
func ValidateWeightDevice(val string) (*blkiodev.WeightDevice, error) {
split := strings.SplitN(val, ":", 2)
if len(split) != 2 {
k, v, ok := strings.Cut(val, ":")
if !ok || k == "" {
return nil, fmt.Errorf("bad format: %s", val)
}
if !strings.HasPrefix(split[0], "/dev/") {
// TODO(thaJeztah): should we really validate this on the client?
if !strings.HasPrefix(k, "/dev/") {
return nil, fmt.Errorf("bad format for device path: %s", val)
}
weight, err := strconv.ParseUint(split[1], 10, 16)
weight, err := strconv.ParseUint(v, 10, 16)
if err != nil {
return nil, fmt.Errorf("invalid weight for device: %s", val)
}
@@ -29,7 +30,7 @@ func ValidateWeightDevice(val string) (*blkiodev.WeightDevice, error) {
}
return &blkiodev.WeightDevice{
Path: split[0],
Path: k,
Weight: uint16(weight),
}, nil
}
@@ -42,9 +43,8 @@ type WeightdeviceOpt struct {
// NewWeightdeviceOpt creates a new WeightdeviceOpt
func NewWeightdeviceOpt(validator ValidatorWeightFctType) WeightdeviceOpt {
values := []*blkiodev.WeightDevice{}
return WeightdeviceOpt{
values: values,
values: []*blkiodev.WeightDevice{},
validator: validator,
}
}
@@ -59,7 +59,7 @@ func (opt *WeightdeviceOpt) Set(val string) error {
}
value = v
}
(opt.values) = append((opt.values), value)
opt.values = append(opt.values, value)
return nil
}