mirror of
https://github.com/containers/podman.git
synced 2025-05-22 17:46:52 +08:00
Quadlet - Allow the user to set the service name for .pod files
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
This commit is contained in:
@ -863,6 +863,7 @@ Valid options for `[Pod]` are listed below:
|
|||||||
| PodmanArgs=\-\-cpus=2 | --cpus=2 |
|
| PodmanArgs=\-\-cpus=2 | --cpus=2 |
|
||||||
| PodName=name | --name=name |
|
| PodName=name | --name=name |
|
||||||
| PublishPort=50-59 | --publish 50-59 |
|
| PublishPort=50-59 | --publish 50-59 |
|
||||||
|
| ServiceName=name | Name the systemd unit `name.service` |
|
||||||
| Volume=/source:/dest | --volume /source:/dest |
|
| Volume=/source:/dest | --volume /source:/dest |
|
||||||
|
|
||||||
Supported keys in the `[Pod]` section are:
|
Supported keys in the `[Pod]` section are:
|
||||||
@ -947,6 +948,14 @@ When using `host` networking via `Network=host`, the `PublishPort=` option canno
|
|||||||
|
|
||||||
This key can be listed multiple times.
|
This key can be listed multiple times.
|
||||||
|
|
||||||
|
|
||||||
|
### `ServiceName=`
|
||||||
|
|
||||||
|
By default, Quadlet will name the systemd service unit by appending `-pod` to the name of the Quadlet.
|
||||||
|
Setting this key overrides this behavior by instructing Quadlet to use the provided name.
|
||||||
|
|
||||||
|
Note, the name should not include the `.service` file extension
|
||||||
|
|
||||||
### `Volume=`
|
### `Volume=`
|
||||||
|
|
||||||
Mount a volume in the pod. This is equivalent to the Podman `--volume` option, and
|
Mount a volume in the pod. This is equivalent to the Podman `--volume` option, and
|
||||||
|
@ -143,6 +143,7 @@ const (
|
|||||||
KeySecurityLabelLevel = "SecurityLabelLevel"
|
KeySecurityLabelLevel = "SecurityLabelLevel"
|
||||||
KeySecurityLabelNested = "SecurityLabelNested"
|
KeySecurityLabelNested = "SecurityLabelNested"
|
||||||
KeySecurityLabelType = "SecurityLabelType"
|
KeySecurityLabelType = "SecurityLabelType"
|
||||||
|
KeyServiceName = "ServiceName"
|
||||||
KeySetWorkingDirectory = "SetWorkingDirectory"
|
KeySetWorkingDirectory = "SetWorkingDirectory"
|
||||||
KeyShmSize = "ShmSize"
|
KeyShmSize = "ShmSize"
|
||||||
KeyStopSignal = "StopSignal"
|
KeyStopSignal = "StopSignal"
|
||||||
@ -373,6 +374,7 @@ var (
|
|||||||
KeyPodName: true,
|
KeyPodName: true,
|
||||||
KeyPodmanArgs: true,
|
KeyPodmanArgs: true,
|
||||||
KeyPublishPort: true,
|
KeyPublishPort: true,
|
||||||
|
KeyServiceName: true,
|
||||||
KeyVolume: true,
|
KeyVolume: true,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -1474,6 +1476,9 @@ func GetBuiltImageName(buildUnit *parser.UnitFile) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetPodServiceName(podUnit *parser.UnitFile) string {
|
func GetPodServiceName(podUnit *parser.UnitFile) string {
|
||||||
|
if serviceName, ok := podUnit.Lookup(PodGroup, KeyServiceName); ok {
|
||||||
|
return serviceName
|
||||||
|
}
|
||||||
return replaceExtension(podUnit.Filename, "", "", "-pod")
|
return replaceExtension(podUnit.Filename, "", "", "-pod")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
test/e2e/quadlet/service-name.pod
Normal file
5
test/e2e/quadlet/service-name.pod
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
## assert-podman-pre-args "--name=test-pod"
|
||||||
|
|
||||||
|
[Pod]
|
||||||
|
PodName=test-pod
|
||||||
|
ServiceName=test-pod
|
Reference in New Issue
Block a user