Skip to content

Commit

Permalink
exclude git-ops-update files by default
Browse files Browse the repository at this point in the history
  • Loading branch information
choffmeister committed Nov 14, 2021
1 parent 323b4e2 commit a3b1f7d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ files:
- '\.yaml$'
excludes:
- '\.generated\.yaml$'
- '\/system\/.*\.yaml$'
```
### Define registries
Expand Down
3 changes: 2 additions & 1 deletion example/.git-ops-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ files:
includes:
- '\.yaml$'
excludes:
- '\.git-ops-update(\.cache)?\.yaml$'
- '\.generated\.yaml$'
- '\/system\/.*\.yaml$'
registries:
my-docker-registry:
interval: 1h
Expand Down
7 changes: 6 additions & 1 deletion internal/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func fileList(dir string, includes []regexp.Regexp, excludes []regexp.Regexp) (*[]string, error) {
defaultExclude := regexp.MustCompile(`\/\.git-ops-update(\.cache)?\.yaml$`)
files := []string{}
err := filepath.Walk(dir, func(path string, f os.FileInfo, err error) error {
if err != nil {
Expand All @@ -17,12 +18,16 @@ func fileList(dir string, includes []regexp.Regexp, excludes []regexp.Regexp) (*
if err != nil {
return err
}
pathRel = "/" + pathRel

for _, i := range includes {
if i.Match([]byte(pathRel)) {
excluded := false
if defaultExclude.MatchString(pathRel) {
excluded = true
}
for _, e := range excludes {
if e.Match([]byte(pathRel)) {
if e.MatchString(pathRel) {
excluded = true
}
}
Expand Down

0 comments on commit a3b1f7d

Please sign in to comment.