Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tejal29 committed Dec 23, 2020
1 parent 352a73f commit b3069eb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
5 changes: 5 additions & 0 deletions integration/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ type integrationTestConfig struct {
hardlinkBaseImage string
serviceAccount string
dockerMajorVersion int
localRegistry bool
}

const gcrRepoPrefix string = "gcr.io/"

func (config *integrationTestConfig) isGcrRepository() bool {
return strings.HasPrefix(config.imageRepo, gcrRepoPrefix)
}

func (config *integrationTestConfig) buildLocally() bool {
return config.localRegistry
}
13 changes: 8 additions & 5 deletions integration/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"},
Expand All @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion scripts/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
3 changes: 2 additions & 1 deletion scripts/travis-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b3069eb

Please sign in to comment.