Skip to content

Commit 78f27b3

Browse files
authoredAug 3, 2021
internal/declcfg: Avoid processing the .indexignore file when walking the root fs (operator-framework#733)
Update internal/declcfg/load.go and avoid processing any files that are named `.indexignore` when walking the declarative config index root filesystem. When validating declarative config directories, the .indexignore file was being processed and validated. Signed-off-by: timflannagan <[email protected]>
1 parent 673849b commit 78f27b3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎internal/declcfg/load.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import (
1717
"github.com/operator-framework/operator-registry/internal/property"
1818
)
1919

20+
const (
21+
indexIgnoreFilename = ".indexignore"
22+
)
23+
2024
type WalkFunc func(path string, cfg *DeclarativeConfig, err error) error
2125

2226
// WalkFS walks root using a gitignore-style filename matcher to skip files
@@ -27,7 +31,7 @@ func WalkFS(root fs.FS, walkFn WalkFunc) error {
2731
if root == nil {
2832
return fmt.Errorf("no declarative config filesystem provided")
2933
}
30-
matcher, err := ignore.NewMatcher(root, ".indexignore")
34+
matcher, err := ignore.NewMatcher(root, indexIgnoreFilename)
3135
if err != nil {
3236
return err
3337
}
@@ -36,7 +40,9 @@ func WalkFS(root fs.FS, walkFn WalkFunc) error {
3640
if err != nil {
3741
return walkFn(path, nil, err)
3842
}
39-
if info.IsDir() || matcher.Match(path, false) {
43+
// avoid validating a directory, an .indexignore file, or any file that matches
44+
// an ignore pattern outlined in a .indexignore file.
45+
if info.IsDir() || info.Name() == indexIgnoreFilename || matcher.Match(path, false) {
4046
return nil
4147
}
4248
file, err := root.Open(path)

0 commit comments

Comments
 (0)
Please sign in to comment.