diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-02-04 13:12:42 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-04 13:12:42 -0500 |
commit | aaa86c68c045519085fe7b174b6adce5f8373ad6 (patch) | |
tree | 17741e9494953292e2377773dbaff3845f42583a /test/e2e | |
parent | d178ba1e860b50c5ec5f6dcf5d06d483ecf6c348 (diff) | |
parent | c995b54607a53d692ea2491771233895ff2c75a7 (diff) | |
download | podman-aaa86c68c045519085fe7b174b6adce5f8373ad6.tar.gz podman-aaa86c68c045519085fe7b174b6adce5f8373ad6.tar.bz2 podman-aaa86c68c045519085fe7b174b6adce5f8373ad6.zip |
Merge pull request #9220 from vrothberg/fix-9211
generate kube: handle entrypoint
Diffstat (limited to 'test/e2e')
-rw-r--r-- | test/e2e/generate_kube_test.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go index dba366a1e..bcfab0f68 100644 --- a/test/e2e/generate_kube_test.go +++ b/test/e2e/generate_kube_test.go @@ -1,6 +1,7 @@ package integration import ( + "io/ioutil" "os" "path/filepath" "strconv" @@ -639,4 +640,63 @@ var _ = Describe("Podman generate kube", func() { Expect(pod.Spec.DNSConfig.Options[0].Name).To(Equal("color")) Expect(*pod.Spec.DNSConfig.Options[0].Value).To(Equal("blue")) }) + + It("podman generate kube - set entrypoint as command", func() { + session := podmanTest.Podman([]string{"create", "--pod", "new:testpod", "--entrypoint", "/bin/sleep", ALPINE, "10s"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + kube := podmanTest.Podman([]string{"generate", "kube", "testpod"}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Equal(0)) + + // Now make sure that the container's command is set to the + // entrypoint and it's arguments to "10s". + pod := new(v1.Pod) + err := yaml.Unmarshal(kube.Out.Contents(), pod) + Expect(err).To(BeNil()) + + containers := pod.Spec.Containers + Expect(len(containers)).To(Equal(1)) + + Expect(containers[0].Command).To(Equal([]string{"/bin/sleep"})) + Expect(containers[0].Args).To(Equal([]string{"10s"})) + }) + + It("podman generate kube - use entrypoint from image", func() { + // Build an image with an entrypoint. + containerfile := `FROM quay.io/libpod/alpine:latest +ENTRYPOINT /bin/sleep` + + targetPath, err := CreateTempDirInTempDir() + Expect(err).To(BeNil()) + containerfilePath := filepath.Join(targetPath, "Containerfile") + err = ioutil.WriteFile(containerfilePath, []byte(containerfile), 0644) + Expect(err).To(BeNil()) + + image := "generatekube:test" + session := podmanTest.Podman([]string{"build", "-f", containerfilePath, "-t", image}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"create", "--pod", "new:testpod", image, "10s"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + kube := podmanTest.Podman([]string{"generate", "kube", "testpod"}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Equal(0)) + + // Now make sure that the container's command is set to the + // entrypoint and it's arguments to "10s". + pod := new(v1.Pod) + err = yaml.Unmarshal(kube.Out.Contents(), pod) + Expect(err).To(BeNil()) + + containers := pod.Spec.Containers + Expect(len(containers)).To(Equal(1)) + + Expect(containers[0].Command).To(Equal([]string{"/bin/sh", "-c", "/bin/sleep"})) + Expect(containers[0].Args).To(Equal([]string{"10s"})) + }) }) |