onbuild integration test
This commit is contained in:
parent
27f964957b
commit
59a5950e9e
|
|
@ -0,0 +1,6 @@
|
||||||
|
FROM gcr.io/google-appengine/debian9:latest
|
||||||
|
ENV dir /tmp/dir/
|
||||||
|
ONBUILD RUN echo "onbuild" > /tmp/onbuild
|
||||||
|
ONBUILD RUN mkdir $dir
|
||||||
|
ONBUILD RUN echo "onbuild 2" > ${dir}/onbuild2
|
||||||
|
ONBUILD WORKDIR /new/workdir
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
FROM gcr.io/kaniko-test/onbuild-base:latest
|
||||||
|
COPY context/foo foo
|
||||||
|
ENV dir /new/workdir/
|
||||||
|
ONBUILD RUN echo "onbuild" > /tmp/onbuild
|
||||||
|
ONBUILD RUN echo "onbuild 2" > ${dir}
|
||||||
|
ONBUILD WORKDIR /new/workdir
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"Image1": "gcr.io/kaniko-test/docker-test-onbuild:latest",
|
||||||
|
"Image2": "gcr.io/kaniko-test/kaniko-test-onbuild:latest",
|
||||||
|
"DiffType": "File",
|
||||||
|
"Diff": {
|
||||||
|
"Adds": null,
|
||||||
|
"Dels": null,
|
||||||
|
"Mods": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -34,6 +34,7 @@ const (
|
||||||
kanikoTestBucket = "kaniko-test-bucket"
|
kanikoTestBucket = "kaniko-test-bucket"
|
||||||
buildcontextPath = "/workspace/integration_tests"
|
buildcontextPath = "/workspace/integration_tests"
|
||||||
dockerfilesPath = "/workspace/integration_tests/dockerfiles"
|
dockerfilesPath = "/workspace/integration_tests/dockerfiles"
|
||||||
|
onbuildBaseImage = testRepo + "onbuild-base:latest"
|
||||||
)
|
)
|
||||||
|
|
||||||
var fileTests = []struct {
|
var fileTests = []struct {
|
||||||
|
|
@ -102,6 +103,14 @@ var fileTests = []struct {
|
||||||
kanikoContext: buildcontextPath,
|
kanikoContext: buildcontextPath,
|
||||||
repo: "test-add",
|
repo: "test-add",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "test onbuild",
|
||||||
|
dockerfilePath: "/workspace/integration_tests/dockerfiles/Dockerfile_test_onbuild",
|
||||||
|
configPath: "/workspace/integration_tests/dockerfiles/config_test_onbuild.json",
|
||||||
|
dockerContext: buildcontextPath,
|
||||||
|
kanikoContext: buildcontextPath,
|
||||||
|
repo: "test-onbuild",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var structureTests = []struct {
|
var structureTests = []struct {
|
||||||
|
|
@ -182,8 +191,19 @@ func main() {
|
||||||
Name: dockerImage,
|
Name: dockerImage,
|
||||||
Args: []string{"build", "-t", executorImage, "-f", "deploy/Dockerfile", "."},
|
Args: []string{"build", "-t", executorImage, "-f", "deploy/Dockerfile", "."},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build and push onbuild base images
|
||||||
|
buildOnbuildImage := step{
|
||||||
|
Name: dockerImage,
|
||||||
|
Args: []string{"build", "-t", onbuildBaseImage, "-f", "/workspace/integration_tests/dockerfiles/Dockerfile_onbuild_base", "."},
|
||||||
|
}
|
||||||
|
pushOnbuildBase := step{
|
||||||
|
Name: dockerImage,
|
||||||
|
Args: []string{"push", onbuildBaseImage},
|
||||||
|
}
|
||||||
y := testyaml{
|
y := testyaml{
|
||||||
Steps: []step{containerDiffStep, containerDiffPermissions, structureTestsStep, structureTestPermissions, GCSBucketTarBuildContext, uploadTarBuildContext, buildExecutorImage},
|
Steps: []step{containerDiffStep, containerDiffPermissions, structureTestsStep, structureTestPermissions, GCSBucketTarBuildContext, uploadTarBuildContext, buildExecutorImage,
|
||||||
|
buildOnbuildImage, pushOnbuildBase},
|
||||||
}
|
}
|
||||||
for _, test := range fileTests {
|
for _, test := range fileTests {
|
||||||
// First, build the image with docker
|
// First, build the image with docker
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,10 @@ type OnBuildCommand struct {
|
||||||
cmd *instructions.OnbuildCommand
|
cmd *instructions.OnbuildCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ExecuteCommand adds the specified expression in Onbuild to the config
|
||||||
func (o *OnBuildCommand) ExecuteCommand(config *manifest.Schema2Config) error {
|
func (o *OnBuildCommand) ExecuteCommand(config *manifest.Schema2Config) error {
|
||||||
logrus.Info("cmd: ONBUILD")
|
logrus.Info("cmd: ONBUILD")
|
||||||
|
logrus.Infof("args: %s", o.cmd.Expression)
|
||||||
resolvedExpression, err := util.ResolveEnvironmentReplacement(o.cmd.Expression, config.Env, false)
|
resolvedExpression, err := util.ResolveEnvironmentReplacement(o.cmd.Expression, config.Env, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -41,7 +43,7 @@ func (o *OnBuildCommand) ExecuteCommand(config *manifest.Schema2Config) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// No files have changed, this command only touches metadata.
|
// FilesToSnapshot returns that no files have changed, this command only touches metadata.
|
||||||
func (o *OnBuildCommand) FilesToSnapshot() []string {
|
func (o *OnBuildCommand) FilesToSnapshot() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue