Merge pull request #3138 from weirdwiz/env-var

Minor fix splitting env vars in podman-commit
This commit is contained in:
OpenShift Merge Robot 2019-05-19 06:31:25 +02:00 committed by GitHub
commit ce84c3afdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -99,7 +99,7 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai
// Should we store the ENV we actually want in the spec separately?
if c.config.Spec.Process != nil {
for _, e := range c.config.Spec.Process.Env {
splitEnv := strings.Split(e, "=")
splitEnv := strings.SplitN(e, "=", 2)
importBuilder.SetEnv(splitEnv[0], splitEnv[1])
}
}

View File

@ -194,4 +194,24 @@ var _ = Describe("Podman commit", func() {
Expect(r.ExitCode()).To(Equal(0))
})
It("podman commit container check env variables", func() {
s := podmanTest.Podman([]string{"run", "--name", "test1", "-e", "TEST=1=1-01=9.01", "-it", "alpine", "true"})
s.WaitWithDefaultTimeout()
Expect(s.ExitCode()).To(Equal(0))
c := podmanTest.Podman([]string{"commit", "test1", "newimage"})
c.WaitWithDefaultTimeout()
Expect(c.ExitCode()).To(Equal(0))
inspect := podmanTest.Podman([]string{"inspect", "newimage"})
inspect.WaitWithDefaultTimeout()
Expect(inspect.ExitCode()).To(Equal(0))
image := inspect.InspectImageJSON()
envMap := make(map[string]bool)
for _, v := range image[0].Config.Env {
envMap[v] = true
}
Expect(envMap["TEST=1=1-01=9.01"]).To(BeTrue())
})
})