Add the possibility to ignore files with build and diff ks
If implemented, user will be able to ignore files when using `build kustomization` and `diff kustomization` both with .sourceignore and `ignore-paths` flag. Signed-off-by: Soule BA <bah.soule@gmail.com>
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -71,6 +72,7 @@ type Builder struct {
|
||||
namespace string
|
||||
resourcesPath string
|
||||
kustomizationFile string
|
||||
ignore []string
|
||||
// mu is used to synchronize access to the kustomization file
|
||||
mu sync.Mutex
|
||||
action kustomize.Action
|
||||
@@ -156,6 +158,14 @@ func WithDryRun(dryRun bool) BuilderOptionFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// WithIgnore sets ignore field
|
||||
func WithIgnore(ignore []string) BuilderOptionFunc {
|
||||
return func(b *Builder) error {
|
||||
b.ignore = ignore
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// NewBuilder returns a new Builder
|
||||
// It takes a kustomization name and a path to the resources
|
||||
// It also takes a list of BuilderOptionFunc to configure the builder
|
||||
@@ -326,9 +336,13 @@ func (b *Builder) generate(kustomization kustomizev1.Kustomization, dirPath stri
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
gen := kustomize.NewGeneratorWithIgnore("", "", unstructured.Unstructured{Object: data})
|
||||
|
||||
// acuire the lock
|
||||
// a scanner will be used down the line to parse the list
|
||||
// so we have to make sure to unclude newlines
|
||||
ignoreList := strings.Join(b.ignore, "\n")
|
||||
gen := kustomize.NewGeneratorWithIgnore("", ignoreList, unstructured.Unstructured{Object: data})
|
||||
|
||||
// acquire the lock
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user