Merge pull request #1359 from jkutner/snapshotPathPrefix

Move snapshotPathPrefix into a method
This commit is contained in:
Tejal Desai 2020-07-28 14:49:51 -07:00 committed by GitHub
commit 6c743c0ead
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -33,7 +33,7 @@ import (
)
// For testing
var snapshotPathPrefix = config.KanikoDir
var snapshotPathPrefix = ""
// Snapshotter holds the root directory from which to take snapshots, and a list of snapshots taken
type Snapshotter struct {
@ -119,7 +119,7 @@ func (s *Snapshotter) TakeSnapshot(files []string, shdCheckDelete bool) (string,
// TakeSnapshotFS takes a snapshot of the filesystem, avoiding directories in the ignorelist, and creates
// a tarball of the changed files.
func (s *Snapshotter) TakeSnapshotFS() (string, error) {
f, err := ioutil.TempFile(snapshotPathPrefix, "")
f, err := ioutil.TempFile(s.getSnashotPathPrefix(), "")
if err != nil {
return "", err
}
@ -138,6 +138,13 @@ func (s *Snapshotter) TakeSnapshotFS() (string, error) {
return f.Name(), nil
}
func (s *Snapshotter) getSnashotPathPrefix() string {
if snapshotPathPrefix == "" {
return config.KanikoDir
}
return snapshotPathPrefix
}
func (s *Snapshotter) scanFullFilesystem() ([]string, []string, error) {
logrus.Info("Taking snapshot of full filesystem...")