Compare commits

...

4 Commits

Author SHA1 Message Date
Matt Benson 6d14568eed
Merge a0615c88aa into 236ba5690e 2025-07-16 15:29:21 +02:00
Christophe 236ba5690e
Add archive notice to README (#3502) 2025-06-03 10:36:10 -04:00
Quan Zhang fa67e45814
chore: remove @zhangquan and @jeromeju from maintainer list (#3345) 2025-06-03 10:21:02 -04:00
dadurex a0615c88aa fix: New cleanup when using --cleanup flag (#1406) 2024-04-21 23:13:51 -05:00
4 changed files with 34 additions and 3 deletions

View File

@ -1,2 +0,0 @@
Jerome Ju <jeromeju@google.com>
Quan Zhang <zhangquan@google.com>

View File

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

View File

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

View File

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