Skip to content

Commit

Permalink
Merge pull request #4 from simar7/export-funcs
Browse files Browse the repository at this point in the history
chore(rego): Export rego funcs
  • Loading branch information
simar7 authored Sep 15, 2023
2 parents cf704c9 + 33edb29 commit 0f6e136
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/rego/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func RecurseEmbeddedModules(fs embed.FS, dir string) (map[string]*ast.Module, er
}
continue
}
if !isRegoFile(entry.Name()) || isDotFile(entry.Name()) {
if !IsRegoFile(entry.Name()) || IsDotFile(entry.Name()) {
continue
}
fullPath := strings.Join([]string{dir, entry.Name()}, "/")
Expand Down
8 changes: 4 additions & 4 deletions pkg/rego/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import (
"github.com/open-policy-agent/opa/bundle"
)

func isRegoFile(name string) bool {
func IsRegoFile(name string) bool {
return strings.HasSuffix(name, bundle.RegoExt) && !strings.HasSuffix(name, "_test"+bundle.RegoExt)
}

func isDotFile(name string) bool {
func IsDotFile(name string) bool {
return strings.HasPrefix(name, ".")
}

func isJSONFile(name string) bool {
func IsJSONFile(name string) bool {
return strings.HasSuffix(name, ".json")
}

Expand All @@ -42,7 +42,7 @@ func (s *Scanner) loadPoliciesFromDirs(target fs.FS, paths []string) (map[string
if info.IsDir() {
return nil
}
if !isRegoFile(info.Name()) || isDotFile(info.Name()) {
if !IsRegoFile(info.Name()) || IsDotFile(info.Name()) {
return nil
}
data, err := fs.ReadFile(target, filepath.ToSlash(path))
Expand Down
2 changes: 1 addition & 1 deletion pkg/rego/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ func findSchemaInFS(paths []string, srcFS fs.FS, schemaName string) ([]byte, err
if info.IsDir() {
return nil
}
if !isJSONFile(info.Name()) {
if !IsJSONFile(info.Name()) {
return nil
}
if info.Name() == schemaName+".json" {
Expand Down

0 comments on commit 0f6e136

Please sign in to comment.