summaryrefslogtreecommitdiff
path: root/pkg/systemd/generate/common.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-01-12 11:47:14 -0500
committerGitHub <noreply@github.com>2021-01-12 11:47:14 -0500
commit0ccc88813e3e3a385ecdefbe971c1664193cd682 (patch)
tree90fef5dbc772c4b8f900633411cdc950eb9778a0 /pkg/systemd/generate/common.go
parent0532fdac1a5746ad02ef21842ca6cd3b172fad03 (diff)
parentef82be4e0022e9986eca5022b76ce228c05e5d89 (diff)
downloadpodman-0ccc88813e3e3a385ecdefbe971c1664193cd682.tar.gz
podman-0ccc88813e3e3a385ecdefbe971c1664193cd682.tar.bz2
podman-0ccc88813e3e3a385ecdefbe971c1664193cd682.zip
Merge pull request #8851 from Luap99/fix-generate-systemd-flag-parsing
Make podman generate systemd --new flag parsing more robust
Diffstat (limited to 'pkg/systemd/generate/common.go')
-rw-r--r--pkg/systemd/generate/common.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/pkg/systemd/generate/common.go b/pkg/systemd/generate/common.go
index fb921cd72..8901298db 100644
--- a/pkg/systemd/generate/common.go
+++ b/pkg/systemd/generate/common.go
@@ -71,3 +71,30 @@ func quoteArguments(command []string) []string {
}
return command
}
+
+func removeDetachArg(args []string, argCount int) []string {
+ // "--detach=false" could also be in the container entrypoint
+ // split them off so we do not remove it there
+ realArgs := args[len(args)-argCount:]
+ flagArgs := removeArg("-d=false", args[:len(args)-argCount])
+ flagArgs = removeArg("--detach=false", flagArgs)
+ return append(flagArgs, realArgs...)
+}
+
+func removeReplaceArg(args []string, argCount int) []string {
+ // "--replace=false" could also be in the container entrypoint
+ // split them off so we do not remove it there
+ realArgs := args[len(args)-argCount:]
+ flagArgs := removeArg("--replace=false", args[:len(args)-argCount])
+ return append(flagArgs, realArgs...)
+}
+
+func removeArg(arg string, args []string) []string {
+ newArgs := []string{}
+ for _, a := range args {
+ if a != arg {
+ newArgs = append(newArgs, a)
+ }
+ }
+ return newArgs
+}