mirror of
https://github.com/containers/podman.git
synced 2025-08-26 03:01:31 +08:00
Quadlet .pod - add support for the Volume Key
Add e2e tests Update documentation Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
This commit is contained in:
@ -324,6 +324,7 @@ var (
|
||||
KeyNetwork: true,
|
||||
KeyPodmanArgs: true,
|
||||
KeyPodName: true,
|
||||
KeyVolume: true,
|
||||
}
|
||||
)
|
||||
|
||||
@ -667,37 +668,8 @@ func ConvertContainer(container *parser.UnitFile, names map[string]string, isUse
|
||||
podman.add("--tmpfs", tmpfs)
|
||||
}
|
||||
|
||||
volumes := container.LookupAll(ContainerGroup, KeyVolume)
|
||||
for _, volume := range volumes {
|
||||
parts := strings.SplitN(volume, ":", 3)
|
||||
|
||||
source := ""
|
||||
var dest string
|
||||
options := ""
|
||||
if len(parts) >= 2 {
|
||||
source = parts[0]
|
||||
dest = parts[1]
|
||||
} else {
|
||||
dest = parts[0]
|
||||
}
|
||||
if len(parts) >= 3 {
|
||||
options = ":" + parts[2]
|
||||
}
|
||||
|
||||
if source != "" {
|
||||
var err error
|
||||
source, err = handleStorageSource(container, service, source, names)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
podman.add("-v")
|
||||
if source == "" {
|
||||
podman.add(dest)
|
||||
} else {
|
||||
podman.addf("%s:%s%s", source, dest, options)
|
||||
}
|
||||
if err := addVolumes(container, service, ContainerGroup, names, podman); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
update, ok := container.Lookup(ContainerGroup, KeyAutoUpdate)
|
||||
@ -1325,6 +1297,10 @@ func ConvertPod(podUnit *parser.UnitFile, name string, podsInfoMap map[string]*P
|
||||
|
||||
addNetworks(podUnit, PodGroup, service, names, execStartPre)
|
||||
|
||||
if err := addVolumes(podUnit, service, PodGroup, names, execStartPre); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
execStartPre.addf("--name=%s", podName)
|
||||
|
||||
handlePodmanArgs(podUnit, PodGroup, execStartPre)
|
||||
@ -1824,3 +1800,40 @@ func handlePod(quadletUnitFile, serviceUnitFile *parser.UnitFile, groupName stri
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func addVolumes(quadletUnitFile, serviceUnitFile *parser.UnitFile, groupName string, names map[string]string, podman *PodmanCmdline) error {
|
||||
volumes := quadletUnitFile.LookupAll(groupName, KeyVolume)
|
||||
for _, volume := range volumes {
|
||||
parts := strings.SplitN(volume, ":", 3)
|
||||
|
||||
source := ""
|
||||
var dest string
|
||||
options := ""
|
||||
if len(parts) >= 2 {
|
||||
source = parts[0]
|
||||
dest = parts[1]
|
||||
} else {
|
||||
dest = parts[0]
|
||||
}
|
||||
if len(parts) >= 3 {
|
||||
options = ":" + parts[2]
|
||||
}
|
||||
|
||||
if source != "" {
|
||||
var err error
|
||||
source, err = handleStorageSource(quadletUnitFile, serviceUnitFile, source, names)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
podman.add("-v")
|
||||
if source == "" {
|
||||
podman.add(dest)
|
||||
} else {
|
||||
podman.addf("%s:%s%s", source, dest, options)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user