Skip to content

Commit

Permalink
Fix issue where .manifest files didn't register as roots
Browse files Browse the repository at this point in the history
We previously traversed the path downwards, so if we had
`foo/bar/.manifest` and `foo/bar/baz` was provided, we would
not find `foo/bar` as a root. Now search for manifests from the
root.

Fixes #1077

Signed-off-by: Anders Eknert <anders@styra.com>
  • Loading branch information
anderseknert committed Sep 9, 2024
1 parent 28bac91 commit ee8e713
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions internal/io/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ func WalkFiles(root string, f func(path string) error) error {
})
}

// FindManifestLocations walks the file system rooted at root, and returns the
// *relative* paths of directories containing a .manifest file.
func FindManifestLocations(root string) ([]string, error) {
var foundBundleRoots []string

Expand Down
13 changes: 7 additions & 6 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,6 @@ func FindBundleRootDirectories(path string) ([]string, error) {
foundBundleRoots = append(foundBundleRoots, roots...)
}

// rather than calling rio.FindManifestLocations later, let's
// check for .manifest directories as part of the same walk
if !info.IsDir() && info.Name() == ".manifest" {
foundBundleRoots = append(foundBundleRoots, filepath.Dir(path))
}

return nil
}); err != nil {
return nil, fmt.Errorf("failed to walk path: %w", err)
Expand Down Expand Up @@ -268,6 +262,13 @@ func rootsFromRegalDirectory(regalDir *os.File) ([]string, error) {
foundBundleRoots = append(foundBundleRoots, customRulesDir)
}

manifestRoots, err := rio.FindManifestLocations(filepath.Dir(regalDir.Name()))
if err != nil {
return nil, fmt.Errorf("failed while looking for manifest locations: %w", err)
}

foundBundleRoots = append(foundBundleRoots, util.Map(util.FilepathJoiner(parent), manifestRoots)...)

return foundBundleRoots, nil
}

Expand Down

0 comments on commit ee8e713

Please sign in to comment.