mirror of
https://github.com/containers/podman.git
synced 2025-05-21 09:05:56 +08:00
quadlet.go: clean up keys
- A number of keys had a "Network" prefix, for historical reasons that never panned out ("KeyNetworkGateway"). Remove that prefix and remove the two duplicates. - Three RemapXXX keys were mismatched in case ("UID" vs "Uid"). Make those consistent. Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
@ -101,16 +101,14 @@ const (
|
|||||||
KeyMask = "Mask"
|
KeyMask = "Mask"
|
||||||
KeyMount = "Mount"
|
KeyMount = "Mount"
|
||||||
KeyNetwork = "Network"
|
KeyNetwork = "Network"
|
||||||
KeyNetworkDisableDNS = "DisableDNS"
|
KeyDisableDNS = "DisableDNS"
|
||||||
KeyNetworkDriver = "Driver"
|
KeyGateway = "Gateway"
|
||||||
KeyNetworkGateway = "Gateway"
|
KeyIPAMDriver = "IPAMDriver"
|
||||||
KeyNetworkIPAMDriver = "IPAMDriver"
|
KeyIPRange = "IPRange"
|
||||||
KeyNetworkIPRange = "IPRange"
|
KeyIPv6 = "IPv6"
|
||||||
KeyNetworkIPv6 = "IPv6"
|
KeyInternal = "Internal"
|
||||||
KeyNetworkInternal = "Internal"
|
|
||||||
KeyNetworkName = "NetworkName"
|
KeyNetworkName = "NetworkName"
|
||||||
KeyNetworkOptions = "Options"
|
KeySubnet = "Subnet"
|
||||||
KeyNetworkSubnet = "Subnet"
|
|
||||||
KeyNoNewPrivileges = "NoNewPrivileges"
|
KeyNoNewPrivileges = "NoNewPrivileges"
|
||||||
KeyNotify = "Notify"
|
KeyNotify = "Notify"
|
||||||
KeyOptions = "Options"
|
KeyOptions = "Options"
|
||||||
@ -123,10 +121,10 @@ const (
|
|||||||
KeyPull = "Pull"
|
KeyPull = "Pull"
|
||||||
KeyReadOnly = "ReadOnly"
|
KeyReadOnly = "ReadOnly"
|
||||||
KeyReadOnlyTmpfs = "ReadOnlyTmpfs"
|
KeyReadOnlyTmpfs = "ReadOnlyTmpfs"
|
||||||
KeyRemapGID = "RemapGid"
|
KeyRemapGid = "RemapGid" //nolint:stylecheck
|
||||||
KeyRemapUID = "RemapUid"
|
KeyRemapUid = "RemapUid" //nolint:stylecheck
|
||||||
KeyRemapUIDSize = "RemapUidSize"
|
KeyRemapUidSize = "RemapUidSize" //nolint:stylecheck
|
||||||
KeyRemapUsers = "RemapUsers"
|
KeyRemapUsers = "RemapUsers" // deprecated
|
||||||
KeyRootfs = "Rootfs"
|
KeyRootfs = "Rootfs"
|
||||||
KeyRunInit = "RunInit"
|
KeyRunInit = "RunInit"
|
||||||
KeySeccompProfile = "SeccompProfile"
|
KeySeccompProfile = "SeccompProfile"
|
||||||
@ -217,9 +215,9 @@ var (
|
|||||||
KeyPull: true,
|
KeyPull: true,
|
||||||
KeyReadOnly: true,
|
KeyReadOnly: true,
|
||||||
KeyReadOnlyTmpfs: true,
|
KeyReadOnlyTmpfs: true,
|
||||||
KeyRemapGID: true,
|
KeyRemapGid: true,
|
||||||
KeyRemapUID: true,
|
KeyRemapUid: true,
|
||||||
KeyRemapUIDSize: true,
|
KeyRemapUidSize: true,
|
||||||
KeyRemapUsers: true,
|
KeyRemapUsers: true,
|
||||||
KeyRootfs: true,
|
KeyRootfs: true,
|
||||||
KeyRunInit: true,
|
KeyRunInit: true,
|
||||||
@ -270,16 +268,16 @@ var (
|
|||||||
KeyDNS: true,
|
KeyDNS: true,
|
||||||
KeyContainersConfModule: true,
|
KeyContainersConfModule: true,
|
||||||
KeyGlobalArgs: true,
|
KeyGlobalArgs: true,
|
||||||
KeyNetworkDisableDNS: true,
|
KeyDisableDNS: true,
|
||||||
KeyNetworkDriver: true,
|
KeyDriver: true,
|
||||||
KeyNetworkGateway: true,
|
KeyGateway: true,
|
||||||
KeyNetworkIPAMDriver: true,
|
KeyIPAMDriver: true,
|
||||||
KeyNetworkIPRange: true,
|
KeyIPRange: true,
|
||||||
KeyNetworkIPv6: true,
|
KeyIPv6: true,
|
||||||
KeyNetworkInternal: true,
|
KeyInternal: true,
|
||||||
KeyNetworkName: true,
|
KeyNetworkName: true,
|
||||||
KeyNetworkOptions: true,
|
KeyOptions: true,
|
||||||
KeyNetworkSubnet: true,
|
KeySubnet: true,
|
||||||
KeyPodmanArgs: true,
|
KeyPodmanArgs: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,9 +293,9 @@ var (
|
|||||||
KeyNetwork: true,
|
KeyNetwork: true,
|
||||||
KeyPodmanArgs: true,
|
KeyPodmanArgs: true,
|
||||||
KeyPublishPort: true,
|
KeyPublishPort: true,
|
||||||
KeyRemapGID: true,
|
KeyRemapGid: true,
|
||||||
KeyRemapUID: true,
|
KeyRemapUid: true,
|
||||||
KeyRemapUIDSize: true,
|
KeyRemapUidSize: true,
|
||||||
KeyRemapUsers: true,
|
KeyRemapUsers: true,
|
||||||
KeySetWorkingDirectory: true,
|
KeySetWorkingDirectory: true,
|
||||||
KeyUserNS: true,
|
KeyUserNS: true,
|
||||||
@ -826,7 +824,7 @@ func ConvertNetwork(network *parser.UnitFile, name string) (*parser.UnitFile, st
|
|||||||
|
|
||||||
podman.add("network", "create", "--ignore")
|
podman.add("network", "create", "--ignore")
|
||||||
|
|
||||||
if disableDNS := network.LookupBooleanWithDefault(NetworkGroup, KeyNetworkDisableDNS, false); disableDNS {
|
if disableDNS := network.LookupBooleanWithDefault(NetworkGroup, KeyDisableDNS, false); disableDNS {
|
||||||
podman.add("--disable-dns")
|
podman.add("--disable-dns")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -835,14 +833,14 @@ func ConvertNetwork(network *parser.UnitFile, name string) (*parser.UnitFile, st
|
|||||||
podman.addf("--dns=%s", ipAddr)
|
podman.addf("--dns=%s", ipAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
driver, ok := network.Lookup(NetworkGroup, KeyNetworkDriver)
|
driver, ok := network.Lookup(NetworkGroup, KeyDriver)
|
||||||
if ok && len(driver) > 0 {
|
if ok && len(driver) > 0 {
|
||||||
podman.addf("--driver=%s", driver)
|
podman.addf("--driver=%s", driver)
|
||||||
}
|
}
|
||||||
|
|
||||||
subnets := network.LookupAll(NetworkGroup, KeyNetworkSubnet)
|
subnets := network.LookupAll(NetworkGroup, KeySubnet)
|
||||||
gateways := network.LookupAll(NetworkGroup, KeyNetworkGateway)
|
gateways := network.LookupAll(NetworkGroup, KeyGateway)
|
||||||
ipRanges := network.LookupAll(NetworkGroup, KeyNetworkIPRange)
|
ipRanges := network.LookupAll(NetworkGroup, KeyIPRange)
|
||||||
if len(subnets) > 0 {
|
if len(subnets) > 0 {
|
||||||
if len(gateways) > len(subnets) {
|
if len(gateways) > len(subnets) {
|
||||||
return nil, "", fmt.Errorf("cannot set more gateways than subnets")
|
return nil, "", fmt.Errorf("cannot set more gateways than subnets")
|
||||||
@ -863,19 +861,19 @@ func ConvertNetwork(network *parser.UnitFile, name string) (*parser.UnitFile, st
|
|||||||
return nil, "", fmt.Errorf("cannot set gateway or range without subnet")
|
return nil, "", fmt.Errorf("cannot set gateway or range without subnet")
|
||||||
}
|
}
|
||||||
|
|
||||||
if internal := network.LookupBooleanWithDefault(NetworkGroup, KeyNetworkInternal, false); internal {
|
if internal := network.LookupBooleanWithDefault(NetworkGroup, KeyInternal, false); internal {
|
||||||
podman.add("--internal")
|
podman.add("--internal")
|
||||||
}
|
}
|
||||||
|
|
||||||
if ipamDriver, ok := network.Lookup(NetworkGroup, KeyNetworkIPAMDriver); ok && len(ipamDriver) > 0 {
|
if ipamDriver, ok := network.Lookup(NetworkGroup, KeyIPAMDriver); ok && len(ipamDriver) > 0 {
|
||||||
podman.addf("--ipam-driver=%s", ipamDriver)
|
podman.addf("--ipam-driver=%s", ipamDriver)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ipv6 := network.LookupBooleanWithDefault(NetworkGroup, KeyNetworkIPv6, false); ipv6 {
|
if ipv6 := network.LookupBooleanWithDefault(NetworkGroup, KeyIPv6, false); ipv6 {
|
||||||
podman.add("--ipv6")
|
podman.add("--ipv6")
|
||||||
}
|
}
|
||||||
|
|
||||||
networkOptions := network.LookupAllKeyVal(NetworkGroup, KeyNetworkOptions)
|
networkOptions := network.LookupAllKeyVal(NetworkGroup, KeyOptions)
|
||||||
if len(networkOptions) > 0 {
|
if len(networkOptions) > 0 {
|
||||||
podman.addKeys("--opt", networkOptions)
|
podman.addKeys("--opt", networkOptions)
|
||||||
}
|
}
|
||||||
@ -1390,8 +1388,8 @@ func handleUserMappings(unitFile *parser.UnitFile, groupName string, podman *Pod
|
|||||||
}
|
}
|
||||||
|
|
||||||
if mappingsDefined {
|
if mappingsDefined {
|
||||||
_, hasRemapUID := unitFile.Lookup(groupName, KeyRemapUID)
|
_, hasRemapUID := unitFile.Lookup(groupName, KeyRemapUid)
|
||||||
_, hasRemapGID := unitFile.Lookup(groupName, KeyRemapGID)
|
_, hasRemapGID := unitFile.Lookup(groupName, KeyRemapGid)
|
||||||
_, RemapUsers := unitFile.LookupLast(groupName, KeyRemapUsers)
|
_, RemapUsers := unitFile.LookupLast(groupName, KeyRemapUsers)
|
||||||
if hasRemapUID || hasRemapGID || RemapUsers {
|
if hasRemapUID || hasRemapGID || RemapUsers {
|
||||||
return fmt.Errorf("deprecated Remap keys are set along with explicit mapping keys")
|
return fmt.Errorf("deprecated Remap keys are set along with explicit mapping keys")
|
||||||
@ -1403,8 +1401,8 @@ func handleUserMappings(unitFile *parser.UnitFile, groupName string, podman *Pod
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleUserRemap(unitFile *parser.UnitFile, groupName string, podman *PodmanCmdline, isUser, supportManual bool) error {
|
func handleUserRemap(unitFile *parser.UnitFile, groupName string, podman *PodmanCmdline, isUser, supportManual bool) error {
|
||||||
uidMaps := unitFile.LookupAllStrv(groupName, KeyRemapUID)
|
uidMaps := unitFile.LookupAllStrv(groupName, KeyRemapUid)
|
||||||
gidMaps := unitFile.LookupAllStrv(groupName, KeyRemapGID)
|
gidMaps := unitFile.LookupAllStrv(groupName, KeyRemapGid)
|
||||||
remapUsers, _ := unitFile.LookupLast(groupName, KeyRemapUsers)
|
remapUsers, _ := unitFile.LookupLast(groupName, KeyRemapUsers)
|
||||||
switch remapUsers {
|
switch remapUsers {
|
||||||
case "":
|
case "":
|
||||||
@ -1433,7 +1431,7 @@ func handleUserRemap(unitFile *parser.UnitFile, groupName string, podman *Podman
|
|||||||
for _, gidMap := range gidMaps {
|
for _, gidMap := range gidMaps {
|
||||||
autoOpts = append(autoOpts, "gidmapping="+gidMap)
|
autoOpts = append(autoOpts, "gidmapping="+gidMap)
|
||||||
}
|
}
|
||||||
uidSize := unitFile.LookupUint32(groupName, KeyRemapUIDSize, 0)
|
uidSize := unitFile.LookupUint32(groupName, KeyRemapUidSize, 0)
|
||||||
if uidSize > 0 {
|
if uidSize > 0 {
|
||||||
autoOpts = append(autoOpts, fmt.Sprintf("size=%v", uidSize))
|
autoOpts = append(autoOpts, fmt.Sprintf("size=%v", uidSize))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user