summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-09-15 06:21:58 -0400
committerGitHub <noreply@github.com>2021-09-15 06:21:58 -0400
commitaff64dda65514064ccbf7fcaf78293e111539eb6 (patch)
tree395ab38c3a486f0dd43fa157c8b2899782053d26
parent07e9bf340a83ecb7174e32fb565826c21a9a91ca (diff)
parent5dbf3ee7aeef6e2aca5512b3ad8684610080d421 (diff)
downloadpodman-aff64dda65514064ccbf7fcaf78293e111539eb6.tar.gz
podman-aff64dda65514064ccbf7fcaf78293e111539eb6.tar.bz2
podman-aff64dda65514064ccbf7fcaf78293e111539eb6.zip
Merge pull request #11574 from nalind/buildah-platforms
build: take advantage of --platform lists
-rw-r--r--cmd/podman/images/build.go5
-rw-r--r--pkg/api/handlers/compat/images_build.go18
-rw-r--r--pkg/bindings/images/build.go10
3 files changed, 21 insertions, 12 deletions
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index a1a28b809..31d014dfe 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -476,7 +476,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
runtimeFlags = append(runtimeFlags, "--systemd-cgroup")
}
- imageOS, arch, err := parse.PlatformFromOptions(c)
+ platforms, err := parse.PlatformsFromOptions(c)
if err != nil {
return nil, err
}
@@ -490,7 +490,6 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
AddCapabilities: flags.CapAdd,
AdditionalTags: tags,
Annotations: flags.Annotation,
- Architecture: arch,
Args: args,
BlobDirectory: flags.BlobCache,
CNIConfigDir: flags.CNIConfigDir,
@@ -516,11 +515,11 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
MaxPullPushRetries: 3,
NamespaceOptions: nsValues,
NoCache: flags.NoCache,
- OS: imageOS,
OciDecryptConfig: decConfig,
Out: stdout,
Output: output,
OutputFormat: format,
+ Platforms: platforms,
PullPolicy: pullPolicy,
PullPushRetryDelay: 2 * time.Second,
Quiet: flags.Quiet,
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go
index 6855742b2..606c52e41 100644
--- a/pkg/api/handlers/compat/images_build.go
+++ b/pkg/api/handlers/compat/images_build.go
@@ -106,7 +106,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
NamespaceOptions string `schema:"nsoptions"`
NoCache bool `schema:"nocache"`
OutputFormat string `schema:"outputformat"`
- Platform string `schema:"platform"`
+ Platform []string `schema:"platform"`
Pull bool `schema:"pull"`
PullPolicy string `schema:"pullpolicy"`
Quiet bool `schema:"q"`
@@ -126,7 +126,6 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
Registry: "docker.io",
Rm: true,
ShmSize: 64 * 1024 * 1024,
- Tag: []string{},
}
decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
@@ -481,16 +480,17 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
},
}
- if len(query.Platform) > 0 {
- variant := ""
- buildOptions.OS, buildOptions.Architecture, variant, err = parse.Platform(query.Platform)
+ for _, platformSpec := range query.Platform {
+ os, arch, variant, err := parse.Platform(platformSpec)
if err != nil {
- utils.BadRequest(w, "platform", query.Platform, err)
+ utils.BadRequest(w, "platform", platformSpec, err)
return
}
- buildOptions.SystemContext.OSChoice = buildOptions.OS
- buildOptions.SystemContext.ArchitectureChoice = buildOptions.Architecture
- buildOptions.SystemContext.VariantChoice = variant
+ buildOptions.Platforms = append(buildOptions.Platforms, struct{ OS, Arch, Variant string }{
+ OS: os,
+ Arch: arch,
+ Variant: variant,
+ })
}
if _, found := r.URL.Query()["timestamp"]; found {
ts := time.Unix(query.Timestamp, 0)
diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go
index 3beafa585..9d5aad23b 100644
--- a/pkg/bindings/images/build.go
+++ b/pkg/bindings/images/build.go
@@ -220,6 +220,16 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
if len(platform) > 0 {
params.Set("platform", platform)
}
+ if len(options.Platforms) > 0 {
+ params.Del("platform")
+ for _, platformSpec := range options.Platforms {
+ platform = platformSpec.OS + "/" + platformSpec.Arch
+ if platformSpec.Variant != "" {
+ platform += "/" + platformSpec.Variant
+ }
+ params.Add("platform", platform)
+ }
+ }
params.Set("pullpolicy", options.PullPolicy.String())