mirror of
https://github.com/containers/podman.git
synced 2025-05-17 15:18:43 +08:00
Fix: inheritlabels=true if query param absent
The inheritlabels param must default to true if query param is absent. Signed-off-by: Matej Vašek <matejvasek@gmail.com>
This commit is contained in:

committed by
openshift-cherrypick-robot

parent
f271c9360d
commit
b2a99aab3f
@ -95,83 +95,83 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
query := struct {
|
||||
AddHosts string `schema:"extrahosts"`
|
||||
AdditionalCapabilities string `schema:"addcaps"`
|
||||
AdditionalBuildContexts string `schema:"additionalbuildcontexts"`
|
||||
AllPlatforms bool `schema:"allplatforms"`
|
||||
Annotations string `schema:"annotations"`
|
||||
AppArmor string `schema:"apparmor"`
|
||||
BuildArgs string `schema:"buildargs"`
|
||||
CacheFrom string `schema:"cachefrom"`
|
||||
CacheTo string `schema:"cacheto"`
|
||||
CacheTTL string `schema:"cachettl"`
|
||||
CgroupParent string `schema:"cgroupparent"`
|
||||
CompatVolumes bool `schema:"compatvolumes"`
|
||||
Compression uint64 `schema:"compression"`
|
||||
ConfigureNetwork string `schema:"networkmode"`
|
||||
CPPFlags string `schema:"cppflags"`
|
||||
CpuPeriod uint64 `schema:"cpuperiod"`
|
||||
CpuQuota int64 `schema:"cpuquota"`
|
||||
CpuSetCpus string `schema:"cpusetcpus"`
|
||||
CpuSetMems string `schema:"cpusetmems"`
|
||||
CpuShares uint64 `schema:"cpushares"`
|
||||
DNSOptions string `schema:"dnsoptions"`
|
||||
DNSSearch string `schema:"dnssearch"`
|
||||
DNSServers string `schema:"dnsservers"`
|
||||
Devices string `schema:"devices"`
|
||||
Dockerfile string `schema:"dockerfile"`
|
||||
DropCapabilities string `schema:"dropcaps"`
|
||||
Envs []string `schema:"setenv"`
|
||||
Excludes string `schema:"excludes"`
|
||||
ForceRm bool `schema:"forcerm"`
|
||||
From string `schema:"from"`
|
||||
GroupAdd []string `schema:"groupadd"`
|
||||
HTTPProxy bool `schema:"httpproxy"`
|
||||
IDMappingOptions string `schema:"idmappingoptions"`
|
||||
IdentityLabel bool `schema:"identitylabel"`
|
||||
Ignore bool `schema:"ignore"`
|
||||
InheritLabels bool `schema:"inheritlabels"`
|
||||
Isolation string `schema:"isolation"`
|
||||
Jobs int `schema:"jobs"`
|
||||
LabelOpts string `schema:"labelopts"`
|
||||
Labels string `schema:"labels"`
|
||||
LayerLabels []string `schema:"layerLabel"`
|
||||
Layers bool `schema:"layers"`
|
||||
LogRusage bool `schema:"rusage"`
|
||||
Manifest string `schema:"manifest"`
|
||||
MemSwap int64 `schema:"memswap"`
|
||||
Memory int64 `schema:"memory"`
|
||||
NamespaceOptions string `schema:"nsoptions"`
|
||||
NoCache bool `schema:"nocache"`
|
||||
NoHosts bool `schema:"nohosts"`
|
||||
OmitHistory bool `schema:"omithistory"`
|
||||
OSFeatures []string `schema:"osfeature"`
|
||||
OSVersion string `schema:"osversion"`
|
||||
OutputFormat string `schema:"outputformat"`
|
||||
Platform []string `schema:"platform"`
|
||||
Pull bool `schema:"pull"`
|
||||
PullPolicy string `schema:"pullpolicy"`
|
||||
Quiet bool `schema:"q"`
|
||||
Registry string `schema:"registry"`
|
||||
Rm bool `schema:"rm"`
|
||||
RusageLogFile string `schema:"rusagelogfile"`
|
||||
Remote string `schema:"remote"`
|
||||
Retry int `schema:"retry"`
|
||||
RetryDelay string `schema:"retry-delay"`
|
||||
Seccomp string `schema:"seccomp"`
|
||||
Secrets string `schema:"secrets"`
|
||||
SecurityOpt string `schema:"securityopt"`
|
||||
ShmSize int `schema:"shmsize"`
|
||||
SkipUnusedStages bool `schema:"skipunusedstages"`
|
||||
Squash bool `schema:"squash"`
|
||||
TLSVerify bool `schema:"tlsVerify"`
|
||||
Tags []string `schema:"t"`
|
||||
Target string `schema:"target"`
|
||||
Timestamp int64 `schema:"timestamp"`
|
||||
Ulimits string `schema:"ulimits"`
|
||||
UnsetEnvs []string `schema:"unsetenv"`
|
||||
UnsetLabels []string `schema:"unsetlabel"`
|
||||
Volumes []string `schema:"volume"`
|
||||
AddHosts string `schema:"extrahosts"`
|
||||
AdditionalCapabilities string `schema:"addcaps"`
|
||||
AdditionalBuildContexts string `schema:"additionalbuildcontexts"`
|
||||
AllPlatforms bool `schema:"allplatforms"`
|
||||
Annotations string `schema:"annotations"`
|
||||
AppArmor string `schema:"apparmor"`
|
||||
BuildArgs string `schema:"buildargs"`
|
||||
CacheFrom string `schema:"cachefrom"`
|
||||
CacheTo string `schema:"cacheto"`
|
||||
CacheTTL string `schema:"cachettl"`
|
||||
CgroupParent string `schema:"cgroupparent"`
|
||||
CompatVolumes bool `schema:"compatvolumes"`
|
||||
Compression uint64 `schema:"compression"`
|
||||
ConfigureNetwork string `schema:"networkmode"`
|
||||
CPPFlags string `schema:"cppflags"`
|
||||
CpuPeriod uint64 `schema:"cpuperiod"`
|
||||
CpuQuota int64 `schema:"cpuquota"`
|
||||
CpuSetCpus string `schema:"cpusetcpus"`
|
||||
CpuSetMems string `schema:"cpusetmems"`
|
||||
CpuShares uint64 `schema:"cpushares"`
|
||||
DNSOptions string `schema:"dnsoptions"`
|
||||
DNSSearch string `schema:"dnssearch"`
|
||||
DNSServers string `schema:"dnsservers"`
|
||||
Devices string `schema:"devices"`
|
||||
Dockerfile string `schema:"dockerfile"`
|
||||
DropCapabilities string `schema:"dropcaps"`
|
||||
Envs []string `schema:"setenv"`
|
||||
Excludes string `schema:"excludes"`
|
||||
ForceRm bool `schema:"forcerm"`
|
||||
From string `schema:"from"`
|
||||
GroupAdd []string `schema:"groupadd"`
|
||||
HTTPProxy bool `schema:"httpproxy"`
|
||||
IDMappingOptions string `schema:"idmappingoptions"`
|
||||
IdentityLabel bool `schema:"identitylabel"`
|
||||
Ignore bool `schema:"ignore"`
|
||||
InheritLabels types.OptionalBool `schema:"inheritlabels"`
|
||||
Isolation string `schema:"isolation"`
|
||||
Jobs int `schema:"jobs"`
|
||||
LabelOpts string `schema:"labelopts"`
|
||||
Labels string `schema:"labels"`
|
||||
LayerLabels []string `schema:"layerLabel"`
|
||||
Layers bool `schema:"layers"`
|
||||
LogRusage bool `schema:"rusage"`
|
||||
Manifest string `schema:"manifest"`
|
||||
MemSwap int64 `schema:"memswap"`
|
||||
Memory int64 `schema:"memory"`
|
||||
NamespaceOptions string `schema:"nsoptions"`
|
||||
NoCache bool `schema:"nocache"`
|
||||
NoHosts bool `schema:"nohosts"`
|
||||
OmitHistory bool `schema:"omithistory"`
|
||||
OSFeatures []string `schema:"osfeature"`
|
||||
OSVersion string `schema:"osversion"`
|
||||
OutputFormat string `schema:"outputformat"`
|
||||
Platform []string `schema:"platform"`
|
||||
Pull bool `schema:"pull"`
|
||||
PullPolicy string `schema:"pullpolicy"`
|
||||
Quiet bool `schema:"q"`
|
||||
Registry string `schema:"registry"`
|
||||
Rm bool `schema:"rm"`
|
||||
RusageLogFile string `schema:"rusagelogfile"`
|
||||
Remote string `schema:"remote"`
|
||||
Retry int `schema:"retry"`
|
||||
RetryDelay string `schema:"retry-delay"`
|
||||
Seccomp string `schema:"seccomp"`
|
||||
Secrets string `schema:"secrets"`
|
||||
SecurityOpt string `schema:"securityopt"`
|
||||
ShmSize int `schema:"shmsize"`
|
||||
SkipUnusedStages bool `schema:"skipunusedstages"`
|
||||
Squash bool `schema:"squash"`
|
||||
TLSVerify bool `schema:"tlsVerify"`
|
||||
Tags []string `schema:"t"`
|
||||
Target string `schema:"target"`
|
||||
Timestamp int64 `schema:"timestamp"`
|
||||
Ulimits string `schema:"ulimits"`
|
||||
UnsetEnvs []string `schema:"unsetenv"`
|
||||
UnsetLabels []string `schema:"unsetlabel"`
|
||||
Volumes []string `schema:"volume"`
|
||||
}{
|
||||
Dockerfile: "Dockerfile",
|
||||
IdentityLabel: true,
|
||||
@ -745,7 +745,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
||||
IDMappingOptions: &idMappingOptions,
|
||||
IgnoreUnrecognizedInstructions: query.Ignore,
|
||||
IgnoreFile: ignoreFile,
|
||||
InheritLabels: types.NewOptionalBool(query.InheritLabels),
|
||||
InheritLabels: query.InheritLabels,
|
||||
Isolation: isolation,
|
||||
Jobs: &jobs,
|
||||
Labels: labels,
|
||||
|
@ -5,10 +5,12 @@ package handlers
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/containers/image/v5/types"
|
||||
"github.com/containers/podman/v5/libpod/define"
|
||||
"github.com/containers/podman/v5/pkg/util"
|
||||
"github.com/gorilla/schema"
|
||||
@ -28,6 +30,9 @@ func NewAPIDecoder() *schema.Decoder {
|
||||
|
||||
var Signal syscall.Signal
|
||||
d.RegisterConverter(Signal, convertSignal)
|
||||
|
||||
d.RegisterConverter(types.OptionalBoolUndefined, convertOptionalBool)
|
||||
|
||||
return d
|
||||
}
|
||||
|
||||
@ -39,6 +44,16 @@ func NewCompatAPIDecoder() *schema.Decoder {
|
||||
s = strings.ToLower(strings.TrimSpace(s))
|
||||
return reflect.ValueOf(s != "" && s != "0" && s != "no" && s != "false" && s != "none")
|
||||
})
|
||||
dec.RegisterConverter(types.OptionalBoolUndefined, func(s string) reflect.Value {
|
||||
if len(s) == 0 {
|
||||
return reflect.ValueOf(types.OptionalBoolUndefined)
|
||||
}
|
||||
s = strings.ToLower(strings.TrimSpace(s))
|
||||
if s != "0" && s != "no" && s != "false" && s != "none" {
|
||||
return reflect.ValueOf(types.OptionalBoolTrue)
|
||||
}
|
||||
return reflect.ValueOf(types.OptionalBoolFalse)
|
||||
})
|
||||
|
||||
return dec
|
||||
}
|
||||
@ -143,3 +158,14 @@ func convertSignal(query string) reflect.Value {
|
||||
}
|
||||
return reflect.ValueOf(signal)
|
||||
}
|
||||
|
||||
func convertOptionalBool(s string) reflect.Value {
|
||||
if len(s) == 0 {
|
||||
return reflect.ValueOf(types.OptionalBoolUndefined)
|
||||
}
|
||||
val, _ := strconv.ParseBool(s)
|
||||
if val {
|
||||
return reflect.ValueOf(types.OptionalBoolTrue)
|
||||
}
|
||||
return reflect.ValueOf(types.OptionalBoolFalse)
|
||||
}
|
||||
|
Reference in New Issue
Block a user