summaryrefslogtreecommitdiff
path: root/test/e2e/generate_systemd_test.go
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2021-01-20 14:30:42 +0100
committerMatthew Heon <matthew.heon@pm.me>2021-01-29 15:25:07 -0500
commitb111370306bca917d77d3b84352791f157e09983 (patch)
treea92be9db277cd4941fad715f6ad0af6445f17560 /test/e2e/generate_systemd_test.go
parent07f2df472cdbb4c1e533dbb6e17a6c04bd2f76fe (diff)
downloadpodman-b111370306bca917d77d3b84352791f157e09983.tar.gz
podman-b111370306bca917d77d3b84352791f157e09983.tar.bz2
podman-b111370306bca917d77d3b84352791f157e09983.zip
Make generate systemd --new robust against double curly braces
If the container create command contains an argument with double curly braces the golang template parsing can fail since it tries to interpret the value as variable. To fix this change the default delimiter for the internal template to `{{{{`. Fixes #9034 Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'test/e2e/generate_systemd_test.go')
-rw-r--r--test/e2e/generate_systemd_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go
index be9727591..606d756b0 100644
--- a/test/e2e/generate_systemd_test.go
+++ b/test/e2e/generate_systemd_test.go
@@ -355,4 +355,25 @@ var _ = Describe("Podman generate systemd", func() {
Expect(session.ExitCode()).To(Equal(0))
Expect(session.IsJSONOutputValid()).To(BeTrue())
})
+
+ It("podman generate systemd --new create command with double curly braces", func() {
+ // Regression test for #9034
+ session := podmanTest.Podman([]string{"create", "--name", "foo", "--log-driver=journald", "--log-opt=tag={{.Name}}", ALPINE})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"generate", "systemd", "--new", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(ContainSubstring(" --log-opt=tag={{.Name}} "))
+
+ session = podmanTest.Podman([]string{"pod", "create", "--name", "pod", "--label", "key={{someval}}"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"generate", "systemd", "--new", "pod"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(ContainSubstring(" --label key={{someval}}"))
+ })
})