From 50ef6fe9c10e361800caff7e96d0544fdd3c6983 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Thu, 12 Apr 2018 15:17:08 -0700 Subject: [PATCH 1/2] Build trigger for building kaniko executor image --- deploy/executor-release.yaml | 32 ++++++++++++++++++++++++++++++++ pkg/constants/constants.go | 3 +++ pkg/snapshot/snapshot.go | 5 +++++ pkg/util/fs_util.go | 3 +++ 4 files changed, 43 insertions(+) create mode 100644 deploy/executor-release.yaml diff --git a/deploy/executor-release.yaml b/deploy/executor-release.yaml new file mode 100644 index 000000000..ba4a42c77 --- /dev/null +++ b/deploy/executor-release.yaml @@ -0,0 +1,32 @@ +steps: + # First, install make + - name: "gcr.io/google-appengine/debian9" + args: ["sh", "-c", "apt-get update && apt-get install -y make"] + volumes: + - name: "make" + path: "/usr/bin" + - name: "gcr.io/google-appengine/debian9" + args: ["sh", "-c", "cp -r . /kaniko/ && mkdir -p /workspace/go/src/github.com/GoogleCloudPlatform/ && cp -r /kaniko/ /workspace/go/src/github.com/GoogleCloudPlatform/"] + volumes: + - name: "make" + path: "/usr/bin" + # Then, build the binary + - name: "gcr.io/google-appengine/golang" + args: ["sh", "-c", "make"] + volumes: + - name: "make" + path: "/usr/bin" + dir: go/src/github.com/GoogleCloudPlatform/kaniko + env: ["GOPATH=/workspace/go/"] + # Then, build kaniko with kaniko + - name: "gcr.io/priya-wadhwa/executor:latest" + args: ["--dockerfile=/workspace/deploy/Dockerfile", + "--context=/workspace/go/src/github.com/GoogleCloudPlatform/kaniko/", + "--destination=gcr.io/priya-wadhwa/executor:${COMMIT_SHA}"] + # Pull the image down + - name: "gcr.io/cloud-builders/docker" + args: ["pull", "gcr.io/priya-wadhwa/executor:${COMMIT_SHA}"] + # And tag it to latest + - name: "gcr.io/cloud-builders/docker" + args: ["tag", "gcr.io/priya-wadhwa/executor:${COMMIT_SHA}", "gcr.io/priya-wadhwa/executor:latest"] +images: ["gcr.io/priya-wadhwa/executor:latest"] \ No newline at end of file diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index a98dee17a..93bb37e0d 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -29,6 +29,9 @@ const ( //KanikoDir is the path to the Kaniko directory KanikoDir = "/kaniko" + // KanikoExecutor is the path to the kaniko executor + KanikoExecutor = "/kaniko/executor" + WhitelistPath = "/proc/self/mountinfo" Author = "kaniko" diff --git a/pkg/snapshot/snapshot.go b/pkg/snapshot/snapshot.go index c75bf4296..32ad40add 100644 --- a/pkg/snapshot/snapshot.go +++ b/pkg/snapshot/snapshot.go @@ -81,6 +81,7 @@ func (s *Snapshotter) TakeSnapshotOfFiles(files []string) ([]byte, error) { buf := bytes.NewBuffer([]byte{}) w := tar.NewWriter(buf) defer w.Close() + filesAdded := false for _, file := range files { info, err := os.Stat(file) if err != nil { @@ -96,9 +97,13 @@ func (s *Snapshotter) TakeSnapshotOfFiles(files []string) ([]byte, error) { return nil, err } if maybeAdd { + filesAdded = true util.AddToTar(file, info, w) } } + if !filesAdded { + return nil, nil + } return ioutil.ReadAll(buf) } diff --git a/pkg/util/fs_util.go b/pkg/util/fs_util.go index df03a4266..88d33b3ff 100644 --- a/pkg/util/fs_util.go +++ b/pkg/util/fs_util.go @@ -57,6 +57,9 @@ func ExtractFileSystemFromImage(img string) error { // PathInWhitelist returns true if the path is whitelisted func PathInWhitelist(path, directory string) bool { + if path == constants.KanikoExecutor { + return false + } for _, d := range whitelist { dirPath := filepath.Join(directory, d) if pkgutil.HasFilepathPrefix(path, dirPath) { From 954b1382d2f798dae7710898f51b8dccbebc2045 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Thu, 12 Apr 2018 15:30:32 -0700 Subject: [PATCH 2/2] change k8s to kaniko --- .travis.yml | 2 +- Makefile | 2 +- executor/cmd/root.go | 12 ++++++------ executor/main.go | 2 +- hack/dep.sh | 2 +- kaniko/main.go | 2 +- pkg/commands/add.go | 2 +- pkg/commands/cmd_test.go | 2 +- pkg/commands/copy.go | 2 +- pkg/commands/entrypoint_test.go | 2 +- pkg/commands/env.go | 2 +- pkg/commands/env_test.go | 2 +- pkg/commands/expose.go | 2 +- pkg/commands/expose_test.go | 2 +- pkg/commands/label.go | 2 +- pkg/commands/label_test.go | 2 +- pkg/commands/onbuild.go | 2 +- pkg/commands/onbuild_test.go | 2 +- pkg/commands/user.go | 2 +- pkg/commands/user_test.go | 2 +- pkg/commands/volume.go | 2 +- pkg/commands/volume_test.go | 2 +- pkg/commands/workdir.go | 2 +- pkg/commands/workdir_test.go | 2 +- pkg/image/image.go | 2 +- pkg/snapshot/snapshot.go | 2 +- pkg/snapshot/snapshot_test.go | 4 ++-- pkg/util/bucket_util.go | 2 +- pkg/util/command_util_test.go | 2 +- pkg/util/fs_util.go | 2 +- pkg/util/fs_util_test.go | 2 +- pkg/util/tar_util_test.go | 2 +- 32 files changed, 38 insertions(+), 38 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2315db814..8505a0fc1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ os: linux go: - 1.9.x -go_import_path: github.com/GoogleCloudPlatform/k8s-container-builder +go_import_path: github.com/GoogleCloudPlatform/kaniko script: - make test diff --git a/Makefile b/Makefile index 7e4e8abf3..7f6ecfa71 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ VERSION ?= v$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_BUILD) GOOS ?= $(shell go env GOOS) GOARCH = amd64 ORG := github.com/GoogleCloudPlatform -PROJECT := k8s-container-builder +PROJECT := kaniko REGISTRY?=gcr.io/kaniko-project REPOPATH ?= $(ORG)/$(PROJECT) diff --git a/executor/cmd/root.go b/executor/cmd/root.go index 14a1c68e8..4f29c62f1 100644 --- a/executor/cmd/root.go +++ b/executor/cmd/root.go @@ -18,12 +18,12 @@ package cmd import ( "fmt" - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/commands" - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/constants" - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/dockerfile" - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/image" - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/snapshot" - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/util" + "github.com/GoogleCloudPlatform/kaniko/pkg/commands" + "github.com/GoogleCloudPlatform/kaniko/pkg/constants" + "github.com/GoogleCloudPlatform/kaniko/pkg/dockerfile" + "github.com/GoogleCloudPlatform/kaniko/pkg/image" + "github.com/GoogleCloudPlatform/kaniko/pkg/snapshot" + "github.com/GoogleCloudPlatform/kaniko/pkg/util" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/pkg/errors" diff --git a/executor/main.go b/executor/main.go index 61e3a6cef..7d4ed407c 100644 --- a/executor/main.go +++ b/executor/main.go @@ -18,7 +18,7 @@ package main import ( "fmt" - "github.com/GoogleCloudPlatform/k8s-container-builder/executor/cmd" + "github.com/GoogleCloudPlatform/kaniko/executor/cmd" "os" ) diff --git a/hack/dep.sh b/hack/dep.sh index 487d7ee07..e9f4b723e 100755 --- a/hack/dep.sh +++ b/hack/dep.sh @@ -31,7 +31,7 @@ install_dep() { } if [ -z "$VALIDATE_UPSTREAM" ]; then - VALIDATE_REPO='git@github.com:GoogleCloudPlatform/k8s-container-builder.git' + VALIDATE_REPO='git@github.com:GoogleCloudPlatform/kaniko.git' VALIDATE_BRANCH='master' VALIDATE_HEAD="$(git rev-parse --verify HEAD)" diff --git a/kaniko/main.go b/kaniko/main.go index ba8a61643..81a8e08b6 100644 --- a/kaniko/main.go +++ b/kaniko/main.go @@ -18,7 +18,7 @@ package main import ( "fmt" - "github.com/GoogleCloudPlatform/k8s-container-builder/kaniko/cmd" + "github.com/GoogleCloudPlatform/kaniko/kaniko/cmd" "os" ) diff --git a/pkg/commands/add.go b/pkg/commands/add.go index 524018c72..7338e773c 100644 --- a/pkg/commands/add.go +++ b/pkg/commands/add.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/util" + "github.com/GoogleCloudPlatform/kaniko/pkg/util" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/sirupsen/logrus" diff --git a/pkg/commands/cmd_test.go b/pkg/commands/cmd_test.go index 3a966da11..7cac2754b 100644 --- a/pkg/commands/cmd_test.go +++ b/pkg/commands/cmd_test.go @@ -16,7 +16,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/testutil" + "github.com/GoogleCloudPlatform/kaniko/testutil" "github.com/containers/image/manifest" "github.com/containers/image/pkg/strslice" "github.com/docker/docker/builder/dockerfile/instructions" diff --git a/pkg/commands/copy.go b/pkg/commands/copy.go index e9f8cab59..93c7f96fa 100644 --- a/pkg/commands/copy.go +++ b/pkg/commands/copy.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/util" + "github.com/GoogleCloudPlatform/kaniko/pkg/util" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/sirupsen/logrus" diff --git a/pkg/commands/entrypoint_test.go b/pkg/commands/entrypoint_test.go index 0835de07e..a718260f5 100644 --- a/pkg/commands/entrypoint_test.go +++ b/pkg/commands/entrypoint_test.go @@ -16,7 +16,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/testutil" + "github.com/GoogleCloudPlatform/kaniko/testutil" "github.com/containers/image/manifest" "github.com/containers/image/pkg/strslice" "github.com/docker/docker/builder/dockerfile/instructions" diff --git a/pkg/commands/env.go b/pkg/commands/env.go index 94e1edabe..6a3153ba8 100644 --- a/pkg/commands/env.go +++ b/pkg/commands/env.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/util" + "github.com/GoogleCloudPlatform/kaniko/pkg/util" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/sirupsen/logrus" diff --git a/pkg/commands/env_test.go b/pkg/commands/env_test.go index 5aedcff02..b7abe4732 100644 --- a/pkg/commands/env_test.go +++ b/pkg/commands/env_test.go @@ -16,7 +16,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/testutil" + "github.com/GoogleCloudPlatform/kaniko/testutil" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "testing" diff --git a/pkg/commands/expose.go b/pkg/commands/expose.go index fc9d6fe75..293ef541c 100644 --- a/pkg/commands/expose.go +++ b/pkg/commands/expose.go @@ -18,7 +18,7 @@ package commands import ( "fmt" - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/util" + "github.com/GoogleCloudPlatform/kaniko/pkg/util" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/sirupsen/logrus" diff --git a/pkg/commands/expose_test.go b/pkg/commands/expose_test.go index ad23cca25..7a196c442 100644 --- a/pkg/commands/expose_test.go +++ b/pkg/commands/expose_test.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/testutil" + "github.com/GoogleCloudPlatform/kaniko/testutil" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "testing" diff --git a/pkg/commands/label.go b/pkg/commands/label.go index 81b9bab56..a9c42455a 100644 --- a/pkg/commands/label.go +++ b/pkg/commands/label.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/util" + "github.com/GoogleCloudPlatform/kaniko/pkg/util" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/sirupsen/logrus" diff --git a/pkg/commands/label_test.go b/pkg/commands/label_test.go index f997611c3..13f36b80e 100644 --- a/pkg/commands/label_test.go +++ b/pkg/commands/label_test.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/testutil" + "github.com/GoogleCloudPlatform/kaniko/testutil" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "testing" diff --git a/pkg/commands/onbuild.go b/pkg/commands/onbuild.go index db4711604..630b119d4 100644 --- a/pkg/commands/onbuild.go +++ b/pkg/commands/onbuild.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/util" + "github.com/GoogleCloudPlatform/kaniko/pkg/util" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/sirupsen/logrus" diff --git a/pkg/commands/onbuild_test.go b/pkg/commands/onbuild_test.go index 3004e99c9..cdb6d7a48 100644 --- a/pkg/commands/onbuild_test.go +++ b/pkg/commands/onbuild_test.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/testutil" + "github.com/GoogleCloudPlatform/kaniko/testutil" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "testing" diff --git a/pkg/commands/user.go b/pkg/commands/user.go index d2e4cff61..bff51c3b5 100644 --- a/pkg/commands/user.go +++ b/pkg/commands/user.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/util" + "github.com/GoogleCloudPlatform/kaniko/pkg/util" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/sirupsen/logrus" diff --git a/pkg/commands/user_test.go b/pkg/commands/user_test.go index c1ebe0ab2..6758e1ca8 100644 --- a/pkg/commands/user_test.go +++ b/pkg/commands/user_test.go @@ -16,7 +16,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/testutil" + "github.com/GoogleCloudPlatform/kaniko/testutil" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "testing" diff --git a/pkg/commands/volume.go b/pkg/commands/volume.go index d5fd8ad05..762044b77 100644 --- a/pkg/commands/volume.go +++ b/pkg/commands/volume.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/util" + "github.com/GoogleCloudPlatform/kaniko/pkg/util" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/sirupsen/logrus" diff --git a/pkg/commands/volume_test.go b/pkg/commands/volume_test.go index 69bd5b9c4..f909d565f 100644 --- a/pkg/commands/volume_test.go +++ b/pkg/commands/volume_test.go @@ -16,7 +16,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/testutil" + "github.com/GoogleCloudPlatform/kaniko/testutil" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "testing" diff --git a/pkg/commands/workdir.go b/pkg/commands/workdir.go index f249608ac..9575abdac 100644 --- a/pkg/commands/workdir.go +++ b/pkg/commands/workdir.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/util" + "github.com/GoogleCloudPlatform/kaniko/pkg/util" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/sirupsen/logrus" diff --git a/pkg/commands/workdir_test.go b/pkg/commands/workdir_test.go index 439d77fd5..faf525ca0 100644 --- a/pkg/commands/workdir_test.go +++ b/pkg/commands/workdir_test.go @@ -16,7 +16,7 @@ limitations under the License. package commands import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/testutil" + "github.com/GoogleCloudPlatform/kaniko/testutil" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "testing" diff --git a/pkg/image/image.go b/pkg/image/image.go index 4b9354abe..672cc802c 100644 --- a/pkg/image/image.go +++ b/pkg/image/image.go @@ -18,7 +18,7 @@ package image import ( img "github.com/GoogleCloudPlatform/container-diff/pkg/image" - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/constants" + "github.com/GoogleCloudPlatform/kaniko/pkg/constants" "github.com/containers/image/copy" "github.com/containers/image/docker" "github.com/containers/image/signature" diff --git a/pkg/snapshot/snapshot.go b/pkg/snapshot/snapshot.go index 32ad40add..0956a3612 100644 --- a/pkg/snapshot/snapshot.go +++ b/pkg/snapshot/snapshot.go @@ -19,7 +19,7 @@ package snapshot import ( "archive/tar" "bytes" - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/util" + "github.com/GoogleCloudPlatform/kaniko/pkg/util" "github.com/sirupsen/logrus" "io" diff --git a/pkg/snapshot/snapshot_test.go b/pkg/snapshot/snapshot_test.go index 040669abe..c3f66110f 100644 --- a/pkg/snapshot/snapshot_test.go +++ b/pkg/snapshot/snapshot_test.go @@ -18,8 +18,8 @@ package snapshot import ( "archive/tar" "bytes" - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/util" - "github.com/GoogleCloudPlatform/k8s-container-builder/testutil" + "github.com/GoogleCloudPlatform/kaniko/pkg/util" + "github.com/GoogleCloudPlatform/kaniko/testutil" "github.com/pkg/errors" "io" "io/ioutil" diff --git a/pkg/util/bucket_util.go b/pkg/util/bucket_util.go index 043c2890f..5ccea6da9 100644 --- a/pkg/util/bucket_util.go +++ b/pkg/util/bucket_util.go @@ -18,7 +18,7 @@ package util import ( "cloud.google.com/go/storage" - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/constants" + "github.com/GoogleCloudPlatform/kaniko/pkg/constants" "github.com/sirupsen/logrus" "golang.org/x/net/context" "os" diff --git a/pkg/util/command_util_test.go b/pkg/util/command_util_test.go index afd359d30..9650036a4 100644 --- a/pkg/util/command_util_test.go +++ b/pkg/util/command_util_test.go @@ -17,7 +17,7 @@ limitations under the License. package util import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/testutil" + "github.com/GoogleCloudPlatform/kaniko/testutil" "sort" "testing" ) diff --git a/pkg/util/fs_util.go b/pkg/util/fs_util.go index 88d33b3ff..ea1a763c5 100644 --- a/pkg/util/fs_util.go +++ b/pkg/util/fs_util.go @@ -19,7 +19,7 @@ package util import ( "bufio" pkgutil "github.com/GoogleCloudPlatform/container-diff/pkg/util" - "github.com/GoogleCloudPlatform/k8s-container-builder/pkg/constants" + "github.com/GoogleCloudPlatform/kaniko/pkg/constants" "github.com/containers/image/docker" "github.com/sirupsen/logrus" "io" diff --git a/pkg/util/fs_util_test.go b/pkg/util/fs_util_test.go index 19bef1d9b..39666c3cc 100644 --- a/pkg/util/fs_util_test.go +++ b/pkg/util/fs_util_test.go @@ -17,7 +17,7 @@ limitations under the License. package util import ( - "github.com/GoogleCloudPlatform/k8s-container-builder/testutil" + "github.com/GoogleCloudPlatform/kaniko/testutil" "io/ioutil" "os" "path/filepath" diff --git a/pkg/util/tar_util_test.go b/pkg/util/tar_util_test.go index 9974f6c21..356fb4c1c 100644 --- a/pkg/util/tar_util_test.go +++ b/pkg/util/tar_util_test.go @@ -19,7 +19,7 @@ package util import ( "archive/tar" "compress/gzip" - "github.com/GoogleCloudPlatform/k8s-container-builder/testutil" + "github.com/GoogleCloudPlatform/kaniko/testutil" "io" "io/ioutil" "os"