mirror of
https://github.com/containers/podman.git
synced 2025-10-19 20:23:08 +08:00
vendor: bump c/common to 9b0d134f392
Bump common to 9b0d134f392f41de3f3065aad162e73a3904168e Signed-off-by: flouthoc <flouthoc.git@gmail.com>
This commit is contained in:
7
vendor/github.com/containers/common/libimage/copier.go
generated
vendored
7
vendor/github.com/containers/common/libimage/copier.go
generated
vendored
@ -178,7 +178,7 @@ type Copier struct {
|
||||
// Note that fields in options *may* overwrite the counterparts of
|
||||
// the specified system context. Please make sure to call `(*Copier).Close()`.
|
||||
func (r *Runtime) newCopier(options *CopyOptions) (*Copier, error) {
|
||||
return NewCopier(options, r.SystemContext(), nil)
|
||||
return NewCopier(options, r.SystemContext())
|
||||
}
|
||||
|
||||
// storageAllowedPolicyScopes overrides the policy for local storage
|
||||
@ -225,7 +225,7 @@ func getDockerAuthConfig(name, passwd, creds, idToken string) (*types.DockerAuth
|
||||
// NewCopier creates a Copier based on a provided system context.
|
||||
// Note that fields in options *may* overwrite the counterparts of
|
||||
// the specified system context. Please make sure to call `(*Copier).Close()`.
|
||||
func NewCopier(options *CopyOptions, sc *types.SystemContext, reportResolvedReference *types.ImageReference) (*Copier, error) {
|
||||
func NewCopier(options *CopyOptions, sc *types.SystemContext) (*Copier, error) {
|
||||
c := Copier{extendTimeoutSocket: options.extendTimeoutSocket}
|
||||
sysContextCopy := *sc
|
||||
c.systemContext = &sysContextCopy
|
||||
@ -332,7 +332,6 @@ func NewCopier(options *CopyOptions, sc *types.SystemContext, reportResolvedRefe
|
||||
c.imageCopyOptions.SignBySigstorePrivateKeyFile = options.SignBySigstorePrivateKeyFile
|
||||
c.imageCopyOptions.SignSigstorePrivateKeyPassphrase = options.SignSigstorePrivateKeyPassphrase
|
||||
c.imageCopyOptions.ReportWriter = options.Writer
|
||||
c.imageCopyOptions.ReportResolvedReference = reportResolvedReference
|
||||
|
||||
defaultContainerConfig, err := config.Default()
|
||||
if err != nil {
|
||||
@ -489,7 +488,7 @@ func (c *Copier) copyToStorage(ctx context.Context, source, destination types.Im
|
||||
var resolvedReference types.ImageReference
|
||||
_, err := c.copyInternal(ctx, source, destination, &resolvedReference)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("internal error: unable to copy from source %s: %w", source, err)
|
||||
return nil, fmt.Errorf("internal error: unable to copy from source %s: %w", transports.ImageName(source), err)
|
||||
}
|
||||
if resolvedReference == nil {
|
||||
return nil, fmt.Errorf("internal error: After attempting to copy %s, resolvedReference is nil", source)
|
||||
|
4
vendor/github.com/containers/common/libimage/image.go
generated
vendored
4
vendor/github.com/containers/common/libimage/image.go
generated
vendored
@ -463,13 +463,13 @@ func (i *Image) removeRecursive(ctx context.Context, rmMap map[string]*RemoveIma
|
||||
skipRemove := false
|
||||
numNames := len(i.Names())
|
||||
|
||||
// NOTE: the `numNames == 1` check is not only a performance
|
||||
// NOTE: the `numNames != 1` check is not only a performance
|
||||
// optimization but also preserves existing Podman/Docker behaviour.
|
||||
// If image "foo" is used by a container and has only this tag/name,
|
||||
// an `rmi foo` will not untag "foo" but instead attempt to remove the
|
||||
// entire image. If there's a container using "foo", we should get an
|
||||
// error.
|
||||
if !(referencedBy == "" || numNames == 1) {
|
||||
if referencedBy != "" && numNames != 1 {
|
||||
byID := strings.HasPrefix(i.ID(), referencedBy)
|
||||
byDigest := strings.HasPrefix(referencedBy, "sha256:")
|
||||
if !options.Force {
|
||||
|
2
vendor/github.com/containers/common/libimage/load.go
generated
vendored
2
vendor/github.com/containers/common/libimage/load.go
generated
vendored
@ -115,7 +115,7 @@ func (r *Runtime) Load(ctx context.Context, path string, options *LoadOptions) (
|
||||
|
||||
// Give a decent error message if nothing above worked.
|
||||
// we want the colon here for the multiline error
|
||||
//nolint:revive
|
||||
//nolint:revive,staticcheck
|
||||
loadError := errors.New("payload does not match any of the supported image formats:")
|
||||
for _, err := range loadErrors {
|
||||
loadError = fmt.Errorf("%v\n * %v", loadError, err)
|
||||
|
2
vendor/github.com/containers/common/libimage/normalize.go
generated
vendored
2
vendor/github.com/containers/common/libimage/normalize.go
generated
vendored
@ -30,7 +30,7 @@ func NormalizeName(name string) (reference.Named, error) {
|
||||
|
||||
// Enforce "localhost" if needed.
|
||||
registry := reference.Domain(named)
|
||||
if !(strings.ContainsAny(registry, ".:") || registry == "localhost") {
|
||||
if !strings.ContainsAny(registry, ".:") && registry != "localhost" {
|
||||
name = toLocalImageName(ref.String())
|
||||
}
|
||||
|
||||
|
2
vendor/github.com/containers/common/libimage/search.go
generated
vendored
2
vendor/github.com/containers/common/libimage/search.go
generated
vendored
@ -217,7 +217,7 @@ func (r *Runtime) searchImageInRegistry(ctx context.Context, term, registry stri
|
||||
paramsArr := []SearchResult{}
|
||||
for i := range limit {
|
||||
// Check whether query matches filters
|
||||
if !(filterMatchesAutomatedFilter(&options.Filter, results[i]) && filterMatchesOfficialFilter(&options.Filter, results[i]) && filterMatchesStarFilter(&options.Filter, results[i])) {
|
||||
if !filterMatchesAutomatedFilter(&options.Filter, results[i]) || !filterMatchesOfficialFilter(&options.Filter, results[i]) || !filterMatchesStarFilter(&options.Filter, results[i]) {
|
||||
continue
|
||||
}
|
||||
official := ""
|
||||
|
2
vendor/github.com/containers/common/libnetwork/cni/network.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/cni/network.go
generated
vendored
@ -191,7 +191,7 @@ func (n *cniNetwork) loadNetworks() error {
|
||||
}
|
||||
|
||||
if !types.NameRegex.MatchString(conf.Name) {
|
||||
logrus.Warnf("CNI config list %s has invalid name, skipping: %v", file, types.RegexError)
|
||||
logrus.Warnf("CNI config list %s has invalid name, skipping: %v", file, types.ErrInvalidName)
|
||||
continue
|
||||
}
|
||||
|
||||
|
2
vendor/github.com/containers/common/libnetwork/internal/util/bridge.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/internal/util/bridge.go
generated
vendored
@ -19,7 +19,7 @@ func CreateBridge(n NetUtil, network *types.Network, usedNetworks []*net.IPNet,
|
||||
}
|
||||
}
|
||||
if !types.NameRegex.MatchString(network.NetworkInterface) {
|
||||
return fmt.Errorf("bridge name %s invalid: %w", network.NetworkInterface, types.RegexError)
|
||||
return fmt.Errorf("bridge name %s invalid: %w", network.NetworkInterface, types.ErrInvalidName)
|
||||
}
|
||||
} else {
|
||||
var err error
|
||||
|
2
vendor/github.com/containers/common/libnetwork/internal/util/create.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/internal/util/create.go
generated
vendored
@ -23,7 +23,7 @@ func CommonNetworkCreate(n NetUtil, network *types.Network) error {
|
||||
// validate the name when given
|
||||
if network.Name != "" {
|
||||
if !types.NameRegex.MatchString(network.Name) {
|
||||
return fmt.Errorf("network name %s invalid: %w", network.Name, types.RegexError)
|
||||
return fmt.Errorf("network name %s invalid: %w", network.Name, types.ErrInvalidName)
|
||||
}
|
||||
if _, err := n.Network(network.Name); err == nil {
|
||||
return fmt.Errorf("network name %s already used: %w", network.Name, types.ErrNetworkExists)
|
||||
|
5
vendor/github.com/containers/common/libnetwork/netavark/config.go
generated
vendored
5
vendor/github.com/containers/common/libnetwork/netavark/config.go
generated
vendored
@ -294,10 +294,7 @@ func createIpvlanOrMacvlan(network *types.Network) error {
|
||||
}
|
||||
|
||||
driver := network.Driver
|
||||
isMacVlan := true
|
||||
if driver == types.IPVLANNetworkDriver {
|
||||
isMacVlan = false
|
||||
}
|
||||
isMacVlan := driver != types.IPVLANNetworkDriver
|
||||
|
||||
// always turn dns off with macvlan, it is not implemented in netavark
|
||||
// and makes little sense to support with macvlan
|
||||
|
2
vendor/github.com/containers/common/libnetwork/netavark/network.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/netavark/network.go
generated
vendored
@ -248,7 +248,7 @@ func (n *netavarkNetwork) loadNetworks() error {
|
||||
}
|
||||
|
||||
if !types.NameRegex.MatchString(network.Name) {
|
||||
logrus.Warnf("Network config %q has invalid name: %q, skipping: %v", path, network.Name, types.RegexError)
|
||||
logrus.Warnf("Network config %q has invalid name: %q, skipping: %v", path, network.Name, types.ErrInvalidName)
|
||||
continue
|
||||
}
|
||||
|
||||
|
2
vendor/github.com/containers/common/libnetwork/slirp4netns/slirp4netns.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/slirp4netns/slirp4netns.go
generated
vendored
@ -682,7 +682,7 @@ func openSlirp4netnsPort(apiSocket, proto, hostip string, hostport, guestport ui
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot marshal JSON for slirp4netns: %w", err)
|
||||
}
|
||||
if _, err := conn.Write([]byte(fmt.Sprintf("%s\n", data))); err != nil {
|
||||
if _, err := fmt.Fprintf(conn, "%s\n", data); err != nil {
|
||||
return fmt.Errorf("cannot write to control socket %s: %w", apiSocket, err)
|
||||
}
|
||||
//nolint:errcheck // This cast should never fail, if it does we get a interface
|
||||
|
6
vendor/github.com/containers/common/libnetwork/types/define.go
generated
vendored
6
vendor/github.com/containers/common/libnetwork/types/define.go
generated
vendored
@ -24,8 +24,10 @@ var (
|
||||
// NameRegex is a regular expression to validate names.
|
||||
// This must NOT be changed.
|
||||
NameRegex = regexp.Delayed("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$")
|
||||
// RegexError is thrown in presence of an invalid name.
|
||||
RegexError = fmt.Errorf("names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*: %w", ErrInvalidArg) // nolint:revive // This lint is new and we do not want to break the API.
|
||||
// ErrInvalidName is thrown in presence of an invalid name.
|
||||
ErrInvalidName = fmt.Errorf("names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*: %w", ErrInvalidArg)
|
||||
// Deprecated: use [ErrInvalidName] instead.
|
||||
RegexError = ErrInvalidName
|
||||
|
||||
// NotHexRegex is a regular expression to check if a string is
|
||||
// a hexadecimal string.
|
||||
|
4
vendor/github.com/containers/common/pkg/auth/auth.go
generated
vendored
4
vendor/github.com/containers/common/pkg/auth/auth.go
generated
vendored
@ -173,10 +173,10 @@ func Login(ctx context.Context, systemContext *types.SystemContext, opts *LoginO
|
||||
if opts.StdinPassword {
|
||||
var stdinPasswordStrBuilder strings.Builder
|
||||
if opts.Password != "" {
|
||||
return errors.New("Can't specify both --password-stdin and --password")
|
||||
return errors.New("can't specify both --password-stdin and --password")
|
||||
}
|
||||
if opts.Username == "" {
|
||||
return errors.New("Must provide --username with --password-stdin")
|
||||
return errors.New("must provide --username with --password-stdin")
|
||||
}
|
||||
scanner := bufio.NewScanner(opts.Stdin)
|
||||
for scanner.Scan() {
|
||||
|
4
vendor/github.com/containers/common/pkg/cgroups/utils_linux.go
generated
vendored
4
vendor/github.com/containers/common/pkg/cgroups/utils_linux.go
generated
vendored
@ -221,7 +221,7 @@ func MoveUnderCgroup(cgroup, subtree string, processes []uint32) error {
|
||||
}
|
||||
|
||||
// root cgroup, skip it
|
||||
if parts[2] == "/" && !(unifiedMode && parts[1] == "") {
|
||||
if parts[2] == "/" && (!unifiedMode || parts[1] != "") {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -261,7 +261,7 @@ func MoveUnderCgroup(cgroup, subtree string, processes []uint32) error {
|
||||
|
||||
if len(processes) > 0 {
|
||||
for _, pid := range processes {
|
||||
if _, err := f.WriteString(fmt.Sprintf("%d\n", pid)); err != nil {
|
||||
if _, err := fmt.Fprintf(f, "%d\n", pid); err != nil {
|
||||
logrus.Debugf("Cannot move process %d to cgroup %q: %v", pid, newCgroup, err)
|
||||
}
|
||||
}
|
||||
|
2
vendor/github.com/containers/common/pkg/parse/parse_unix.go
generated
vendored
2
vendor/github.com/containers/common/pkg/parse/parse_unix.go
generated
vendored
@ -17,7 +17,7 @@ func DeviceFromPath(device string) ([]devices.Device, error) {
|
||||
return nil, err
|
||||
}
|
||||
if unshare.IsRootless() && src != dst {
|
||||
return nil, fmt.Errorf("Renaming device %s to %s is not supported in rootless containers", src, dst)
|
||||
return nil, fmt.Errorf("renaming device %s to %s is not supported in rootless containers", src, dst)
|
||||
}
|
||||
srcInfo, err := os.Stat(src)
|
||||
if err != nil {
|
||||
|
11
vendor/github.com/containers/common/pkg/retry/retry.go
generated
vendored
11
vendor/github.com/containers/common/pkg/retry/retry.go
generated
vendored
@ -5,10 +5,12 @@ import (
|
||||
"io"
|
||||
"math"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/containers/image/v5/docker"
|
||||
"github.com/docker/distribution/registry/api/errcode"
|
||||
errcodev2 "github.com/docker/distribution/registry/api/v2"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
@ -47,7 +49,7 @@ func IfNecessary(ctx context.Context, operation func() error, options *Options)
|
||||
logrus.Warnf("Failed, retrying in %s ... (%d/%d). Error: %v", delay, attempt+1, options.MaxRetry, err)
|
||||
select {
|
||||
case <-time.After(delay):
|
||||
break
|
||||
// Do nothing.
|
||||
case <-ctx.Done():
|
||||
return err
|
||||
}
|
||||
@ -81,6 +83,13 @@ func IsErrorRetryable(err error) bool {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
case docker.UnexpectedHTTPStatusError:
|
||||
// Retry on 502, 502 and 503 http server errors, they appear to be quite common in the field.
|
||||
// https://github.com/containers/common/issues/2299
|
||||
if e.StatusCode >= http.StatusBadGateway && e.StatusCode <= http.StatusGatewayTimeout {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
case *net.OpError:
|
||||
return IsErrorRetryable(e.Err)
|
||||
case *url.Error: // This includes errors returned by the net/http client.
|
||||
|
2
vendor/github.com/containers/common/pkg/secrets/secrets.go
generated
vendored
2
vendor/github.com/containers/common/pkg/secrets/secrets.go
generated
vendored
@ -166,7 +166,7 @@ func (s *SecretsManager) Store(name string, data []byte, driverType string, opti
|
||||
return "", err
|
||||
}
|
||||
|
||||
if !(len(data) > 0 && len(data) < maxSecretSize) {
|
||||
if len(data) == 0 || len(data) >= maxSecretSize {
|
||||
return "", errDataSize
|
||||
}
|
||||
var secr *Secret
|
||||
|
14
vendor/github.com/containers/common/pkg/subscriptions/subscriptions.go
generated
vendored
14
vendor/github.com/containers/common/pkg/subscriptions/subscriptions.go
generated
vendored
@ -322,7 +322,7 @@ func addSubscriptionsFromMountsFile(filePath, mountLabel, containerRunDir string
|
||||
func containerHasEtcSystemFips(subscriptionsDir, mountPoint string) (bool, error) {
|
||||
containerEtc, err := securejoin.SecureJoin(mountPoint, "etc")
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("Container /etc resolution error: %w", err)
|
||||
return false, fmt.Errorf("container /etc resolution error: %w", err)
|
||||
}
|
||||
if fileutils.Lexists(filepath.Join(containerEtc, "system-fips")) != nil {
|
||||
logrus.Debug("/etc/system-fips does not exist in the container, not creating /run/secrets/system-fips")
|
||||
@ -331,7 +331,7 @@ func containerHasEtcSystemFips(subscriptionsDir, mountPoint string) (bool, error
|
||||
|
||||
fipsFileTarget, err := securejoin.SecureJoin(mountPoint, "etc/system-fips")
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("Container /etc/system-fips resolution error: %w", err)
|
||||
return false, fmt.Errorf("container /etc/system-fips resolution error: %w", err)
|
||||
}
|
||||
if fipsFileTarget != filepath.Join(mountPoint, subscriptionsDir, "system-fips") {
|
||||
logrus.Warnf("/etc/system-fips exists in the container, but is not a symlink to %[1]v/system-fips; not creating %[1]v/system-fips", subscriptionsDir)
|
||||
@ -448,24 +448,24 @@ func addFIPSMounts(mounts *[]rspec.Mount, containerRunDir, mountPoint, mountLabe
|
||||
destPolicyConfig := "/etc/crypto-policies/config"
|
||||
srcPolicyConfigOnHost, err := securejoin.SecureJoin(mountPoint, srcPolicyConfig)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Could not expand %q in container: %w", srcPolicyConfig, err)
|
||||
return fmt.Errorf("could not expand %q in container: %w", srcPolicyConfig, err)
|
||||
}
|
||||
|
||||
if err = fileutils.Exists(srcPolicyConfigOnHost); err != nil {
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
return fmt.Errorf("Could not check whether %q exists in container: %w", srcPolicyConfig, err)
|
||||
return fmt.Errorf("could not check whether %q exists in container: %w", srcPolicyConfig, err)
|
||||
}
|
||||
|
||||
// /usr/share/crypto-policies/default-fips-config does not exist, let's create it ourselves
|
||||
cryptoPoliciesConfigFile := filepath.Join(containerRunDir, "fips-config")
|
||||
if err := os.WriteFile(cryptoPoliciesConfigFile, []byte("FIPS\n"), 0o644); err != nil {
|
||||
return fmt.Errorf("Failed to write fips config file in container for FIPS mode: %w", err)
|
||||
return fmt.Errorf("failed to write fips config file in container for FIPS mode: %w", err)
|
||||
}
|
||||
if err = label.Relabel(cryptoPoliciesConfigFile, mountLabel, false); err != nil {
|
||||
return fmt.Errorf("Failed to apply correct labels on fips config file: %w", err)
|
||||
return fmt.Errorf("failed to apply correct labels on fips config file: %w", err)
|
||||
}
|
||||
if err := os.Chown(cryptoPoliciesConfigFile, uid, gid); err != nil {
|
||||
return fmt.Errorf("Failed to chown fips config file: %w", err)
|
||||
return fmt.Errorf("failed to chown fips config file: %w", err)
|
||||
}
|
||||
|
||||
srcPolicyConfigOnHost = cryptoPoliciesConfigFile
|
||||
|
5
vendor/github.com/containers/common/pkg/timetype/timestamp.go
generated
vendored
5
vendor/github.com/containers/common/pkg/timetype/timestamp.go
generated
vendored
@ -31,8 +31,9 @@ func GetTimestamp(value string, reference time.Time) (string, error) {
|
||||
}
|
||||
|
||||
var format string
|
||||
// if the string has a Z or a + or three dashes use parse otherwise use parseinlocation
|
||||
parseInLocation := !(strings.ContainsAny(value, "zZ+") || strings.Count(value, "-") == 3)
|
||||
// If the string has a Z, or a +, or three dashes,
|
||||
// then use time.Parse, otherwise use time.ParseInLocation.
|
||||
parseInLocation := !strings.ContainsAny(value, "zZ+") && strings.Count(value, "-") != 3
|
||||
|
||||
switch {
|
||||
case strings.Contains(value, "."):
|
||||
|
6
vendor/github.com/containers/common/pkg/timezone/timezone.go
generated
vendored
6
vendor/github.com/containers/common/pkg/timezone/timezone.go
generated
vendored
@ -20,10 +20,10 @@ import (
|
||||
// It returns the path of the created /etc/localtime file if needed.
|
||||
func ConfigureContainerTimeZone(timezone, containerRunDir, mountPoint, etcPath, containerID string) (localTimePath string, err error) {
|
||||
var timezonePath string
|
||||
switch {
|
||||
case timezone == "":
|
||||
switch timezone {
|
||||
case "":
|
||||
return "", nil
|
||||
case timezone == "local":
|
||||
case "local":
|
||||
timezonePath, err = filepath.EvalSymlinks("/etc/localtime")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("finding local timezone for container %s: %w", containerID, err)
|
||||
|
Reference in New Issue
Block a user