chore: make deps

This commit is contained in:
2025-11-11 14:18:57 +01:00
parent db7c4042d0
commit 45af67d22d
590 changed files with 22837 additions and 16387 deletions

View File

@ -1,14 +0,0 @@
package opts
import (
"os"
"github.com/docker/cli/pkg/kvfile"
)
// ParseEnvFile reads a file with environment variables enumerated by lines
//
// Deprecated: use [kvfile.Parse] and pass [os.LookupEnv] to lookup env-vars from the current environment.
func ParseEnvFile(filename string) ([]string, error) {
return kvfile.Parse(filename, os.LookupEnv)
}

View File

@ -7,7 +7,7 @@ import (
"strconv"
"strings"
"github.com/docker/docker/api/types/container"
"github.com/moby/moby/api/types/container"
)
// GpuOpts is a Value type for parsing mounts

View File

@ -32,23 +32,6 @@ const (
hostGatewayName = "host-gateway"
)
// ValidateHost validates that the specified string is a valid host and returns it.
//
// Deprecated: this function is no longer used, and will be removed in the next release.
func ValidateHost(val string) (string, error) {
host := strings.TrimSpace(val)
// The empty string means default and is not handled by parseDockerDaemonHost
if host != "" {
_, err := parseDockerDaemonHost(host)
if err != nil {
return val, err
}
}
// Note: unlike most flag validators, we don't return the mutated value here
// we need to know what the user entered later (using ParseHost) to adjust for TLS
return val, nil
}
// ParseHost and set defaults for a Daemon host string
func ParseHost(defaultToTLS bool, val string) (string, error) {
host := strings.TrimSpace(val)

View File

@ -9,9 +9,8 @@ import (
"strconv"
"strings"
mounttypes "github.com/docker/docker/api/types/mount"
"github.com/docker/go-units"
"github.com/sirupsen/logrus"
mounttypes "github.com/moby/moby/api/types/mount"
)
// MountOpt is a Value type for parsing mounts
@ -88,8 +87,7 @@ func (m *MountOpt) Set(value string) error {
volumeOptions().NoCopy = true
continue
case "bind-nonrecursive":
bindOptions().NonRecursive = true
continue
return errors.New("bind-nonrecursive is deprecated, use bind-recursive=disabled instead")
default:
return fmt.Errorf("invalid field '%s' must be a key=value pair", field)
}
@ -117,16 +115,12 @@ func (m *MountOpt) Set(value string) error {
case "bind-propagation":
bindOptions().Propagation = mounttypes.Propagation(strings.ToLower(val))
case "bind-nonrecursive":
bindOptions().NonRecursive, err = strconv.ParseBool(val)
if err != nil {
return fmt.Errorf("invalid value for %s: %s", key, val)
}
logrus.Warn("bind-nonrecursive is deprecated, use bind-recursive=disabled instead")
return errors.New("bind-nonrecursive is deprecated, use bind-recursive=disabled instead")
case "bind-recursive":
switch val {
case "enabled": // read-only mounts are recursively read-only if Engine >= v25 && kernel >= v5.12, otherwise writable
// NOP
case "disabled": // alias of bind-nonrecursive=true
case "disabled": // previously "bind-nonrecursive=true"
bindOptions().NonRecursive = true
case "writable": // conforms to the default read-only bind-mount of Docker v24; read-only mounts are recursively mounted but not recursively read-only
bindOptions().ReadOnlyNonRecursive = true

View File

@ -4,6 +4,7 @@ import (
"encoding/csv"
"errors"
"fmt"
"net/netip"
"regexp"
"strconv"
"strings"
@ -26,9 +27,9 @@ type NetworkAttachmentOpts struct {
Aliases []string
DriverOpts map[string]string
Links []string // TODO add support for links in the csv notation of `--network`
IPv4Address string
IPv6Address string
LinkLocalIPs []string
IPv4Address netip.Addr
IPv6Address netip.Addr
LinkLocalIPs []netip.Addr
MacAddress string
GwPriority int
}
@ -70,13 +71,23 @@ func (n *NetworkOpt) Set(value string) error { //nolint:gocyclo
case networkOptAlias:
netOpt.Aliases = append(netOpt.Aliases, val)
case networkOptIPv4Address:
netOpt.IPv4Address = val
netOpt.IPv4Address, err = netip.ParseAddr(val)
if err != nil {
return err
}
case networkOptIPv6Address:
netOpt.IPv6Address = val
netOpt.IPv6Address, err = netip.ParseAddr(val)
if err != nil {
return err
}
case networkOptMacAddress:
netOpt.MacAddress = val
case networkOptLinkLocalIP:
netOpt.LinkLocalIPs = append(netOpt.LinkLocalIPs, val)
a, err := netip.ParseAddr(val)
if err != nil {
return err
}
netOpt.LinkLocalIPs = append(netOpt.LinkLocalIPs, a)
case driverOpt:
key, val, err = parseDriverOpt(val)
if err != nil {

View File

@ -1,6 +1,7 @@
package opts
import (
"encoding/json"
"errors"
"fmt"
"math/big"
@ -9,8 +10,8 @@ import (
"strings"
"github.com/docker/cli/internal/lazyregexp"
"github.com/docker/docker/api/types/filters"
"github.com/docker/go-units"
"github.com/moby/moby/client"
)
var (
@ -60,6 +61,8 @@ func (opts *ListOpts) Set(value string) error {
}
// Delete removes the specified element from the slice.
//
// Deprecated: this method is no longer used and will be removed in the next release.
func (opts *ListOpts) Delete(key string) {
for i, k := range *opts.values {
if k == key {
@ -79,13 +82,6 @@ func (opts *ListOpts) GetMap() map[string]struct{} {
return ret
}
// GetAll returns the values of slice.
//
// Deprecated: use [ListOpts.GetSlice] instead. This method will be removed in a future release.
func (opts *ListOpts) GetAll() []string {
return *opts.values
}
// GetSlice returns the values of slice.
//
// It implements [cobra.SliceValue] to allow shell completion to be provided
@ -132,43 +128,6 @@ func (opts *ListOpts) WithValidator(validator ValidatorFctType) *ListOpts {
return opts
}
// NamedOption is an interface that list and map options
// with names implement.
//
// Deprecated: NamedOption is no longer used and will be removed in the next release.
type NamedOption interface {
Name() string
}
// NamedListOpts is a ListOpts with a configuration name.
// This struct is useful to keep reference to the assigned
// field name in the internal configuration struct.
//
// Deprecated: NamedListOpts is no longer used and will be removed in the next release.
type NamedListOpts struct {
name string
ListOpts
}
var _ NamedOption = &NamedListOpts{}
// NewNamedListOptsRef creates a reference to a new NamedListOpts struct.
//
// Deprecated: NewNamedListOptsRef is no longer used and will be removed in the next release.
func NewNamedListOptsRef(name string, values *[]string, validator ValidatorFctType) *NamedListOpts {
return &NamedListOpts{
name: name,
ListOpts: *NewListOptsRef(values, validator),
}
}
// Name returns the name of the NamedListOpts in the configuration.
//
// Deprecated: NamedListOpts is no longer used and will be removed in the next release.
func (o *NamedListOpts) Name() string {
return o.name
}
// MapOpts holds a map of values and a validation function.
type MapOpts struct {
values map[string]string
@ -215,35 +174,6 @@ func NewMapOpts(values map[string]string, validator ValidatorFctType) *MapOpts {
}
}
// NamedMapOpts is a MapOpts struct with a configuration name.
// This struct is useful to keep reference to the assigned
// field name in the internal configuration struct.
//
// Deprecated: NamedMapOpts is no longer used and will be removed in the next release.
type NamedMapOpts struct {
name string
MapOpts
}
var _ NamedOption = &NamedMapOpts{}
// NewNamedMapOpts creates a reference to a new NamedMapOpts struct.
//
// Deprecated: NamedMapOpts is no longer used and will be removed in the next release.
func NewNamedMapOpts(name string, values map[string]string, validator ValidatorFctType) *NamedMapOpts {
return &NamedMapOpts{
name: name,
MapOpts: *NewMapOpts(values, validator),
}
}
// Name returns the name of the NamedMapOpts in the configuration.
//
// Deprecated: NamedMapOpts is no longer used and will be removed in the next release.
func (o *NamedMapOpts) Name() string {
return o.name
}
// ValidatorFctType defines a validator function that returns a validated string and/or an error.
type ValidatorFctType func(val string) (string, error)
@ -264,6 +194,8 @@ func ValidateIPAddress(val string) (string, error) {
}
// ValidateMACAddress validates a MAC address.
//
// Deprecated: use [net.ParseMAC]. This function will be removed in the next release.
func ValidateMACAddress(val string) (string, error) {
_, err := net.ParseMAC(strings.TrimSpace(val))
if err != nil {
@ -350,20 +282,23 @@ func ValidateSysctl(val string) (string, error) {
// FilterOpt is a flag type for validating filters
type FilterOpt struct {
filter filters.Args
filter client.Filters
}
// NewFilterOpt returns a new FilterOpt
func NewFilterOpt() FilterOpt {
return FilterOpt{filter: filters.NewArgs()}
return FilterOpt{filter: make(client.Filters)}
}
func (o *FilterOpt) String() string {
repr, err := filters.ToJSON(o.filter)
if o == nil || len(o.filter) == 0 {
return ""
}
repr, err := json.Marshal(o.filter)
if err != nil {
return "invalid filters"
}
return repr
return string(repr)
}
// Set sets the value of the opt by parsing the command line value
@ -389,7 +324,7 @@ func (*FilterOpt) Type() string {
}
// Value returns the value of this option
func (o *FilterOpt) Value() filters.Args {
func (o *FilterOpt) Value() client.Filters {
return o.filter
}

View File

@ -7,7 +7,7 @@ import (
"strings"
"github.com/docker/cli/pkg/kvfile"
"github.com/docker/docker/api/types/container"
"github.com/moby/moby/api/types/container"
)
// ReadKVStrings reads a file of line terminated key=value pairs, and overrides any keys

View File

@ -1,44 +0,0 @@
package opts
// QuotedString is a string that may have extra quotes around the value. The
// quotes are stripped from the value.
//
// Deprecated: This option type is no longer used and will be removed in the next release.
type QuotedString struct {
value *string
}
// Set sets a new value
func (s *QuotedString) Set(val string) error {
*s.value = trimQuotes(val)
return nil
}
// Type returns the type of the value
func (*QuotedString) Type() string {
return "string"
}
func (s *QuotedString) String() string {
return *s.value
}
func trimQuotes(value string) string {
if len(value) < 2 {
return value
}
lastIndex := len(value) - 1
for _, char := range []byte{'\'', '"'} {
if value[0] == char && value[lastIndex] == char {
return value[1:lastIndex]
}
}
return value
}
// NewQuotedString returns a new quoted string option
//
// Deprecated: This option type is no longer used and will be removed in the next release.
func NewQuotedString(value *string) *QuotedString {
return &QuotedString{value: value}
}

View File

@ -8,7 +8,7 @@ import (
"strconv"
"strings"
"github.com/docker/docker/api/types/swarm"
"github.com/moby/moby/api/types/swarm"
)
// ConfigOpt is a Value type for parsing configs

View File

@ -9,8 +9,9 @@ import (
"strconv"
"strings"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/go-connections/nat"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/api/types/swarm"
"github.com/sirupsen/logrus"
)
@ -41,7 +42,10 @@ func (p *PortOpt) Set(value string) error {
return err
}
pConfig := swarm.PortConfig{}
pConfig := swarm.PortConfig{
Protocol: network.TCP,
PublishMode: swarm.PortConfigPublishModeIngress,
}
for _, field := range fields {
// TODO(thaJeztah): these options should not be case-insensitive.
key, val, ok := strings.Cut(strings.ToLower(field), "=")
@ -50,17 +54,19 @@ func (p *PortOpt) Set(value string) error {
}
switch key {
case portOptProtocol:
if val != string(swarm.PortConfigProtocolTCP) && val != string(swarm.PortConfigProtocolUDP) && val != string(swarm.PortConfigProtocolSCTP) {
switch proto := network.IPProtocol(val); proto {
case network.TCP, network.UDP, network.SCTP:
pConfig.Protocol = proto
default:
return fmt.Errorf("invalid protocol value '%s'", val)
}
pConfig.Protocol = swarm.PortConfigProtocol(val)
case portOptMode:
if val != string(swarm.PortConfigPublishModeIngress) && val != string(swarm.PortConfigPublishModeHost) {
switch swarm.PortConfigPublishMode(val) {
case swarm.PortConfigPublishModeIngress, swarm.PortConfigPublishModeHost:
pConfig.PublishMode = swarm.PortConfigPublishMode(val)
default:
return fmt.Errorf("invalid publish mode value (%s): must be either '%s' or '%s'", val, swarm.PortConfigPublishModeIngress, swarm.PortConfigPublishModeHost)
}
pConfig.PublishMode = swarm.PortConfigPublishMode(val)
case portOptTargetPort:
tPort, err := strconv.ParseUint(val, 10, 16)
if err != nil {
@ -92,18 +98,9 @@ func (p *PortOpt) Set(value string) error {
return fmt.Errorf("missing mandatory field '%s'", portOptTargetPort)
}
if pConfig.PublishMode == "" {
pConfig.PublishMode = swarm.PortConfigPublishModeIngress
}
if pConfig.Protocol == "" {
pConfig.Protocol = swarm.PortConfigProtocolTCP
}
p.ports = append(p.ports, pConfig)
} else {
// short syntax
portConfigs := []swarm.PortConfig{}
ports, portBindingMap, err := nat.ParsePortSpecs([]string{value})
if err != nil {
return err
@ -116,8 +113,13 @@ func (p *PortOpt) Set(value string) error {
}
}
var portConfigs []swarm.PortConfig
for port := range ports {
portConfig, err := ConvertPortToPortConfig(port, portBindingMap)
portProto, err := network.ParsePort(string(port))
if err != nil {
return err
}
portConfig, err := ConvertPortToPortConfig(portProto, portBindingMap)
if err != nil {
return err
}
@ -135,7 +137,7 @@ func (*PortOpt) Type() string {
// String returns a string repr of this option
func (p *PortOpt) String() string {
ports := []string{}
ports := make([]string, 0, len(p.ports))
for _, port := range p.ports {
repr := fmt.Sprintf("%v:%v/%s/%s", port.PublishedPort, port.TargetPort, port.Protocol, port.PublishMode)
ports = append(ports, repr)
@ -150,28 +152,27 @@ func (p *PortOpt) Value() []swarm.PortConfig {
// ConvertPortToPortConfig converts ports to the swarm type
func ConvertPortToPortConfig(
port nat.Port,
portProto network.Port,
portBindings map[nat.Port][]nat.PortBinding,
) ([]swarm.PortConfig, error) {
ports := []swarm.PortConfig{}
for _, binding := range portBindings[port] {
ports := make([]swarm.PortConfig, 0, len(portBindings))
for _, binding := range portBindings[nat.Port(portProto.String())] {
if p := net.ParseIP(binding.HostIP); p != nil && !p.IsUnspecified() {
// TODO(thaJeztah): use context-logger, so that this output can be suppressed (in tests).
logrus.Warnf("ignoring IP-address (%s:%s) service will listen on '0.0.0.0'", net.JoinHostPort(binding.HostIP, binding.HostPort), port)
logrus.Warnf("ignoring IP-address (%s:%s) service will listen on '0.0.0.0'", net.JoinHostPort(binding.HostIP, binding.HostPort), portProto.String())
}
startHostPort, endHostPort, err := nat.ParsePortRange(binding.HostPort)
if err != nil && binding.HostPort != "" {
return nil, fmt.Errorf("invalid hostport binding (%s) for port (%s)", binding.HostPort, port.Port())
return nil, fmt.Errorf("invalid hostport binding (%s) for port (%d)", binding.HostPort, portProto.Num())
}
for i := startHostPort; i <= endHostPort; i++ {
ports = append(ports, swarm.PortConfig{
// TODO Name: ?
Protocol: swarm.PortConfigProtocol(strings.ToLower(port.Proto())),
TargetPort: uint32(port.Int()),
Protocol: portProto.Proto(),
TargetPort: uint32(portProto.Num()),
PublishedPort: uint32(i),
PublishMode: swarm.PortConfigPublishModeIngress,
})

View File

@ -8,7 +8,7 @@ import (
"strconv"
"strings"
"github.com/docker/docker/api/types/swarm"
"github.com/moby/moby/api/types/swarm"
)
// SecretOpt is a Value type for parsing secrets

View File

@ -5,8 +5,8 @@ import (
"strconv"
"strings"
"github.com/docker/docker/api/types/blkiodev"
"github.com/docker/go-units"
"github.com/moby/moby/api/types/blkiodev"
)
// ValidatorThrottleFctType defines a validator function that returns a validated struct and/or an error.

View File

@ -4,8 +4,8 @@ import (
"fmt"
"sort"
"github.com/docker/docker/api/types/container"
"github.com/docker/go-units"
"github.com/moby/moby/api/types/container"
)
// UlimitOpt defines a map of Ulimits

View File

@ -5,7 +5,7 @@ import (
"strconv"
"strings"
"github.com/docker/docker/api/types/blkiodev"
"github.com/moby/moby/api/types/blkiodev"
)
// ValidatorWeightFctType defines a validator function that returns a validated struct and/or an error.