summaryrefslogtreecommitdiff
path: root/pkg/policies/init.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/policies/init.go')
-rw-r--r--pkg/policies/init.go60
1 files changed, 0 insertions, 60 deletions
diff --git a/pkg/policies/init.go b/pkg/policies/init.go
deleted file mode 100644
index bc270763..00000000
--- a/pkg/policies/init.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package policies
-
-import (
- "context"
- "embed"
- _ "embed"
- "io/fs"
- "strings"
-
- "github.com/cedar-policy/cedar-go"
- "github.com/xlgmokha/x/pkg/log"
-)
-
-//go:embed *.cedar *.json
-var files embed.FS
-
-var All *cedar.PolicySet = cedar.NewPolicySet()
-var Entities cedar.EntityMap = cedar.EntityMap{}
-
-func init() {
- err := fs.WalkDir(files, ".", func(path string, d fs.DirEntry, err error) error {
- if err != nil {
- return err
- }
-
- if d.IsDir() {
- return nil
- }
-
- if strings.HasSuffix(path, ".cedar") {
- content, err := fs.ReadFile(files, path)
- if err != nil {
- return err
- }
-
- policy := cedar.Policy{}
- if err := policy.UnmarshalCedar(content); err != nil {
- return err
- }
- policy.SetFilename(path)
-
- All.Add(cedar.PolicyID(path), &policy)
- } else if strings.HasSuffix(path, ".json") {
- content, err := fs.ReadFile(files, path)
- if err != nil {
- return err
- }
-
- if err := Entities.UnmarshalJSON(content); err != nil {
- return err
- }
- }
-
- return nil
- })
-
- if err != nil {
- log.WithFields(context.Background(), log.Fields{"error": err})
- }
-}