diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-03-17 10:34:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-17 10:34:11 +0100 |
commit | 6ce967708de95723df92084818274a76c1d7ae16 (patch) | |
tree | cf09301df89228e663fa68ef3947c1962fd92d51 /pkg/api/handlers/libpod/generate.go | |
parent | b1d37a7e21bfb3e12af2e7cee25dc88ac4f148dd (diff) | |
parent | 714e5a13d9586ac6a3a6a1ee1b2ec15a43058350 (diff) | |
download | podman-6ce967708de95723df92084818274a76c1d7ae16.tar.gz podman-6ce967708de95723df92084818274a76c1d7ae16.tar.bz2 podman-6ce967708de95723df92084818274a76c1d7ae16.zip |
Merge pull request #13299 from npate012/fix_systemd_generate_name_on_empty_prefix
Separator is no longer prepended when prefix is empty on podman generate systemd
Diffstat (limited to 'pkg/api/handlers/libpod/generate.go')
-rw-r--r-- | pkg/api/handlers/libpod/generate.go | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/pkg/api/handlers/libpod/generate.go b/pkg/api/handlers/libpod/generate.go index 7e08dd4a8..28785b00d 100644 --- a/pkg/api/handlers/libpod/generate.go +++ b/pkg/api/handlers/libpod/generate.go @@ -25,18 +25,15 @@ func GenerateSystemd(w http.ResponseWriter, r *http.Request) { RestartSec uint `schema:"restartSec"` StopTimeout uint `schema:"stopTimeout"` StartTimeout uint `schema:"startTimeout"` - ContainerPrefix string `schema:"containerPrefix"` - PodPrefix string `schema:"podPrefix"` - Separator string `schema:"separator"` + ContainerPrefix *string `schema:"containerPrefix"` + PodPrefix *string `schema:"podPrefix"` + Separator *string `schema:"separator"` Wants []string `schema:"wants"` After []string `schema:"after"` Requires []string `schema:"requires"` }{ - StartTimeout: 0, - StopTimeout: util.DefaultContainerConfig().Engine.StopTimeout, - ContainerPrefix: "container", - PodPrefix: "pod", - Separator: "-", + StartTimeout: 0, + StopTimeout: util.DefaultContainerConfig().Engine.StopTimeout, } if err := decoder.Decode(&query, r.URL.Query()); err != nil { @@ -44,6 +41,21 @@ func GenerateSystemd(w http.ResponseWriter, r *http.Request) { return } + var ContainerPrefix = "container" + if query.ContainerPrefix != nil { + ContainerPrefix = *query.ContainerPrefix + } + + var PodPrefix = "pod" + if query.PodPrefix != nil { + PodPrefix = *query.PodPrefix + } + + var Separator = "-" + if query.Separator != nil { + Separator = *query.Separator + } + containerEngine := abi.ContainerEngine{Libpod: runtime} options := entities.GenerateSystemdOptions{ Name: query.Name, @@ -53,9 +65,9 @@ func GenerateSystemd(w http.ResponseWriter, r *http.Request) { RestartPolicy: query.RestartPolicy, StartTimeout: &query.StartTimeout, StopTimeout: &query.StopTimeout, - ContainerPrefix: query.ContainerPrefix, - PodPrefix: query.PodPrefix, - Separator: query.Separator, + ContainerPrefix: ContainerPrefix, + PodPrefix: PodPrefix, + Separator: Separator, RestartSec: &query.RestartSec, Wants: query.Wants, After: query.After, |