README
¶
Testing an OPA builtin with a rego query
- Set up your main.go to be the following
func main() {
logLevel := &slog.LevelVar{}
logLevel.Set(slog.LevelDebug)
opts := &slog.HandlerOptions{
Level: logLevel,
}
logger := slog.New(slog.NewJSONHandler(os.Stdout, opts))
slog.SetDefault(logger)
subjectmappingbuiltin.JQBuiltin()
if err := cmd.RootCommand.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
- Build the executable
cd service
go build -o opa++
- Create an example rego file
package sample
my_json = {
"testing1": {
"testing2": {
"testing3": ["helloworld"]
}
}
}
req = ".testing1.testing2.testing3[]"
res := jq.evaluate(my_json, req)
- Perform the query
./opa++ eval -d example.rego 'data.sample.res'
Documentation
¶
Index ¶
- func EvaluateCondition(condition *policy.Condition, entity flattening.Flattened) (bool, error)
- func EvaluateConditionGroup(conditionGroup *policy.ConditionGroup, entity flattening.Flattened) (bool, error)
- func EvaluateSubjectMappingMultipleEntities(...) (map[string][]string, error)
- func EvaluateSubjectMappings(...) ([]string, error)
- func EvaluateSubjectSet(subjectSet *policy.SubjectSet, entity flattening.Flattened) (bool, error)
- func SubjectMappingBuiltin()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvaluateCondition ¶
func EvaluateConditionGroup ¶
func EvaluateConditionGroup(conditionGroup *policy.ConditionGroup, entity flattening.Flattened) (bool, error)
func EvaluateSubjectMappingMultipleEntities ¶ added in v0.4.17
func EvaluateSubjectMappingMultipleEntities(attributeMappings map[string]*attributes.GetAttributeValuesByFqnsResponse_AttributeAndValue, entityRepresentations []*entityresolution.EntityRepresentation) (map[string][]string, error)
func EvaluateSubjectMappings ¶
func EvaluateSubjectMappings(attributeMappings map[string]*attributes.GetAttributeValuesByFqnsResponse_AttributeAndValue, entityRepresentation *entityresolution.EntityRepresentation) ([]string, error)
func EvaluateSubjectSet ¶
func EvaluateSubjectSet(subjectSet *policy.SubjectSet, entity flattening.Flattened) (bool, error)
func SubjectMappingBuiltin ¶
func SubjectMappingBuiltin()
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.