bindings, build: don't pass invalid platform in case of none

In case of no `platform` , bindings should not add `platform` to
parameters at all instead it adds `/` as platform string which is
invalid.

[NO NEW TESTS NEEDED]
Exsiting test should pass with new buildah from upstream.

Closes: https://github.com/containers/buildah/issues/4768

Signed-off-by: Aditya R <arajan@redhat.com>
This commit is contained in:
Aditya R 2023-05-02 14:23:38 +05:30
parent d494af9647
commit e1e03a0e34
No known key found for this signature in database
GPG Key ID: 8E5A8A19DF7C8673
1 changed files with 6 additions and 0 deletions

View File

@ -298,6 +298,12 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
if len(options.Platforms) > 0 {
params.Del("platform")
for _, platformSpec := range options.Platforms {
// podman-cli will send empty struct, in such
// case don't add platform to param and let the
// build backend decide the default platform.
if platformSpec.OS == "" && platformSpec.Arch == "" && platformSpec.Variant == "" {
continue
}
platform = platformSpec.OS + "/" + platformSpec.Arch
if platformSpec.Variant != "" {
platform += "/" + platformSpec.Variant