mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-21 01:20:55 +02:00
Added env unit test, updated env integration test, fixed env
This commit is contained in:
@@ -1,5 +1,15 @@
|
||||
FROM gcr.io/distroless/base
|
||||
FROM gcr.io/google-appengine/debian9
|
||||
ENV hey hey
|
||||
ENV PATH /usr/local
|
||||
ENV hey hello
|
||||
ENV first=foo second=foo2
|
||||
ENV third $second:/third
|
||||
ENV myName="John Doe" myDog=Rex\ The\ Dog \
|
||||
myCat=fluffy
|
||||
ENV PATH something
|
||||
ENV test=value\ value2
|
||||
ENV test1="a'b'c"
|
||||
ENV test2='a"b"c'
|
||||
ENV test3=a\ b name2=b\ c
|
||||
ENV test4="a\"b"
|
||||
ENV test5='a\"b'
|
||||
|
||||
@@ -4,8 +4,30 @@ metadataTest:
|
||||
- key: hey
|
||||
value: hello
|
||||
- key: PATH
|
||||
value: /usr/local
|
||||
value: something
|
||||
- key: first
|
||||
value: foo
|
||||
- key: second
|
||||
value: foo2
|
||||
- key: third
|
||||
value: foo2:/third
|
||||
- key: myName
|
||||
value: John Doe
|
||||
- key: myDog
|
||||
value: Rex The Dog
|
||||
- key: myCat
|
||||
value: fluffy
|
||||
- key: test
|
||||
value: value value2
|
||||
- key: test1
|
||||
value: a'b'c
|
||||
- key: test2
|
||||
value: a"b"c
|
||||
- key: test3
|
||||
value: a b
|
||||
- key: name2
|
||||
value: b c
|
||||
- key: test4
|
||||
value: a"b
|
||||
- key: test5
|
||||
value: a\"b
|
||||
|
||||
@@ -55,12 +55,14 @@ var structureTests = []struct {
|
||||
description string
|
||||
dockerfilePath string
|
||||
structureTestYamlPath string
|
||||
dockerBuildContext string
|
||||
repo string
|
||||
}{
|
||||
{
|
||||
description: "test env",
|
||||
dockerfilePath: "/workspace/integration_tests/dockerfiles/Dockerfile_test_env",
|
||||
repo: "test-env",
|
||||
description: "test env",
|
||||
dockerfilePath: "/workspace/integration_tests/dockerfiles/Dockerfile_test_env",
|
||||
repo: "test-env",
|
||||
dockerBuildContext: "/workspace/integration_tests/dockerfiles/",
|
||||
structureTestYamlPath: "/workspace/integration_tests/dockerfiles/test_env.yaml",
|
||||
},
|
||||
}
|
||||
@@ -156,6 +158,14 @@ func main() {
|
||||
}
|
||||
|
||||
for _, test := range structureTests {
|
||||
|
||||
// First, build the image with docker
|
||||
dockerImageTag := testRepo + dockerPrefix + test.repo
|
||||
dockerBuild := step{
|
||||
Name: dockerImage,
|
||||
Args: []string{"build", "-t", dockerImageTag, "-f", test.dockerfilePath, test.dockerBuildContext},
|
||||
}
|
||||
|
||||
// Build the image with kbuild
|
||||
kbuildImage := testRepo + kbuildPrefix + test.repo
|
||||
kbuild := step{
|
||||
@@ -167,15 +177,21 @@ func main() {
|
||||
Name: dockerImage,
|
||||
Args: []string{"pull", kbuildImage},
|
||||
}
|
||||
// Run structure tests on the image
|
||||
// Run structure tests on the kbuild and docker image
|
||||
args := "container-structure-test -image " + kbuildImage + " " + test.structureTestYamlPath
|
||||
structureTest := step{
|
||||
Name: ubuntuImage,
|
||||
Args: []string{"sh", "-c", args},
|
||||
Env: []string{"PATH=/workspace:/bin"},
|
||||
}
|
||||
args = "container-structure-test -image " + dockerImageTag + " " + test.structureTestYamlPath
|
||||
dockerStructureTest := step{
|
||||
Name: ubuntuImage,
|
||||
Args: []string{"sh", "-c", args},
|
||||
Env: []string{"PATH=/workspace:/bin"},
|
||||
}
|
||||
|
||||
y.Steps = append(y.Steps, kbuild, pullKbuildImage, structureTest)
|
||||
y.Steps = append(y.Steps, dockerBuild, kbuild, pullKbuildImage, structureTest, dockerStructureTest)
|
||||
}
|
||||
|
||||
d, _ := yaml.Marshal(&y)
|
||||
|
||||
Reference in New Issue
Block a user