mirror of
https://github.com/containers/podman.git
synced 2025-06-01 09:06:44 +08:00
Fix up play kube to use image data
podman play kube was ignoring the imageData.Config Volumes WorkingDir Labels StopSignal Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -764,7 +764,6 @@ func kubeContainerToCreateConfig(ctx context.Context, containerYAML v1.Container
|
||||
containerConfig.ImageID = newImage.ID()
|
||||
containerConfig.Name = containerYAML.Name
|
||||
containerConfig.Tty = containerYAML.TTY
|
||||
containerConfig.WorkDir = containerYAML.WorkingDir
|
||||
|
||||
containerConfig.Pod = podID
|
||||
|
||||
@ -796,6 +795,27 @@ func kubeContainerToCreateConfig(ctx context.Context, containerYAML v1.Container
|
||||
|
||||
containerConfig.StopSignal = 15
|
||||
|
||||
containerConfig.WorkDir = "/"
|
||||
if imageData != nil {
|
||||
// FIXME,
|
||||
// we are currently ignoring imageData.Config.ExposedPorts
|
||||
containerConfig.BuiltinImgVolumes = imageData.Config.Volumes
|
||||
if imageData.Config.WorkingDir != "" {
|
||||
containerConfig.WorkDir = imageData.Config.WorkingDir
|
||||
}
|
||||
containerConfig.Labels = imageData.Config.Labels
|
||||
if imageData.Config.StopSignal != "" {
|
||||
stopSignal, err := util.ParseSignal(imageData.Config.StopSignal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
containerConfig.StopSignal = stopSignal
|
||||
}
|
||||
}
|
||||
|
||||
if containerYAML.WorkingDir != "" {
|
||||
containerConfig.WorkDir = containerYAML.WorkingDir
|
||||
}
|
||||
// If the user does not pass in ID mappings, just set to basics
|
||||
if userConfig.IDMappings == nil {
|
||||
userConfig.IDMappings = &storage.IDMappingOptions{}
|
||||
|
@ -4,6 +4,7 @@ package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
@ -486,4 +487,46 @@ var _ = Describe("Podman generate kube", func() {
|
||||
newBBinspect := inspect.InspectImageJSON()
|
||||
Expect(oldBBinspect[0].Digest).To(Not(Equal(newBBinspect[0].Digest)))
|
||||
})
|
||||
|
||||
It("podman play kube with image data", func() {
|
||||
testyaml := `
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: demo_pod
|
||||
spec:
|
||||
containers:
|
||||
- image: demo
|
||||
name: demo_kube
|
||||
`
|
||||
pull := podmanTest.Podman([]string{"create", "--workdir", "/etc", "--name", "newBB", "--label", "key1=value1", "alpine"})
|
||||
|
||||
pull.WaitWithDefaultTimeout()
|
||||
Expect(pull.ExitCode()).To(BeZero())
|
||||
|
||||
c := podmanTest.Podman([]string{"commit", "-c", "STOPSIGNAL=51", "newBB", "demo"})
|
||||
c.WaitWithDefaultTimeout()
|
||||
Expect(c.ExitCode()).To(Equal(0))
|
||||
|
||||
conffile := filepath.Join(podmanTest.TempDir, "kube.yaml")
|
||||
tempdir, err = CreateTempDirInTempDir()
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
err := ioutil.WriteFile(conffile, []byte(testyaml), 0755)
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
kube := podmanTest.Podman([]string{"play", "kube", conffile})
|
||||
kube.WaitWithDefaultTimeout()
|
||||
Expect(kube.ExitCode()).To(Equal(0))
|
||||
|
||||
inspect := podmanTest.Podman([]string{"inspect", "demo_kube"})
|
||||
inspect.WaitWithDefaultTimeout()
|
||||
Expect(inspect.ExitCode()).To(Equal(0))
|
||||
|
||||
ctr := inspect.InspectContainerToJSON()
|
||||
Expect(ctr[0].Config.WorkingDir).To(ContainSubstring("/etc"))
|
||||
Expect(ctr[0].Config.Labels["key1"]).To(ContainSubstring("value1"))
|
||||
Expect(ctr[0].Config.Labels["key1"]).To(ContainSubstring("value1"))
|
||||
Expect(ctr[0].Config.StopSignal).To(Equal(uint(51)))
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user