Build a PolicyDomain from a PolicyDomainReference with external Rego files.
mpe build --file <file> [--output <file>]
The build command transforms a PolicyDomainReference YAML file into a complete PolicyDomain by reading external .rego files and inlining their contents.
This allows you to:
.rego files for better editor support| Option | Alias | Description | Required |
|---|---|---|---|
--file | -f | PolicyDomainReference YAML file(s) to build | Yes |
--output | -o | Output file path (single file only) | No |
mpe build -f my-domain-ref.yml
# Creates: my-domain-ref-built.yml
mpe build -f my-domain-ref.yml -o my-domain.yml
mpe build -f domain1-ref.yml -f domain2-ref.yml
# Creates: domain1-ref-built.yml, domain2-ref-built.yml
A PolicyDomainReference uses rego_filename instead of inline rego:
apiVersion: iamlite.manetu.io/v1alpha4
kind: PolicyDomainReference
metadata:
name: my-domain
spec:
policy-libraries:
- mrn: "mrn:iam:library:utils"
name: utils
rego_filename: lib/utils.rego
policies:
- mrn: "mrn:iam:policy:main"
name: main
dependencies:
- "mrn:iam:library:utils"
rego_filename: policies/main.rego
mappers:
- name: http-mapper
selector:
- ".*"
rego_filename: mappers/http.rego
The build process:
PolicyDomainReferencerego_filename, reads the file contentrego_filename with rego containing the file contentkind from PolicyDomainReference to PolicyDomainpolicies:
- mrn: "mrn:iam:policy:main"
name: main
rego_filename: policies/main.rego
policies:
- mrn: "mrn:iam:policy:main"
name: main
rego: |
package authz
default allow = false
# ... rest of main.rego content
| Error | Cause | Solution |
|---|---|---|
| File not found | rego_filename path doesn't exist | Check file path is correct |
| Both specified | rego and rego_filename both present | Use only one |
| Invalid YAML | Malformed YAML syntax | Fix YAML syntax errors |
.rego files relative to the YAML filemy-policy-domain/
├── domain-ref.yml # PolicyDomainReference
├── domain.yml # Built PolicyDomain (generated)
├── lib/
│ ├── utils.rego
│ └── helpers.rego
├── policies/
│ ├── main.rego
│ └── admin.rego
└── mappers/
└── http.rego
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |