Compare commits
4 Commits
84333d6d05
...
6d14568eed
| Author | SHA1 | Date |
|---|---|---|
|
|
6d14568eed | |
|
|
236ba5690e | |
|
|
fa67e45814 | |
|
|
a0615c88aa |
|
|
@ -1,2 +0,0 @@
|
|||
Jerome Ju <jeromeju@google.com>
|
||||
Quan Zhang <zhangquan@google.com>
|
||||
|
|
@ -1,3 +1,11 @@
|
|||
# 🧊 This project is archived and no longer developed or maintained. 🧊
|
||||
|
||||
The code remains available for historic purposes.
|
||||
|
||||
The README as of the archival date remains unchanged below for historic purposes.
|
||||
|
||||
-----
|
||||
|
||||
# kaniko - Build Images In Kubernetes
|
||||
|
||||
## 🚨NOTE: kaniko is not an officially supported Google product🚨
|
||||
|
|
|
|||
|
|
@ -787,7 +787,7 @@ func DoBuild(opts *config.KanikoOptions) (v1.Image, error) {
|
|||
}
|
||||
}
|
||||
if opts.Cleanup {
|
||||
if err = util.DeleteFilesystem(); err != nil {
|
||||
if err = util.CleanupFilesystem(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
|
@ -229,6 +230,30 @@ func GetFSFromLayers(root string, layers []v1.Layer, opts ...FSOpt) ([]string, e
|
|||
return extractedFiles, nil
|
||||
}
|
||||
|
||||
// CleanupFilesystem deletes the extracted image file system, snapshots and stage dependent files
|
||||
func CleanupFilesystem() error {
|
||||
DeleteFilesystem()
|
||||
logrus.Info("Deleting snapshots and layer dependet files...")
|
||||
numericPattern := regexp.MustCompile(`^\d+$`)
|
||||
return filepath.Walk(config.KanikoDir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
// ignore errors when deleting.
|
||||
return nil //nolint:nilerr
|
||||
}
|
||||
|
||||
if numericPattern.MatchString(info.Name()) && isExist(path) {
|
||||
err := os.RemoveAll(path)
|
||||
if err != nil {
|
||||
logrus.Debugf("Error deleting path: %s\n", path)
|
||||
return nil //nolint:nilerr
|
||||
}
|
||||
logrus.Debugf("Deleted path: %s\n", path)
|
||||
}
|
||||
|
||||
return nil //nolint:nilerr
|
||||
})
|
||||
}
|
||||
|
||||
// DeleteFilesystem deletes the extracted image file system
|
||||
func DeleteFilesystem() error {
|
||||
logrus.Info("Deleting filesystem...")
|
||||
|
|
|
|||
Loading…
Reference in New Issue