Merge branch 'master' into snapshot-directories

This commit is contained in:
Gilbert Gilb's
2020-03-31 14:25:04 +02:00
15 changed files with 379 additions and 80 deletions
+3 -3
View File
@@ -28,14 +28,14 @@ import (
"github.com/GoogleContainerTools/kaniko/pkg/timing"
"github.com/karrick/godirwalk"
"github.com/GoogleContainerTools/kaniko/pkg/constants"
"github.com/GoogleContainerTools/kaniko/pkg/config"
"github.com/GoogleContainerTools/kaniko/pkg/util"
"github.com/sirupsen/logrus"
)
// For testing
var snapshotPathPrefix = constants.KanikoDir
var snapshotPathPrefix = config.KanikoDir
// Snapshotter holds the root directory from which to take snapshots, and a list of snapshots taken
type Snapshotter struct {
@@ -63,7 +63,7 @@ func (s *Snapshotter) Key() (string, error) {
// TakeSnapshot takes a snapshot of the specified files, avoiding directories in the whitelist, and creates
// a tarball of the changed files. Return contents of the tarball, and whether or not any files were changed
func (s *Snapshotter) TakeSnapshot(files []string) (string, error) {
f, err := ioutil.TempFile(snapshotPathPrefix, "")
f, err := ioutil.TempFile(config.KanikoDir, "")
if err != nil {
return "", err
}
+4 -1
View File
@@ -25,6 +25,7 @@ import (
"strings"
"testing"
"github.com/GoogleContainerTools/kaniko/pkg/config"
"github.com/GoogleContainerTools/kaniko/pkg/util"
"github.com/GoogleContainerTools/kaniko/testutil"
"github.com/pkg/errors"
@@ -174,7 +175,6 @@ func TestSnapshotFSChangePermissions(t *testing.T) {
if err == io.EOF {
break
}
t.Logf("Info %s in tar", hdr.Name)
foundFiles = append(foundFiles, hdr.Name)
if _, isFile := snapshotFiles[hdr.Name]; !isFile {
t.Fatalf("File %s unexpectedly in tar", hdr.Name)
@@ -478,8 +478,11 @@ func setUpTest() (string, *Snapshotter, func(), error) {
return "", nil, nil, errors.Wrap(err, "initializing snapshotter")
}
original := config.KanikoDir
config.KanikoDir = testDir
cleanup := func() {
os.RemoveAll(snapshotPath)
config.KanikoDir = original
dirCleanUp()
}