API handler: don't force the IdentityLabel flag

Don't force the IdentityLabel option one way or another when the client
doesn't specifically request one or the other, so that the server can
choose to use its default behavior.

Fixes #26669

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
Nalin Dahyabhai
2025-07-21 19:56:54 -04:00
committed by tomsweeneyredhat
parent 3e673591ad
commit db2baee9fa

View File

@@ -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,