diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-04-12 13:40:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-12 13:40:54 -0400 |
commit | ab27836b56ee165526e9f1dd5a41ffd74f823f3d (patch) | |
tree | e2f2a61a90d5e41e5b431354bb110dc524468a4e /pkg/systemd/generate/containers.go | |
parent | a82ec1be458bb0861fdde8351c0474fc3c3fc9e7 (diff) | |
parent | fb4fc03ec48fb6f6b41b51cecdfe9dae0d1610bb (diff) | |
download | podman-ab27836b56ee165526e9f1dd5a41ffd74f823f3d.tar.gz podman-ab27836b56ee165526e9f1dd5a41ffd74f823f3d.tar.bz2 podman-ab27836b56ee165526e9f1dd5a41ffd74f823f3d.zip |
Merge pull request #13814 from rhatdan/systemd
Pretty print systemd services file
Diffstat (limited to 'pkg/systemd/generate/containers.go')
-rw-r--r-- | pkg/systemd/generate/containers.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/pkg/systemd/generate/containers.go b/pkg/systemd/generate/containers.go index e11aed771..d552e21ed 100644 --- a/pkg/systemd/generate/containers.go +++ b/pkg/systemd/generate/containers.go @@ -282,6 +282,22 @@ func setContainerNameForTemplate(startCommand []string, info *containerInfo) ([] return startCommand, nil } +func formatOptions(options []string) string { + var formatted strings.Builder + if len(options) == 0 { + return "" + } + formatted.WriteString(options[0]) + for _, o := range options[1:] { + if strings.HasPrefix(o, "-") { + formatted.WriteString(" \\\n\t" + o) + continue + } + formatted.WriteString(" " + o) + } + return formatted.String() +} + // executeContainerTemplate executes the container template on the specified // containerInfo. Note that the containerInfo is also post processed and // completed, which allows for an easier unit testing. @@ -475,9 +491,8 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst return "", err } } - info.ExecStart = strings.Join(startCommand, " ") + info.ExecStart = formatOptions(startCommand) } - info.TimeoutStopSec = minTimeoutStopSec + info.StopTimeout if info.PodmanVersion == "" { |