diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index c1c5081bae..737b7ad293 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -179,7 +179,6 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { Volumes []string `schema:"volume"` }{ Dockerfile: "Dockerfile", - IdentityLabel: true, Registry: "docker.io", Rm: true, ShmSize: 64 * 1024 * 1024, @@ -195,6 +194,11 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { return } + var identityLabel types.OptionalBool + if _, found := r.URL.Query()["identitylabel"]; found { + identityLabel = types.NewOptionalBool(query.IdentityLabel) + } + // if layers field not set assume its not from a valid podman-client // could be a docker client, set `layers=true` since that is the default // expected behaviour @@ -699,6 +703,9 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { } } + // Note: avoid using types.NewOptionaBool() to initialize optional bool fields of this + // struct without checking if the client supplied a value. Skipping that step prevents + // the builder from choosing/using its defaults. buildOptions := buildahDefine.BuildOptions{ AddCapabilities: addCaps, AdditionalBuildContexts: additionalBuildContexts, @@ -723,7 +730,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { DNSSearch: dnssearch, DNSServers: dnsservers, HTTPProxy: query.HTTPProxy, - IdentityLabel: types.NewOptionalBool(query.IdentityLabel), + IdentityLabel: identityLabel, LabelOpts: labelOpts, Memory: query.Memory, MemorySwap: query.MemSwap,