Merge pull request #78 from priyawadhwa/trigger

kaniko build trigger
This commit is contained in:
priyawadhwa 2018-04-16 10:21:21 -07:00 committed by GitHub
commit 0ddc2115a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,25 @@
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/kaniko-project/executor:latest"
args: ["--dockerfile=/workspace/deploy/Dockerfile",
"--context=/workspace/go/src/github.com/GoogleCloudPlatform/kaniko/",
"--destination=gcr.io/kaniko-project/executor:${COMMIT_SHA}"]

View File

@ -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"

View File

@ -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.Lstat(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)
}

View File

@ -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) {