From 714e5a13d9586ac6a3a6a1ee1b2ec15a43058350 Mon Sep 17 00:00:00 2001 From: Nirmal Patel Date: Sat, 19 Feb 2022 17:55:23 -0500 Subject: Separator is no longer prepended when prefix is empty on podman generate systemd When podman generate systemd is invoked, it previously did not check if container-prefix or pod-prefix are empty. When these are empty, the file name starts with the separator, which is hyphen by default. This results in files like '-containername.service'. The code now checks if these prefixes are empty. If they are, the filename no longer adds a separator. Instead, it uses name or ID of the container or pod. Closes #13272 Signed-off-by: Nirmal Patel --- pkg/systemd/generate/containers.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'pkg/systemd/generate/containers.go') diff --git a/pkg/systemd/generate/containers.go b/pkg/systemd/generate/containers.go index ea829c810..c01bb1baf 100644 --- a/pkg/systemd/generate/containers.go +++ b/pkg/systemd/generate/containers.go @@ -236,7 +236,9 @@ func containerServiceName(ctr *libpod.Container, options entities.GenerateSystem if options.Name { nameOrID = ctr.Name() } - serviceName := fmt.Sprintf("%s%s%s", options.ContainerPrefix, options.Separator, nameOrID) + + serviceName := getServiceName(options.ContainerPrefix, options.Separator, nameOrID) + return nameOrID, serviceName } -- cgit v1.2.3-54-g00ecf