From b3069ebda485e8d9f51559614c20661e7690bc64 Mon Sep 17 00:00:00 2001 From: Tejal Desai Date: Tue, 22 Dec 2020 22:34:41 -0800 Subject: [PATCH] fix --- integration/config.go | 5 +++++ integration/images.go | 13 ++++++++----- integration/integration_test.go | 7 +++++++ scripts/integration-test.sh | 2 +- scripts/travis-setup.sh | 3 ++- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/integration/config.go b/integration/config.go index 2a6df72a21..ddc469245e 100644 --- a/integration/config.go +++ b/integration/config.go @@ -25,6 +25,7 @@ type integrationTestConfig struct { hardlinkBaseImage string serviceAccount string dockerMajorVersion int + localRegistry bool } const gcrRepoPrefix string = "gcr.io/" @@ -32,3 +33,7 @@ const gcrRepoPrefix string = "gcr.io/" func (config *integrationTestConfig) isGcrRepository() bool { return strings.HasPrefix(config.imageRepo, gcrRepoPrefix) } + +func (config *integrationTestConfig) buildLocally() bool { + return config.localRegistry +} diff --git a/integration/images.go b/integration/images.go index 36ec390c55..cdb2478866 100644 --- a/integration/images.go +++ b/integration/images.go @@ -33,11 +33,6 @@ import ( ) const ( - // ExecutorImage is the name of the kaniko executor image - ExecutorImage = "executor-image" - //WarmerImage is the name of the kaniko cache warmer image - WarmerImage = "warmer-image" - dockerPrefix = "docker-" kanikoPrefix = "kaniko-" buildContextPath = "/workspace" @@ -63,6 +58,7 @@ var argsMap = map[string][]string{ "Dockerfile_test_multistage": {"file=/foo2"}, } + // Environment to build Dockerfiles with, used for both docker and kaniko builds var envsMap = map[string][]string{ "Dockerfile_test_arg_secret": {"SSH_PRIVATE_KEY=ThEPriv4t3Key"}, @@ -88,6 +84,13 @@ var outputChecks = map[string]func(string, []byte) error{ "Dockerfile_test_arg_secret": checkArgsNotPrinted, } +var ( + // ExecutorImage is the name of the kaniko executor image + ExecutorImage = "executor-image" + //WarmerImage is the name of the kaniko cache warmer image + WarmerImage = "warmer-image" +) + // Checks if argument are not printed in output. // Argument may be passed through --build-arg key=value manner or --build-arg key with key in environment func checkArgsNotPrinted(dockerfile string, out []byte) error { diff --git a/integration/integration_test.go b/integration/integration_test.go index 2909fc5c09..8b060f0a71 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -109,6 +109,11 @@ func launchTests(m *testing.M) (int, error) { imageBuilder = NewDockerFileBuilder() + if config.localRegistry { + ExecutorImage = "localhost:5000/executor-image" + WarmerImage = "localhost:5000/warmer-image" + } + return m.Run(), nil } @@ -711,6 +716,8 @@ func initIntegrationTestConfig() *integrationTestConfig { flag.StringVar(&c.gcsBucket, "bucket", "gs://kaniko-test-bucket", "The gcs bucket argument to uploaded the tar-ed contents of the `integration` dir to.") flag.StringVar(&c.imageRepo, "repo", "gcr.io/kaniko-test", "The (docker) image repo to build and push images to during the test. `gcloud` must be authenticated with this repo or serviceAccount must be set.") flag.StringVar(&c.serviceAccount, "serviceAccount", "", "The path to the service account push images to GCR and upload/download files to GCS.") + flag.BoolVar(&c.localRegistry, "localRegistry", false, "Build setup images against local registry") + flag.Parse() if len(c.serviceAccount) > 0 { diff --git a/scripts/integration-test.sh b/scripts/integration-test.sh index 07ac75bdb4..26e8c2ae89 100755 --- a/scripts/integration-test.sh +++ b/scripts/integration-test.sh @@ -24,4 +24,4 @@ docker version echo "Running integration tests..." make out/executor make out/warmer -go test ./integration/... -v --bucket "${GCS_BUCKET}" --repo "${IMAGE_REPO}" --timeout 50m "$@" +go test ./integration/... -v --bucket "${GCS_BUCKET}" --repo "${IMAGE_REPO}" --localRegistry true --timeout 50m "$@" diff --git a/scripts/travis-setup.sh b/scripts/travis-setup.sh index f335b4aafa..6ccb2c9869 100755 --- a/scripts/travis-setup.sh +++ b/scripts/travis-setup.sh @@ -28,7 +28,8 @@ mkdir -vp ~/.docker/cli-plugins/ curl --silent -L "https://github.com/docker/buildx/releases/download/v0.3.0/buildx-v0.3.0.linux-amd64" > ~/.docker/cli-plugins/docker-buildx chmod a+x ~/.docker/cli-plugins/docker-buildx docker buildx version -# This has to be set otherwise the default driver will not work + +# This has to be set otherwise the default driver will not work to push to local registry docker buildx create --use --name build --node build --driver-opt network=host docker run -d -p 5000:5000 --restart always --name registry registry:2.6.2