Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions staging/operator-registry/internal/declcfg/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import (
"github.com/operator-framework/operator-registry/internal/property"
)

const (
indexIgnoreFilename = ".indexignore"
)

type WalkFunc func(path string, cfg *DeclarativeConfig, err error) error

// WalkFS walks root using a gitignore-style filename matcher to skip files
Expand All @@ -27,7 +31,7 @@ func WalkFS(root fs.FS, walkFn WalkFunc) error {
if root == nil {
return fmt.Errorf("no declarative config filesystem provided")
}
matcher, err := ignore.NewMatcher(root, ".indexignore")
matcher, err := ignore.NewMatcher(root, indexIgnoreFilename)
if err != nil {
return err
}
Expand All @@ -36,7 +40,9 @@ func WalkFS(root fs.FS, walkFn WalkFunc) error {
if err != nil {
return walkFn(path, nil, err)
}
if info.IsDir() || matcher.Match(path, false) {
// avoid validating a directory, an .indexignore file, or any file that matches
// an ignore pattern outlined in a .indexignore file.
if info.IsDir() || info.Name() == indexIgnoreFilename || matcher.Match(path, false) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there no tests for this?

return nil
}
file, err := root.Open(path)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.