diff --git a/pkg/snapshot/snapshot.go b/pkg/snapshot/snapshot.go index e8523d4e3..dfbc49177 100644 --- a/pkg/snapshot/snapshot.go +++ b/pkg/snapshot/snapshot.go @@ -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...")