mirror of https://github.com/containers/podman.git
Merge pull request #11574 from nalind/buildah-platforms
build: take advantage of --platform lists
This commit is contained in:
commit
aff64dda65
|
@ -476,7 +476,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
|
||||||
runtimeFlags = append(runtimeFlags, "--systemd-cgroup")
|
runtimeFlags = append(runtimeFlags, "--systemd-cgroup")
|
||||||
}
|
}
|
||||||
|
|
||||||
imageOS, arch, err := parse.PlatformFromOptions(c)
|
platforms, err := parse.PlatformsFromOptions(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -490,7 +490,6 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
|
||||||
AddCapabilities: flags.CapAdd,
|
AddCapabilities: flags.CapAdd,
|
||||||
AdditionalTags: tags,
|
AdditionalTags: tags,
|
||||||
Annotations: flags.Annotation,
|
Annotations: flags.Annotation,
|
||||||
Architecture: arch,
|
|
||||||
Args: args,
|
Args: args,
|
||||||
BlobDirectory: flags.BlobCache,
|
BlobDirectory: flags.BlobCache,
|
||||||
CNIConfigDir: flags.CNIConfigDir,
|
CNIConfigDir: flags.CNIConfigDir,
|
||||||
|
@ -516,11 +515,11 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
|
||||||
MaxPullPushRetries: 3,
|
MaxPullPushRetries: 3,
|
||||||
NamespaceOptions: nsValues,
|
NamespaceOptions: nsValues,
|
||||||
NoCache: flags.NoCache,
|
NoCache: flags.NoCache,
|
||||||
OS: imageOS,
|
|
||||||
OciDecryptConfig: decConfig,
|
OciDecryptConfig: decConfig,
|
||||||
Out: stdout,
|
Out: stdout,
|
||||||
Output: output,
|
Output: output,
|
||||||
OutputFormat: format,
|
OutputFormat: format,
|
||||||
|
Platforms: platforms,
|
||||||
PullPolicy: pullPolicy,
|
PullPolicy: pullPolicy,
|
||||||
PullPushRetryDelay: 2 * time.Second,
|
PullPushRetryDelay: 2 * time.Second,
|
||||||
Quiet: flags.Quiet,
|
Quiet: flags.Quiet,
|
||||||
|
|
|
@ -106,7 +106,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
||||||
NamespaceOptions string `schema:"nsoptions"`
|
NamespaceOptions string `schema:"nsoptions"`
|
||||||
NoCache bool `schema:"nocache"`
|
NoCache bool `schema:"nocache"`
|
||||||
OutputFormat string `schema:"outputformat"`
|
OutputFormat string `schema:"outputformat"`
|
||||||
Platform string `schema:"platform"`
|
Platform []string `schema:"platform"`
|
||||||
Pull bool `schema:"pull"`
|
Pull bool `schema:"pull"`
|
||||||
PullPolicy string `schema:"pullpolicy"`
|
PullPolicy string `schema:"pullpolicy"`
|
||||||
Quiet bool `schema:"q"`
|
Quiet bool `schema:"q"`
|
||||||
|
@ -126,7 +126,6 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
||||||
Registry: "docker.io",
|
Registry: "docker.io",
|
||||||
Rm: true,
|
Rm: true,
|
||||||
ShmSize: 64 * 1024 * 1024,
|
ShmSize: 64 * 1024 * 1024,
|
||||||
Tag: []string{},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
|
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 {
|
for _, platformSpec := range query.Platform {
|
||||||
variant := ""
|
os, arch, variant, err := parse.Platform(platformSpec)
|
||||||
buildOptions.OS, buildOptions.Architecture, variant, err = parse.Platform(query.Platform)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.BadRequest(w, "platform", query.Platform, err)
|
utils.BadRequest(w, "platform", platformSpec, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
buildOptions.SystemContext.OSChoice = buildOptions.OS
|
buildOptions.Platforms = append(buildOptions.Platforms, struct{ OS, Arch, Variant string }{
|
||||||
buildOptions.SystemContext.ArchitectureChoice = buildOptions.Architecture
|
OS: os,
|
||||||
buildOptions.SystemContext.VariantChoice = variant
|
Arch: arch,
|
||||||
|
Variant: variant,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if _, found := r.URL.Query()["timestamp"]; found {
|
if _, found := r.URL.Query()["timestamp"]; found {
|
||||||
ts := time.Unix(query.Timestamp, 0)
|
ts := time.Unix(query.Timestamp, 0)
|
||||||
|
|
|
@ -220,6 +220,16 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
|
||||||
if len(platform) > 0 {
|
if len(platform) > 0 {
|
||||||
params.Set("platform", platform)
|
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())
|
params.Set("pullpolicy", options.PullPolicy.String())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue