summaryrefslogtreecommitdiff
path: root/vendor/github.com
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com')
-rw-r--r--vendor/github.com/containers/common/pkg/config/config.go11
-rw-r--r--vendor/github.com/containers/common/pkg/config/containers.conf11
-rw-r--r--vendor/github.com/containers/common/pkg/config/default.go6
-rw-r--r--vendor/github.com/containers/common/pkg/config/libpodConfig.go407
-rw-r--r--vendor/github.com/containers/common/version/version.go2
-rw-r--r--vendor/github.com/containers/image/v5/copy/copy.go12
-rw-r--r--vendor/github.com/containers/image/v5/pkg/compression/compression.go3
-rw-r--r--vendor/github.com/containers/image/v5/pkg/shortnames/shortnames.go15
-rw-r--r--vendor/github.com/containers/image/v5/signature/policy_config.go76
-rw-r--r--vendor/github.com/containers/image/v5/signature/policy_reference_match.go65
-rw-r--r--vendor/github.com/containers/image/v5/signature/policy_types.go11
-rw-r--r--vendor/github.com/containers/image/v5/version/version.go4
-rw-r--r--vendor/github.com/golang/protobuf/proto/text_decode.go2
13 files changed, 186 insertions, 439 deletions
diff --git a/vendor/github.com/containers/common/pkg/config/config.go b/vendor/github.com/containers/common/pkg/config/config.go
index 6a44d353a..320d5e0e5 100644
--- a/vendor/github.com/containers/common/pkg/config/config.go
+++ b/vendor/github.com/containers/common/pkg/config/config.go
@@ -363,6 +363,12 @@ type EngineConfig struct {
// under. This convention is followed by the default volume driver, but
// may not be by other drivers.
VolumePath string `toml:"volume_path,omitempty"`
+
+ // VolumePlugins is a set of plugins that can be used as the backend for
+ // Podman named volumes. Each volume is specified as a name (what Podman
+ // will refer to the plugin as) mapped to a path, which must point to a
+ // Unix socket that conforms to the Volume Plugin specification.
+ VolumePlugins map[string]string `toml:"volume_plugins,omitempty"`
}
// SetOptions contains a subset of options in a Config. It's used to indicate if
@@ -445,11 +451,6 @@ func NewConfig(userConfigPath string) (*Config, error) {
return nil, err
}
- // read libpod.conf and convert the config to *Config
- if err = newLibpodConfig(config); err != nil && !os.IsNotExist(err) {
- logrus.Errorf("error reading libpod.conf: %v", err)
- }
-
// Now, gather the system configs and merge them as needed.
configs, err := systemConfigs()
if err != nil {
diff --git a/vendor/github.com/containers/common/pkg/config/containers.conf b/vendor/github.com/containers/common/pkg/config/containers.conf
index 5b5d3f9b6..12fbecc22 100644
--- a/vendor/github.com/containers/common/pkg/config/containers.conf
+++ b/vendor/github.com/containers/common/pkg/config/containers.conf
@@ -391,7 +391,7 @@ default_sysctls = [
# Default OCI runtime
#
-# runtime = "runc"
+# runtime = "crun"
# List of the OCI runtimes that support --format=json. When json is supported
# engine will use it for reporting nicer errors.
@@ -458,8 +458,11 @@ default_sysctls = [
# "/usr/bin/kata-fc",
# ]
-# The [engine.runtimes] table MUST be the last entry in this file.
+[engine.volume_plugins]
+# testplugin = "/run/podman/plugins/test.sock"
+
+# The [engine.volume_plugins] table MUST be the last entry in this file.
# (Unless another table is added)
# TOML does not provide a way to end a table other than a further table being
-# defined, so every key hereafter will be part of [runtimes] and not the main
-# config.
+# defined, so every key hereafter will be part of [volume_plugins] and not the
+# main config.
diff --git a/vendor/github.com/containers/common/pkg/config/default.go b/vendor/github.com/containers/common/pkg/config/default.go
index 4f1460e3b..2b3a098a7 100644
--- a/vendor/github.com/containers/common/pkg/config/default.go
+++ b/vendor/github.com/containers/common/pkg/config/default.go
@@ -242,11 +242,7 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
c.ImageDefaultTransport = _defaultTransport
c.StateType = BoltDBStateStore
- c.OCIRuntime = "runc"
- // If we're running on cgroupv2 v2, default to using crun.
- if cgroup2, _ := cgroupv2.Enabled(); cgroup2 {
- c.OCIRuntime = "crun"
- }
+ c.OCIRuntime = "crun"
c.ImageBuildFormat = "oci"
c.CgroupManager = defaultCgroupManager()
diff --git a/vendor/github.com/containers/common/pkg/config/libpodConfig.go b/vendor/github.com/containers/common/pkg/config/libpodConfig.go
deleted file mode 100644
index 2df3d6077..000000000
--- a/vendor/github.com/containers/common/pkg/config/libpodConfig.go
+++ /dev/null
@@ -1,407 +0,0 @@
-package config
-
-/* libpodConfig.go contains deprecated functionality and should not be used any longer */
-
-import (
- "os"
- "os/exec"
- "path/filepath"
-
- "github.com/BurntSushi/toml"
- "github.com/containers/common/pkg/cgroupv2"
- "github.com/containers/storage/pkg/unshare"
- "github.com/pkg/errors"
- "github.com/sirupsen/logrus"
-)
-
-const (
- // _rootlessConfigPath is the path to the rootless libpod.conf in $HOME.
- _rootlessConfigPath = ".config/containers/libpod.conf"
-
- // _rootConfigPath is the path to the libpod configuration file
- // This file is loaded to replace the builtin default config before
- // runtime options (e.g. WithStorageConfig) are applied.
- // If it is not present, the builtin default config is used instead
- // This path can be overridden when the runtime is created by using
- // NewRuntimeFromConfig() instead of NewRuntime().
- _rootConfigPath = _installPrefix + "/share/containers/libpod.conf"
-
- // _rootOverrideConfigPath is the path to an override for the default libpod
- // configuration file. If OverrideConfigPath exists, it will be used in
- // place of the configuration file pointed to by ConfigPath.
- _rootOverrideConfigPath = _etcDir + "/containers/libpod.conf"
-)
-
-// ConfigFromLibpod contains configuration options used to set up a libpod runtime
-type ConfigFromLibpod struct {
- // NOTE: when changing this struct, make sure to update (*Config).Merge().
-
- // SetOptions contains a subset of config options. It's used to indicate if
- // a given option has either been set by the user or by a parsed libpod
- // configuration file. If not, the corresponding option might be
- // overwritten by values from the database. This behavior guarantees
- // backwards compat with older version of libpod and Podman.
- SetOptions
-
- // VolumePath is the default location that named volumes will be created
- // under. This convention is followed by the default volume driver, but
- // may not be by other drivers.
- VolumePath string `toml:"volume_path,omitempty"`
-
- // ImageDefaultTransport is the default transport method used to fetch
- // images.
- ImageDefaultTransport string `toml:"image_default_transport,omitempty"`
-
- // SignaturePolicyPath is the path to a signature policy to use for
- // validating images. If left empty, the containers/image default signature
- // policy will be used.
- SignaturePolicyPath string `toml:"signature_policy_path,omitempty"`
-
- // OCIRuntime is the OCI runtime to use.
- OCIRuntime string `toml:"runtime,omitempty"`
-
- // OCIRuntimes are the set of configured OCI runtimes (default is runc).
- OCIRuntimes map[string][]string `toml:"runtimes,omitempty"`
-
- // RuntimeSupportsJSON is the list of the OCI runtimes that support
- // --format=json.
- RuntimeSupportsJSON []string `toml:"runtime_supports_json,omitempty"`
-
- // RuntimeSupportsNoCgroups is a list of OCI runtimes that support
- // running containers without CGroups.
- RuntimeSupportsNoCgroups []string `toml:"runtime_supports_nocgroupv2,omitempty"`
-
- // RuntimePath is the path to OCI runtime binary for launching containers.
- // The first path pointing to a valid file will be used This is used only
- // when there are no OCIRuntime/OCIRuntimes defined. It is used only to be
- // backward compatible with older versions of Podman.
- RuntimePath []string `toml:"runtime_path,omitempty"`
-
- // ConmonPath is the path to the Conmon binary used for managing containers.
- // The first path pointing to a valid file will be used.
- ConmonPath []string `toml:"conmon_path,omitempty"`
-
- // ConmonEnvVars are environment variables to pass to the Conmon binary
- // when it is launched.
- ConmonEnvVars []string `toml:"conmon_env_vars,omitempty"`
-
- // CGroupManager is the CGroup Manager to use Valid values are "cgroupfs"
- // and "systemd".
- CgroupManager string `toml:"cgroup_manager,omitempty"`
-
- // InitPath is the path to the container-init binary.
- InitPath string `toml:"init_path,omitempty"`
-
- // StaticDir is the path to a persistent directory to store container
- // files.
- StaticDir string `toml:"static_dir,omitempty"`
-
- // TmpDir is the path to a temporary directory to store per-boot container
- // files. Must be stored in a tmpfs.
- TmpDir string `toml:"tmp_dir,omitempty"`
-
- // MaxLogSize is the maximum size of container logfiles.
- MaxLogSize int64 `toml:"max_log_size,omitempty"`
-
- // NoPivotRoot sets whether to set no-pivot-root in the OCI runtime.
- NoPivotRoot bool `toml:"no_pivot_root,omitempty"`
-
- // CNIConfigDir sets the directory where CNI configuration files are
- // stored.
- CNIConfigDir string `toml:"cni_config_dir,omitempty"`
-
- // CNIPluginDir sets a number of directories where the CNI network
- // plugins can be located.
- CNIPluginDir []string `toml:"cni_plugin_dir,omitempty"`
-
- // CNIDefaultNetwork is the network name of the default CNI network
- // to attach pods to.
- CNIDefaultNetwork string `toml:"cni_default_network,omitempty"`
-
- // HooksDir holds paths to the directories containing hooks
- // configuration files. When the same filename is present in in
- // multiple directories, the file in the directory listed last in
- // this slice takes precedence.
- HooksDir []string `toml:"hooks_dir,omitempty"`
-
- // Namespace is the libpod namespace to use. Namespaces are used to create
- // scopes to separate containers and pods in the state. When namespace is
- // set, libpod will only view containers and pods in the same namespace. All
- // containers and pods created will default to the namespace set here. A
- // namespace of "", the empty string, is equivalent to no namespace, and all
- // containers and pods will be visible. The default namespace is "".
- Namespace string `toml:"namespace,omitempty"`
-
- // InfraImage is the image a pod infra container will use to manage
- // namespaces.
- InfraImage string `toml:"infra_image,omitempty"`
-
- // InfraCommand is the command run to start up a pod infra container.
- InfraCommand string `toml:"infra_command,omitempty"`
-
- // EnablePortReservation determines whether libpod will reserve ports on the
- // host when they are forwarded to containers. When enabled, when ports are
- // forwarded to containers, they are held open by conmon as long as the
- // container is running, ensuring that they cannot be reused by other
- // programs on the host. However, this can cause significant memory usage if
- // a container has many ports forwarded to it. Disabling this can save
- // memory.
- EnablePortReservation bool `toml:"enable_port_reservation,omitempty"`
-
- // EnableLabeling indicates whether libpod will support container labeling.
- EnableLabeling bool `toml:"label,omitempty"`
-
- // NetworkCmdPath is the path to the slirp4netns binary.
- NetworkCmdPath string `toml:"network_cmd_path,omitempty"`
-
- // NumLocks is the number of locks to make available for containers and
- // pods.
- NumLocks uint32 `toml:"num_locks,omitempty"`
-
- // LockType is the type of locking to use.
- LockType string `toml:"lock_type,omitempty"`
-
- // EventsLogger determines where events should be logged.
- EventsLogger string `toml:"events_logger,omitempty"`
-
- // EventsLogFilePath is where the events log is stored.
- EventsLogFilePath string `toml:"events_logfile_path,omitempty"`
-
- // DetachKeys is the sequence of keys used to detach a container.
- DetachKeys string `toml:"detach_keys,omitempty"`
-
- // SDNotify tells Libpod to allow containers to notify the host systemd of
- // readiness using the SD_NOTIFY mechanism.
- SDNotify bool `toml:",omitempty"`
-
- // CgroupCheck indicates the configuration has been rewritten after an
- // upgrade to Fedora 31 to change the default OCI runtime for cgroupv2v2.
- CgroupCheck bool `toml:"cgroup_check,omitempty"`
-}
-
-// newLibpodConfig creates a new ConfigFromLibpod and converts it to Config.
-// Depending if we're running as root or rootless, we then merge the system configuration followed
-// by merging the default config (hard-coded default in memory).
-// Note that the OCI runtime is hard-set to `crun` if we're running on a system
-// with cgroupv2v2. Other OCI runtimes are not yet supporting cgroupv2v2. This
-// might change in the future.
-func newLibpodConfig(c *Config) error {
- // Start with the default config and iteratively merge
- // fields in the system configs.
- config := c.libpodConfig()
-
- // Now, check if the user can access system configs and merge them if needed.
- configs, err := systemLibpodConfigs()
- if err != nil {
- return errors.Wrapf(err, "error finding config on system")
- }
-
- if len(configs) == 0 {
- return nil
- }
-
- for _, path := range configs {
- config, err = readLibpodConfigFromFile(path, config)
- if err != nil {
- return errors.Wrapf(err, "error reading system config %q", path)
- }
- }
-
- // Since runc does not currently support cgroupV2
- // Change to default crun on first running of libpod.conf
- // TODO Once runc has support for cgroupv2, this function should be removed.
- if !config.CgroupCheck && unshare.IsRootless() {
- cgroup2, err := cgroupv2.Enabled()
- if err != nil {
- return err
- }
- if cgroup2 {
- path, err := exec.LookPath("crun")
- if err != nil {
- // Can't find crun path so do nothing
- logrus.Warnf("Can not find crun package on the host, containers might fail to run on cgroup V2 systems without crun: %q", err)
- } else {
- config.CgroupCheck = true
- config.OCIRuntime = path
- }
- }
- }
-
- // hard code EventsLogger to "file" to match older podman versions.
- if config.EventsLogger != "file" {
- logrus.Warnf("Ignoring libpod.conf EventsLogger setting %q. Use %q if you want to change this setting and remove libpod.conf files.", config.EventsLogger, Path())
- config.EventsLogger = "file"
- }
-
- c.libpodToContainersConfig(config)
-
- return nil
-}
-
-// readConfigFromFile reads the specified config file at `path` and attempts to
-// unmarshal its content into a Config. The config param specifies the previous
-// default config. If the path, only specifies a few fields in the Toml file
-// the defaults from the config parameter will be used for all other fields.
-func readLibpodConfigFromFile(path string, config *ConfigFromLibpod) (*ConfigFromLibpod, error) {
- logrus.Debugf("Reading configuration file %q", path)
- _, err := toml.DecodeFile(path, config)
- if err != nil {
- return nil, errors.Wrapf(err, "decode configuration %s", path)
- }
-
- return config, err
-}
-
-func systemLibpodConfigs() ([]string, error) {
- if unshare.IsRootless() {
- path, err := rootlessLibpodConfigPath()
- if err != nil {
- return nil, err
- }
- if _, err := os.Stat(path); err == nil {
- containersConfPath, err := rootlessConfigPath()
- if err != nil {
- containersConfPath = filepath.Join("$HOME", UserOverrideContainersConfig)
- }
- logrus.Warnf("Found deprecated file %s, please remove. Use %s to override defaults.\n", path, containersConfPath)
- return []string{path}, nil
- }
- return nil, err
- }
-
- configs := []string{}
- if _, err := os.Stat(_rootConfigPath); err == nil {
- logrus.Warnf("Found deprecated file %s, please remove. Use %s to override defaults.\n", _rootConfigPath, OverrideContainersConfig)
- configs = append(configs, _rootConfigPath)
- }
- if _, err := os.Stat(_rootOverrideConfigPath); err == nil {
- logrus.Warnf("Found deprecated file %s, please remove. Use %s to override defaults.\n", _rootOverrideConfigPath, OverrideContainersConfig)
- configs = append(configs, _rootOverrideConfigPath)
- }
- return configs, nil
-}
-
-func rootlessLibpodConfigPath() (string, error) {
- home, err := unshare.HomeDir()
- if err != nil {
- return "", err
- }
-
- return filepath.Join(home, _rootlessConfigPath), nil
-}
-
-func (c *Config) libpodConfig() *ConfigFromLibpod {
- return &ConfigFromLibpod{
- InitPath: c.Containers.InitPath,
- MaxLogSize: c.Containers.LogSizeMax,
- EnableLabeling: c.Containers.EnableLabeling,
-
- SetOptions: c.Engine.SetOptions,
- VolumePath: c.Engine.VolumePath,
- ImageDefaultTransport: c.Engine.ImageDefaultTransport,
- OCIRuntime: c.Engine.OCIRuntime,
- OCIRuntimes: c.Engine.OCIRuntimes,
- RuntimeSupportsJSON: c.Engine.RuntimeSupportsJSON,
- RuntimeSupportsNoCgroups: c.Engine.RuntimeSupportsNoCgroups,
- RuntimePath: c.Engine.RuntimePath,
- ConmonPath: c.Engine.ConmonPath,
- ConmonEnvVars: c.Engine.ConmonEnvVars,
- CgroupManager: c.Engine.CgroupManager,
- StaticDir: c.Engine.StaticDir,
- TmpDir: c.Engine.TmpDir,
- NoPivotRoot: c.Engine.NoPivotRoot,
- HooksDir: c.Engine.HooksDir,
- Namespace: c.Engine.Namespace,
- InfraImage: c.Engine.InfraImage,
- InfraCommand: c.Engine.InfraCommand,
- EnablePortReservation: c.Engine.EnablePortReservation,
- NetworkCmdPath: c.Engine.NetworkCmdPath,
- NumLocks: c.Engine.NumLocks,
- LockType: c.Engine.LockType,
- EventsLogger: c.Engine.EventsLogger,
- EventsLogFilePath: c.Engine.EventsLogFilePath,
- DetachKeys: c.Engine.DetachKeys,
- SDNotify: c.Engine.SDNotify,
- CgroupCheck: c.Engine.CgroupCheck,
- SignaturePolicyPath: c.Engine.SignaturePolicyPath,
-
- CNIConfigDir: c.Network.NetworkConfigDir,
- CNIPluginDir: c.Network.CNIPluginDirs,
- CNIDefaultNetwork: c.Network.DefaultNetwork,
- }
-}
-
-func (c *Config) libpodToContainersConfig(libpodConf *ConfigFromLibpod) {
-
- if libpodConf.InitPath != "" {
- c.Containers.InitPath = libpodConf.InitPath
- }
- c.Containers.LogSizeMax = libpodConf.MaxLogSize
- c.Containers.EnableLabeling = libpodConf.EnableLabeling
-
- if libpodConf.SignaturePolicyPath != "" {
- c.Engine.SignaturePolicyPath = libpodConf.SignaturePolicyPath
- }
- c.Engine.SetOptions = libpodConf.SetOptions
- if libpodConf.VolumePath != "" {
- c.Engine.VolumePath = libpodConf.VolumePath
- }
- if libpodConf.ImageDefaultTransport != "" {
- c.Engine.ImageDefaultTransport = libpodConf.ImageDefaultTransport
- }
- if libpodConf.OCIRuntime != "" {
- c.Engine.OCIRuntime = libpodConf.OCIRuntime
- }
- c.Engine.OCIRuntimes = libpodConf.OCIRuntimes
- c.Engine.RuntimeSupportsJSON = libpodConf.RuntimeSupportsJSON
- c.Engine.RuntimeSupportsNoCgroups = libpodConf.RuntimeSupportsNoCgroups
- c.Engine.RuntimePath = libpodConf.RuntimePath
- c.Engine.ConmonPath = libpodConf.ConmonPath
- c.Engine.ConmonEnvVars = libpodConf.ConmonEnvVars
- if libpodConf.CgroupManager != "" {
- c.Engine.CgroupManager = libpodConf.CgroupManager
- }
- if libpodConf.StaticDir != "" {
- c.Engine.StaticDir = libpodConf.StaticDir
- }
- if libpodConf.TmpDir != "" {
- c.Engine.TmpDir = libpodConf.TmpDir
- }
- c.Engine.NoPivotRoot = libpodConf.NoPivotRoot
- c.Engine.HooksDir = libpodConf.HooksDir
- if libpodConf.Namespace != "" {
- c.Engine.Namespace = libpodConf.Namespace
- }
- if libpodConf.InfraImage != "" {
- c.Engine.InfraImage = libpodConf.InfraImage
- }
- if libpodConf.InfraCommand != "" {
- c.Engine.InfraCommand = libpodConf.InfraCommand
- }
-
- c.Engine.EnablePortReservation = libpodConf.EnablePortReservation
- if libpodConf.NetworkCmdPath != "" {
- c.Engine.NetworkCmdPath = libpodConf.NetworkCmdPath
- }
- c.Engine.NumLocks = libpodConf.NumLocks
- c.Engine.LockType = libpodConf.LockType
- if libpodConf.EventsLogger != "" {
- c.Engine.EventsLogger = libpodConf.EventsLogger
- }
- if libpodConf.EventsLogFilePath != "" {
- c.Engine.EventsLogFilePath = libpodConf.EventsLogFilePath
- }
- if libpodConf.DetachKeys != "" {
- c.Engine.DetachKeys = libpodConf.DetachKeys
- }
- c.Engine.SDNotify = libpodConf.SDNotify
- c.Engine.CgroupCheck = libpodConf.CgroupCheck
-
- if libpodConf.CNIConfigDir != "" {
- c.Network.NetworkConfigDir = libpodConf.CNIConfigDir
- }
- c.Network.CNIPluginDirs = libpodConf.CNIPluginDir
- if libpodConf.CNIDefaultNetwork != "" {
- c.Network.DefaultNetwork = libpodConf.CNIDefaultNetwork
- }
-}
diff --git a/vendor/github.com/containers/common/version/version.go b/vendor/github.com/containers/common/version/version.go
index 141168961..8df453484 100644
--- a/vendor/github.com/containers/common/version/version.go
+++ b/vendor/github.com/containers/common/version/version.go
@@ -1,4 +1,4 @@
package version
// Version is the version of the build.
-const Version = "0.30.0"
+const Version = "0.31.0"
diff --git a/vendor/github.com/containers/image/v5/copy/copy.go b/vendor/github.com/containers/image/v5/copy/copy.go
index 4d5b07689..485db4d30 100644
--- a/vendor/github.com/containers/image/v5/copy/copy.go
+++ b/vendor/github.com/containers/image/v5/copy/copy.go
@@ -53,6 +53,14 @@ var (
// compressionBufferSize is the buffer size used to compress a blob
var compressionBufferSize = 1048576
+// expectedCompressionFormats is used to check if a blob with a specified media type is compressed
+// using the algorithm that the media type says it should be compressed with
+var expectedCompressionFormats = map[string]*compression.Algorithm{
+ imgspecv1.MediaTypeImageLayerGzip: &compression.Gzip,
+ imgspecv1.MediaTypeImageLayerZstd: &compression.Zstd,
+ manifest.DockerV2Schema2LayerMediaType: &compression.Gzip,
+}
+
// newDigestingReader returns an io.Reader implementation with contents of source, which will eventually return a non-EOF error
// or set validationSucceeded/validationFailed to true if the source stream does/does not match expectedDigest.
// (neither is set if EOF is never reached).
@@ -1234,6 +1242,10 @@ func (c *copier) copyBlobFromStream(ctx context.Context, srcStream io.Reader, sr
isCompressed := decompressor != nil
destStream = bar.ProxyReader(destStream)
+ if expectedCompressionFormat, known := expectedCompressionFormats[srcInfo.MediaType]; known && isCompressed && compressionFormat.Name() != expectedCompressionFormat.Name() {
+ logrus.Debugf("blob %s with type %s should be compressed with %s, but compressor appears to be %s", srcInfo.Digest.String(), srcInfo.MediaType, expectedCompressionFormat.Name(), compressionFormat.Name())
+ }
+
// === Send a copy of the original, uncompressed, stream, to a separate path if necessary.
var originalLayerReader io.Reader // DO NOT USE this other than to drain the input if no other consumer in the pipeline has done so.
if getOriginalLayerCopyWriter != nil {
diff --git a/vendor/github.com/containers/image/v5/pkg/compression/compression.go b/vendor/github.com/containers/image/v5/pkg/compression/compression.go
index 04d231c6d..d5cfd8d31 100644
--- a/vendor/github.com/containers/image/v5/pkg/compression/compression.go
+++ b/vendor/github.com/containers/image/v5/pkg/compression/compression.go
@@ -91,7 +91,8 @@ func CompressStream(dest io.Writer, algo Algorithm, level *int) (io.WriteCloser,
return internal.AlgorithmCompressor(algo)(dest, level)
}
-// DetectCompressionFormat returns a DecompressorFunc if the input is recognized as a compressed format, nil otherwise.
+// DetectCompressionFormat returns an Algorithm and DecompressorFunc if the input is recognized as a compressed format, an invalid
+// value and nil otherwise.
// Because it consumes the start of input, other consumers must use the returned io.Reader instead to also read from the beginning.
func DetectCompressionFormat(input io.Reader) (Algorithm, DecompressorFunc, io.Reader, error) {
buffer := [8]byte{}
diff --git a/vendor/github.com/containers/image/v5/pkg/shortnames/shortnames.go b/vendor/github.com/containers/image/v5/pkg/shortnames/shortnames.go
index e02703d77..198ac1cc6 100644
--- a/vendor/github.com/containers/image/v5/pkg/shortnames/shortnames.go
+++ b/vendor/github.com/containers/image/v5/pkg/shortnames/shortnames.go
@@ -225,9 +225,8 @@ func (c *PullCandidate) Record() error {
// Note that tags and digests are stripped from the specified name before
// looking up an alias. Stripped off tags and digests are later on appended to
// all candidates. If neither tag nor digest is specified, candidates are
-// normalized with the "latest" tag. PullCandidates in the returned value may
-// be empty if there is no matching alias and no unqualified-search registries
-// are configured.
+// normalized with the "latest" tag. An error is returned if there is no
+// matching alias and no unqualified-search registries are configured.
//
// Note that callers *must* call `(PullCandidate).Record` after a returned
// item has been pulled successfully; this callback will record a new
@@ -312,6 +311,10 @@ func Resolve(ctx *types.SystemContext, name string) (*Resolved, error) {
if err != nil {
return nil, err
}
+ // Error out if there's no matching alias and no search registries.
+ if len(unqualifiedSearchRegistries) == 0 {
+ return nil, errors.Errorf("short-name %q did not resolve to an alias and no unqualified-search registries are defined in %q", name, usrConfig)
+ }
resolved.originDescription = usrConfig
for _, reg := range unqualifiedSearchRegistries {
@@ -331,10 +334,8 @@ func Resolve(ctx *types.SystemContext, name string) (*Resolved, error) {
return resolved, nil
}
- // If we have only one candidate, there's no ambiguity. In case of an
- // empty candidate slices, callers can implement custom logic or raise
- // an error.
- if len(resolved.PullCandidates) <= 1 {
+ // If we have only one candidate, there's no ambiguity.
+ if len(resolved.PullCandidates) == 1 {
return resolved, nil
}
diff --git a/vendor/github.com/containers/image/v5/signature/policy_config.go b/vendor/github.com/containers/image/v5/signature/policy_config.go
index a4873e9fa..d8cc4a09b 100644
--- a/vendor/github.com/containers/image/v5/signature/policy_config.go
+++ b/vendor/github.com/containers/image/v5/signature/policy_config.go
@@ -19,6 +19,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "regexp"
"github.com/containers/image/v5/docker/reference"
"github.com/containers/image/v5/transports"
@@ -507,6 +508,8 @@ func newPolicyReferenceMatchFromJSON(data []byte) (PolicyReferenceMatch, error)
res = &prmExactReference{}
case prmTypeExactRepository:
res = &prmExactRepository{}
+ case prmTypeRemapIdentity:
+ res = &prmRemapIdentity{}
default:
return nil, InvalidPolicyFormatError(fmt.Sprintf("Unknown policy reference match type \"%s\"", typeField.Type))
}
@@ -693,3 +696,76 @@ func (prm *prmExactRepository) UnmarshalJSON(data []byte) error {
*prm = *res
return nil
}
+
+// Private objects for validateIdentityRemappingPrefix
+var (
+ // remapIdentityDomainRegexp matches exactly a reference domain (name[:port])
+ remapIdentityDomainRegexp = regexp.MustCompile("^" + reference.DomainRegexp.String() + "$")
+ // remapIdentityDomainPrefixRegexp matches a reference that starts with a domain;
+ // we need this because reference.NameRegexp accepts short names with docker.io implied.
+ remapIdentityDomainPrefixRegexp = regexp.MustCompile("^" + reference.DomainRegexp.String() + "/")
+ // remapIdentityNameRegexp matches exactly a reference.Named name (possibly unnormalized)
+ remapIdentityNameRegexp = regexp.MustCompile("^" + reference.NameRegexp.String() + "$")
+)
+
+// validateIdentityRemappingPrefix returns an InvalidPolicyFormatError if s is detected to be invalid
+// for the Prefix or SignedPrefix values of prmRemapIdentity.
+// Note that it may not recognize _all_ invalid values.
+func validateIdentityRemappingPrefix(s string) error {
+ if remapIdentityDomainRegexp.MatchString(s) ||
+ (remapIdentityNameRegexp.MatchString(s) && remapIdentityDomainPrefixRegexp.MatchString(s)) {
+ // FIXME? This does not reject "shortname" nor "ns/shortname", because docker/reference
+ // does not provide an API for the short vs. long name logic.
+ // It will either not match, or fail in the ParseNamed call of
+ // prmRemapIdentity.remapReferencePrefix when trying to use such a prefix.
+ return nil
+ }
+ return InvalidPolicyFormatError(fmt.Sprintf("prefix %q is not valid", s))
+}
+
+// newPRMRemapIdentity is NewPRMRemapIdentity, except it returns the private type.
+func newPRMRemapIdentity(prefix, signedPrefix string) (*prmRemapIdentity, error) {
+ if err := validateIdentityRemappingPrefix(prefix); err != nil {
+ return nil, err
+ }
+ if err := validateIdentityRemappingPrefix(signedPrefix); err != nil {
+ return nil, err
+ }
+ return &prmRemapIdentity{
+ prmCommon: prmCommon{Type: prmTypeRemapIdentity},
+ Prefix: prefix,
+ SignedPrefix: signedPrefix,
+ }, nil
+}
+
+// NewPRMRemapIdentity returns a new "remapIdentity" PolicyRepositoryMatch.
+func NewPRMRemapIdentity(prefix, signedPrefix string) (PolicyReferenceMatch, error) {
+ return newPRMRemapIdentity(prefix, signedPrefix)
+}
+
+// Compile-time check that prmRemapIdentity implements json.Unmarshaler.
+var _ json.Unmarshaler = (*prmRemapIdentity)(nil)
+
+// UnmarshalJSON implements the json.Unmarshaler interface.
+func (prm *prmRemapIdentity) UnmarshalJSON(data []byte) error {
+ *prm = prmRemapIdentity{}
+ var tmp prmRemapIdentity
+ if err := paranoidUnmarshalJSONObjectExactFields(data, map[string]interface{}{
+ "type": &tmp.Type,
+ "prefix": &tmp.Prefix,
+ "signedPrefix": &tmp.SignedPrefix,
+ }); err != nil {
+ return err
+ }
+
+ if tmp.Type != prmTypeRemapIdentity {
+ return InvalidPolicyFormatError(fmt.Sprintf("Unexpected policy requirement type \"%s\"", tmp.Type))
+ }
+
+ res, err := newPRMRemapIdentity(tmp.Prefix, tmp.SignedPrefix)
+ if err != nil {
+ return err
+ }
+ *prm = *res
+ return nil
+}
diff --git a/vendor/github.com/containers/image/v5/signature/policy_reference_match.go b/vendor/github.com/containers/image/v5/signature/policy_reference_match.go
index e2a21f01d..064866cf6 100644
--- a/vendor/github.com/containers/image/v5/signature/policy_reference_match.go
+++ b/vendor/github.com/containers/image/v5/signature/policy_reference_match.go
@@ -4,6 +4,7 @@ package signature
import (
"fmt"
+ "strings"
"github.com/containers/image/v5/docker/reference"
"github.com/containers/image/v5/transports"
@@ -36,12 +37,9 @@ func (prm *prmMatchExact) matchesDockerReference(image types.UnparsedImage, sign
return signature.String() == intended.String()
}
-func (prm *prmMatchRepoDigestOrExact) matchesDockerReference(image types.UnparsedImage, signatureDockerReference string) bool {
- intended, signature, err := parseImageAndDockerReference(image, signatureDockerReference)
- if err != nil {
- return false
- }
-
+// matchRepoDigestOrExactReferenceValues implements prmMatchRepoDigestOrExact.matchesDockerReference
+// using reference.Named values.
+func matchRepoDigestOrExactReferenceValues(intended, signature reference.Named) bool {
// Do not add default tags: image.Reference().DockerReference() should contain it already, and signatureDockerReference should be exact; so, verify that now.
if reference.IsNameOnly(signature) {
return false
@@ -58,6 +56,13 @@ func (prm *prmMatchRepoDigestOrExact) matchesDockerReference(image types.Unparse
return false
}
}
+func (prm *prmMatchRepoDigestOrExact) matchesDockerReference(image types.UnparsedImage, signatureDockerReference string) bool {
+ intended, signature, err := parseImageAndDockerReference(image, signatureDockerReference)
+ if err != nil {
+ return false
+ }
+ return matchRepoDigestOrExactReferenceValues(intended, signature)
+}
func (prm *prmMatchRepository) matchesDockerReference(image types.UnparsedImage, signatureDockerReference string) bool {
intended, signature, err := parseImageAndDockerReference(image, signatureDockerReference)
@@ -99,3 +104,51 @@ func (prm *prmExactRepository) matchesDockerReference(image types.UnparsedImage,
}
return signature.Name() == intended.Name()
}
+
+// refMatchesPrefix returns true if ref matches prm.Prefix.
+func (prm *prmRemapIdentity) refMatchesPrefix(ref reference.Named) bool {
+ name := ref.Name()
+ switch {
+ case len(name) < len(prm.Prefix):
+ return false
+ case len(name) == len(prm.Prefix):
+ return name == prm.Prefix
+ case len(name) > len(prm.Prefix):
+ // We are matching only ref.Name(), not ref.String(), so the only separator we are
+ // expecting is '/':
+ // - '@' is only valid to separate a digest, i.e. not a part of ref.Name()
+ // - similarly ':' to mark a tag would not be a part of ref.Name(); it can be a part of a
+ // host:port domain syntax, but we don't treat that specially and require an exact match
+ // of the domain.
+ return strings.HasPrefix(name, prm.Prefix) && name[len(prm.Prefix)] == '/'
+ default:
+ panic("Internal error: impossible comparison outcome")
+ }
+}
+
+// remapReferencePrefix returns the result of remapping ref, if it matches prm.Prefix
+// or the original ref if it does not.
+func (prm *prmRemapIdentity) remapReferencePrefix(ref reference.Named) (reference.Named, error) {
+ if !prm.refMatchesPrefix(ref) {
+ return ref, nil
+ }
+ refString := ref.String()
+ newNamedRef := strings.Replace(refString, prm.Prefix, prm.SignedPrefix, 1)
+ newParsedRef, err := reference.ParseNamed(newNamedRef)
+ if err != nil {
+ return nil, fmt.Errorf(`error rewriting reference from "%s" to "%s": %v`, refString, newNamedRef, err)
+ }
+ return newParsedRef, nil
+}
+
+func (prm *prmRemapIdentity) matchesDockerReference(image types.UnparsedImage, signatureDockerReference string) bool {
+ intended, signature, err := parseImageAndDockerReference(image, signatureDockerReference)
+ if err != nil {
+ return false
+ }
+ intended, err = prm.remapReferencePrefix(intended)
+ if err != nil {
+ return false
+ }
+ return matchRepoDigestOrExactReferenceValues(intended, signature)
+}
diff --git a/vendor/github.com/containers/image/v5/signature/policy_types.go b/vendor/github.com/containers/image/v5/signature/policy_types.go
index d3b33bb7a..c6819929b 100644
--- a/vendor/github.com/containers/image/v5/signature/policy_types.go
+++ b/vendor/github.com/containers/image/v5/signature/policy_types.go
@@ -121,6 +121,7 @@ const (
prmTypeMatchRepository prmTypeIdentifier = "matchRepository"
prmTypeExactReference prmTypeIdentifier = "exactReference"
prmTypeExactRepository prmTypeIdentifier = "exactRepository"
+ prmTypeRemapIdentity prmTypeIdentifier = "remapIdentity"
)
// prmMatchExact is a PolicyReferenceMatch with type = prmMatchExact: the two references must match exactly.
@@ -150,3 +151,13 @@ type prmExactRepository struct {
prmCommon
DockerRepository string `json:"dockerRepository"`
}
+
+// prmRemapIdentity is a PolicyReferenceMatch with type = prmRemapIdentity: like prmMatchRepoDigestOrExact,
+// except that a namespace (at least a host:port, at most a single repository) is substituted before matching the two references.
+type prmRemapIdentity struct {
+ prmCommon
+ Prefix string `json:"prefix"`
+ SignedPrefix string `json:"signedPrefix"`
+ // Possibly let the users make a choice for tag/digest matching behavior
+ // similar to prmMatchExact/prmMatchRepository?
+}
diff --git a/vendor/github.com/containers/image/v5/version/version.go b/vendor/github.com/containers/image/v5/version/version.go
index 14e553c9f..48ecf938c 100644
--- a/vendor/github.com/containers/image/v5/version/version.go
+++ b/vendor/github.com/containers/image/v5/version/version.go
@@ -6,9 +6,9 @@ const (
// VersionMajor is for an API incompatible changes
VersionMajor = 5
// VersionMinor is for functionality in a backwards-compatible manner
- VersionMinor = 8
+ VersionMinor = 9
// VersionPatch is for backwards-compatible bug fixes
- VersionPatch = 1
+ VersionPatch = 0
// VersionDev indicates development branch. Releases will be empty string.
VersionDev = ""
diff --git a/vendor/github.com/golang/protobuf/proto/text_decode.go b/vendor/github.com/golang/protobuf/proto/text_decode.go
index 4a5931009..47eb3e445 100644
--- a/vendor/github.com/golang/protobuf/proto/text_decode.go
+++ b/vendor/github.com/golang/protobuf/proto/text_decode.go
@@ -765,7 +765,7 @@ func unescape(s string) (ch string, tail string, err error) {
if i > utf8.MaxRune {
return "", "", fmt.Errorf(`\%c%s is not a valid Unicode code point`, r, ss)
}
- return string(i), s, nil
+ return string(rune(i)), s, nil
}
return "", "", fmt.Errorf(`unknown escape \%c`, r)
}