mirror of https://github.com/k3s-io/k3s
Skip any file with no yaml yml or json suffix
parent
334efc743b
commit
c42ea5ec89
|
@ -109,12 +109,11 @@ func (w *watcher) listFilesIn(base string, force bool) error {
|
||||||
if strings.HasSuffix(file.Name(), ".skip") {
|
if strings.HasSuffix(file.Name(), ".skip") {
|
||||||
skips[strings.TrimSuffix(file.Name(), ".skip")] = true
|
skips[strings.TrimSuffix(file.Name(), ".skip")] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var errs []error
|
var errs []error
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if strings.HasSuffix(file.Name(), ".skip") || skips[file.Name()] {
|
if skipFile(file.Name(), skips) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
p := filepath.Join(base, file.Name())
|
p := filepath.Join(base, file.Name())
|
||||||
|
@ -305,3 +304,20 @@ func toObjects(bytes []byte) ([]runtime.Object, error) {
|
||||||
|
|
||||||
return []runtime.Object{obj}, nil
|
return []runtime.Object{obj}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func skipFile(fileName string, skips map[string]bool) bool {
|
||||||
|
switch {
|
||||||
|
case strings.HasPrefix(fileName, "."):
|
||||||
|
return true
|
||||||
|
case skips[fileName]:
|
||||||
|
return true
|
||||||
|
case strings.HasSuffix(fileName, ".json"):
|
||||||
|
return false
|
||||||
|
case strings.HasSuffix(fileName, ".yml"):
|
||||||
|
return false
|
||||||
|
case strings.HasSuffix(fileName, ".yaml"):
|
||||||
|
return false
|
||||||
|
default:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue