Add rule PDP adapter boundary
Some checks failed
CI / Build and Test (push) Has been cancelled
CI / Lint (push) Has been cancelled

This commit is contained in:
2026-05-17 07:13:27 +02:00
parent 4bb329c921
commit ad4895187b
7 changed files with 1011 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
package rule
import (
"github.com/netkingdom/flex-auth/internal/policy"
"github.com/netkingdom/flex-auth/pkg/api"
)
// PolicyArtifactFromPackage preserves the extracted Rego module and metadata
// from a flex-auth Rego-in-Markdown package.
func PolicyArtifactFromPackage(pkg *policy.Package) PolicyArtifact {
tests := make([]string, 0, len(pkg.TestBlocks))
for _, block := range pkg.TestBlocks {
tests = append(tests, block.Body)
}
return PolicyArtifact{
ID: pkg.Metadata.ID,
Version: pkg.Metadata.Version,
Language: LanguageRego,
Package: pkg.Metadata.Package,
Module: pkg.RegoModule,
Tests: tests,
Fixtures: append([]api.PolicyFixture(nil), pkg.Fixtures...),
Caring: pkg.Metadata.Caring,
Metadata: copyMap(pkg.Metadata.Metadata),
}
}