From 0a0b4f1583e07f80fe59257187630b1bd980f700 Mon Sep 17 00:00:00 2001 From: Joe Kutner Date: Tue, 25 Aug 2020 16:49:48 -0500 Subject: [PATCH] Add func to append to ignorelist. This allows those using Kaniko as a library to add ignored dirs and files without needs to modify /proc/self/mountinfo or doing other strange things with mount -t tmpfs --- pkg/util/fs_util.go | 4 ++++ pkg/util/fs_util_test.go | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/pkg/util/fs_util.go b/pkg/util/fs_util.go index 88348bfec3..694e3e7390 100644 --- a/pkg/util/fs_util.go +++ b/pkg/util/fs_util.go @@ -90,6 +90,10 @@ func IgnoreList() []IgnoreListEntry { return ignorelist } +func AddToIgnoreList(entry IgnoreListEntry) { + ignorelist = append(ignorelist, entry) +} + func IncludeWhiteout() FSOpt { return func(opts *FSConfig) { opts.includeWhiteout = true diff --git a/pkg/util/fs_util_test.go b/pkg/util/fs_util_test.go index df49581424..5901c484a0 100644 --- a/pkg/util/fs_util_test.go +++ b/pkg/util/fs_util_test.go @@ -78,6 +78,17 @@ func Test_DetectFilesystemSkiplist(t *testing.T) { testutil.CheckErrorAndDeepEqual(t, false, err, expectedSkiplist, actualSkiplist) } +func Test_AddToIgnoreList(t *testing.T) { + AddToIgnoreList(IgnoreListEntry{ + Path: "/tmp", + PrefixMatchOnly: false, + }) + + if !CheckIgnoreList("/tmp") { + t.Errorf("CheckIgnoreList() = %v, want %v", false, true) + } +} + var tests = []struct { files map[string]string directory string