aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-08-25 07:33:44 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-08-28 09:36:11 -0400
commit3c6603a2f88ab5ba38bf58334417aaa90c458c06 (patch)
treecc31266b9fadabd34b9bbe56ea5abc002f83fdee
parentf49b98c61019ac04dccd6b3d5bc0c6af7857b17e (diff)
downloadpodman-3c6603a2f88ab5ba38bf58334417aaa90c458c06.tar.gz
podman-3c6603a2f88ab5ba38bf58334417aaa90c458c06.tar.bz2
podman-3c6603a2f88ab5ba38bf58334417aaa90c458c06.zip
Add support for variant when pulling images
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
-rw-r--r--cmd/podman/common/create.go5
-rw-r--r--cmd/podman/common/create_opts.go1
-rw-r--r--cmd/podman/containers/create.go9
-rw-r--r--cmd/podman/containers/run.go1
-rw-r--r--cmd/podman/images/pull.go1
-rw-r--r--completions/bash/podman2
-rw-r--r--docs/source/markdown/podman-create.1.md7
-rw-r--r--docs/source/markdown/podman-pull.1.md8
-rw-r--r--docs/source/markdown/podman-run.1.md7
-rw-r--r--libpod/image/docker_registry_options.go3
-rw-r--r--libpod/image/pull.go2
-rw-r--r--pkg/api/handlers/libpod/images.go12
-rw-r--r--pkg/api/server/register_images.go8
-rw-r--r--pkg/bindings/images/images.go1
-rw-r--r--pkg/domain/entities/images.go2
-rw-r--r--pkg/domain/infra/abi/images.go1
16 files changed, 52 insertions, 18 deletions
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go
index df218a026..2b6f9348e 100644
--- a/cmd/podman/common/create.go
+++ b/cmd/podman/common/create.go
@@ -328,6 +328,11 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
"override-os", "",
"use `OS` instead of the running OS for choosing images",
)
+ createFlags.StringVar(
+ &cf.OverrideVariant,
+ "override-variant", "",
+ "Use _VARIANT_ instead of the running architecture variant for choosing images",
+ )
createFlags.String(
"pid", "",
"PID namespace to use",
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index 16d41988f..1b0e64590 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -65,6 +65,7 @@ type ContainerCLIOpts struct {
OOMScoreAdj int
OverrideArch string
OverrideOS string
+ OverrideVariant string
PID string
PIDsLimit *int64
Pod string
diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go
index e29c94352..5e48aa622 100644
--- a/cmd/podman/containers/create.go
+++ b/cmd/podman/containers/create.go
@@ -251,10 +251,11 @@ func pullImage(imageName string) (string, error) {
return "", errors.Wrapf(define.ErrNoSuchImage, "unable to find a name and tag match for %s in repotags", imageName)
}
pullReport, pullErr := registry.ImageEngine().Pull(registry.GetContext(), imageName, entities.ImagePullOptions{
- Authfile: cliVals.Authfile,
- Quiet: cliVals.Quiet,
- OverrideArch: cliVals.OverrideArch,
- OverrideOS: cliVals.OverrideOS,
+ Authfile: cliVals.Authfile,
+ Quiet: cliVals.Quiet,
+ OverrideArch: cliVals.OverrideArch,
+ OverrideOS: cliVals.OverrideOS,
+ OverrideVariant: cliVals.OverrideVariant,
})
if pullErr != nil {
return "", pullErr
diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go
index c60095b64..34eea14e1 100644
--- a/cmd/podman/containers/run.go
+++ b/cmd/podman/containers/run.go
@@ -71,7 +71,6 @@ func runFlags(flags *pflag.FlagSet) {
_ = flags.MarkHidden("preserve-fds")
}
}
-
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
diff --git a/cmd/podman/images/pull.go b/cmd/podman/images/pull.go
index 4deaecbf5..d86f9800c 100644
--- a/cmd/podman/images/pull.go
+++ b/cmd/podman/images/pull.go
@@ -82,6 +82,7 @@ func pullFlags(flags *pflag.FlagSet) {
flags.StringVar(&pullOptions.CredentialsCLI, "creds", "", "`Credentials` (USERNAME:PASSWORD) to use for authenticating to a registry")
flags.StringVar(&pullOptions.OverrideArch, "override-arch", "", "Use `ARCH` instead of the architecture of the machine for choosing images")
flags.StringVar(&pullOptions.OverrideOS, "override-os", "", "Use `OS` instead of the running OS for choosing images")
+ flags.StringVar(&pullOptions.OverrideVariant, "override-variant", "", " use VARIANT instead of the running architecture variant for choosing images")
flags.Bool("disable-content-trust", false, "This is a Docker specific option and is a NOOP")
flags.BoolVarP(&pullOptions.Quiet, "quiet", "q", false, "Suppress output information when pulling images")
flags.StringVar(&pullOptions.SignaturePolicy, "signature-policy", "", "`Pathname` of signature policy file (not usually used)")
diff --git a/completions/bash/podman b/completions/bash/podman
index 6492da2b3..3b50af1a9 100644
--- a/completions/bash/podman
+++ b/completions/bash/podman
@@ -1984,6 +1984,7 @@ _podman_pull() {
--creds
--override-arch
--override-os
+ --override-variant
"
local boolean_options="
--all-tags
@@ -2165,6 +2166,7 @@ _podman_container_run() {
--oom-score-adj
--override-arch
--override-os
+ --override-variant
--pid
--pids-limit
--pod
diff --git a/docs/source/markdown/podman-create.1.md b/docs/source/markdown/podman-create.1.md
index bc195aa39..9049ffb9f 100644
--- a/docs/source/markdown/podman-create.1.md
+++ b/docs/source/markdown/podman-create.1.md
@@ -600,10 +600,13 @@ Whether to disable OOM Killer for the container or not.
Tune the host's OOM preferences for containers (accepts -1000 to 1000)
**--override-arch**=*ARCH*
-Override the machine's default architecture of the image to be pulled. For example, `arm`.
+Override the architecture, defaults to hosts, of the image to be pulled. For example, `arm`.
**--override-os**=*OS*
-Use OS instead of the running OS for choosing images
+Override the OS, defaults to hosts, of the image to be pulled. For example, `windows`.
+
+**--override-variant**=*VARIANT*
+Use _VARIANT_ instead of the default architecture variant of the container image. Some images can use multiple variants of the arm architectures, such as arm/v5 and arm/v7.
**--pid**=*pid*
diff --git a/docs/source/markdown/podman-pull.1.md b/docs/source/markdown/podman-pull.1.md
index f209209a9..c75cb18b4 100644
--- a/docs/source/markdown/podman-pull.1.md
+++ b/docs/source/markdown/podman-pull.1.md
@@ -80,10 +80,14 @@ registry and is not supported by Podman. This flag is a NOOP and provided
solely for scripting compatibility.
**--override-arch**=*ARCH*
-Override the machine's default architecture of the image to be pulled. For example, `arm`.
+Override the architecture, defaults to hosts, of the image to be pulled. For example, `arm`.
**--override-os**=*OS*
-Use OS instead of the running OS for choosing images
+Override the OS, defaults to hosts, of the image to be pulled. For example, `windows`.
+
+**--override-variant**=*VARIANT*
+
+Use _VARIANT_ instead of the default architecture variant of the container image. Some images can use multiple variants of the arm architectures, such as arm/v5 and arm/v7.
**--quiet**, **-q**
diff --git a/docs/source/markdown/podman-run.1.md b/docs/source/markdown/podman-run.1.md
index b0afcecfa..1a7b36a5e 100644
--- a/docs/source/markdown/podman-run.1.md
+++ b/docs/source/markdown/podman-run.1.md
@@ -609,10 +609,13 @@ Whether to disable OOM Killer for the container or not.
Tune the host's OOM preferences for containers (accepts values from **-1000** to **1000**).
**--override-arch**=*ARCH*
-Override the machine's default architecture of the image to be pulled. For example, `arm`.
+Override the architecture, defaults to hosts, of the image to be pulled. For example, `arm`.
**--override-os**=*OS*
-Use OS instead of the running OS for choosing images
+Override the OS, defaults to hosts, of the image to be pulled. For example, `windows`.
+
+**--override-variant**=*VARIANT*
+Use _VARIANT_ instead of the default architecture variant of the container image. Some images can use multiple variants of the arm architectures, such as arm/v5 and arm/v7.
**--pid**=*mode*
diff --git a/libpod/image/docker_registry_options.go b/libpod/image/docker_registry_options.go
index c434f0259..257b7ae8d 100644
--- a/libpod/image/docker_registry_options.go
+++ b/libpod/image/docker_registry_options.go
@@ -30,6 +30,8 @@ type DockerRegistryOptions struct {
OSChoice string
// If not "", overrides the use of platform.GOARCH when choosing an image or verifying architecture match.
ArchitectureChoice string
+ // If not "", overrides_VARIANT_ instead of the running architecture variant for choosing images.
+ VariantChoice string
// RegistriesConfPath can be used to override the default path of registries.conf.
RegistriesConfPath string
}
@@ -43,6 +45,7 @@ func (o DockerRegistryOptions) GetSystemContext(parent *types.SystemContext, add
DockerArchiveAdditionalTags: additionalDockerArchiveTags,
OSChoice: o.OSChoice,
ArchitectureChoice: o.ArchitectureChoice,
+ VariantChoice: o.VariantChoice,
BigFilesTemporaryDir: parse.GetTempDir(),
}
if parent != nil {
diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index 641698d03..bdcda4016 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -228,6 +228,7 @@ func (ir *Runtime) pullImageFromHeuristicSource(ctx context.Context, inputName s
if dockerOptions != nil {
sc.OSChoice = dockerOptions.OSChoice
sc.ArchitectureChoice = dockerOptions.ArchitectureChoice
+ sc.VariantChoice = dockerOptions.VariantChoice
}
sc.BlobInfoCacheDir = filepath.Join(ir.store.GraphRoot(), "cache")
srcRef, err := alltransports.ParseImageName(inputName)
@@ -260,6 +261,7 @@ func (ir *Runtime) pullImageFromReference(ctx context.Context, srcRef types.Imag
if dockerOptions != nil {
sc.OSChoice = dockerOptions.OSChoice
sc.ArchitectureChoice = dockerOptions.ArchitectureChoice
+ sc.VariantChoice = dockerOptions.VariantChoice
}
goal, err := ir.pullGoalFromImageReference(ctx, srcRef, transports.ImageName(srcRef), sc)
if err != nil {
diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go
index 51013acf1..8d3fc4e00 100644
--- a/pkg/api/handlers/libpod/images.go
+++ b/pkg/api/handlers/libpod/images.go
@@ -338,11 +338,12 @@ func ImagesPull(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value("runtime").(*libpod.Runtime)
decoder := r.Context().Value("decoder").(*schema.Decoder)
query := struct {
- Reference string `schema:"reference"`
- OverrideOS string `schema:"overrideOS"`
- OverrideArch string `schema:"overrideArch"`
- TLSVerify bool `schema:"tlsVerify"`
- AllTags bool `schema:"allTags"`
+ Reference string `schema:"reference"`
+ OverrideOS string `schema:"overrideOS"`
+ OverrideArch string `schema:"overrideArch"`
+ OverrideVariant string `schema:"overrideVariant"`
+ TLSVerify bool `schema:"tlsVerify"`
+ AllTags bool `schema:"allTags"`
}{
TLSVerify: true,
}
@@ -393,6 +394,7 @@ func ImagesPull(w http.ResponseWriter, r *http.Request) {
DockerRegistryCreds: authConf,
OSChoice: query.OverrideOS,
ArchitectureChoice: query.OverrideArch,
+ VariantChoice: query.OverrideVariant,
}
if _, found := r.URL.Query()["tlsVerify"]; found {
dockerRegistryOptions.DockerInsecureSkipTLSVerify = types.NewOptionalBool(!query.TLSVerify)
diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go
index 748e3fb11..64258a073 100644
--- a/pkg/api/server/register_images.go
+++ b/pkg/api/server/register_images.go
@@ -905,12 +905,16 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
// description: "username:password for the registry"
// type: string
// - in: query
+ // name: overrideArch
+ // description: Pull image for the specified architecture.
+ // type: string
+ // - in: query
// name: overrideOS
// description: Pull image for the specified operating system.
// type: string
// - in: query
- // name: overrideArch
- // description: Pull image for the specified architecture.
+ // name: overrideVariant
+ // description: Pull image for the specified variant.
// type: string
// - in: query
// name: tlsVerify
diff --git a/pkg/bindings/images/images.go b/pkg/bindings/images/images.go
index 12d1a9ce9..9f6e78b79 100644
--- a/pkg/bindings/images/images.go
+++ b/pkg/bindings/images/images.go
@@ -365,6 +365,7 @@ func Pull(ctx context.Context, rawImage string, options entities.ImagePullOption
params.Set("reference", rawImage)
params.Set("overrideArch", options.OverrideArch)
params.Set("overrideOS", options.OverrideOS)
+ params.Set("overrideVariant", options.OverrideVariant)
if options.SkipTLSVerify != types.OptionalBoolUndefined {
// Note: we have to verify if skipped is false.
verifyTLS := bool(options.SkipTLSVerify == types.OptionalBoolFalse)
diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go
index cb970b09a..3a12a4e22 100644
--- a/pkg/domain/entities/images.go
+++ b/pkg/domain/entities/images.go
@@ -137,6 +137,8 @@ type ImagePullOptions struct {
// OverrideOS will overwrite the local operating system (OS) for image
// pulls.
OverrideOS string
+ // OverrideVariant will overwrite the local variant for image pulls.
+ OverrideVariant string
// Quiet can be specified to suppress pull progress when pulling. Ignored
// for remote calls.
Quiet bool
diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go
index 70d740bb5..6b94ca9c0 100644
--- a/pkg/domain/infra/abi/images.go
+++ b/pkg/domain/infra/abi/images.go
@@ -251,6 +251,7 @@ func (ir *ImageEngine) Pull(ctx context.Context, rawImage string, options entiti
DockerCertPath: options.CertDir,
OSChoice: options.OverrideOS,
ArchitectureChoice: options.OverrideArch,
+ VariantChoice: options.OverrideVariant,
DockerInsecureSkipTLSVerify: options.SkipTLSVerify,
}