mirror of
https://github.com/containers/podman.git
synced 2025-05-22 09:36:57 +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 |
|
||||
| PodName=name | --name=name |
|
||||
| PublishPort=50-59 | --publish 50-59 |
|
||||
| ServiceName=name | Name the systemd unit `name.service` |
|
||||
| Volume=/source:/dest | --volume /source:/dest |
|
||||
|
||||
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.
|
||||
|
||||
|
||||
### `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=`
|
||||
|
||||
Mount a volume in the pod. This is equivalent to the Podman `--volume` option, and
|
||||
|
@ -143,6 +143,7 @@ const (
|
||||
KeySecurityLabelLevel = "SecurityLabelLevel"
|
||||
KeySecurityLabelNested = "SecurityLabelNested"
|
||||
KeySecurityLabelType = "SecurityLabelType"
|
||||
KeyServiceName = "ServiceName"
|
||||
KeySetWorkingDirectory = "SetWorkingDirectory"
|
||||
KeyShmSize = "ShmSize"
|
||||
KeyStopSignal = "StopSignal"
|
||||
@ -373,6 +374,7 @@ var (
|
||||
KeyPodName: true,
|
||||
KeyPodmanArgs: true,
|
||||
KeyPublishPort: true,
|
||||
KeyServiceName: true,
|
||||
KeyVolume: true,
|
||||
}
|
||||
)
|
||||
@ -1474,6 +1476,9 @@ func GetBuiltImageName(buildUnit *parser.UnitFile) string {
|
||||
}
|
||||
|
||||
func GetPodServiceName(podUnit *parser.UnitFile) string {
|
||||
if serviceName, ok := podUnit.Lookup(PodGroup, KeyServiceName); ok {
|
||||
return serviceName
|
||||
}
|
||||
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