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