build(deps): bump github.com/open-policy-agent/opa from 0.64.1 to 0.65.0
Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 0.64.1 to 0.65.0. - [Release notes](https://github.com/open-policy-agent/opa/releases) - [Changelog](https://github.com/open-policy-agent/opa/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-policy-agent/opa/compare/v0.64.1...v0.65.0) --- updated-dependencies: - dependency-name: github.com/open-policy-agent/opa dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
Ralf Haferkamp
parent
340b75495b
commit
01867a22dc
+28
@@ -509,6 +509,34 @@ func (a *Annotations) toObject() (*Object, *Error) {
|
||||
return &obj, nil
|
||||
}
|
||||
|
||||
func attachRuleAnnotations(mod *Module) {
|
||||
// make a copy of the annotations
|
||||
cpy := make([]*Annotations, len(mod.Annotations))
|
||||
for i, a := range mod.Annotations {
|
||||
cpy[i] = a.Copy(a.node)
|
||||
}
|
||||
|
||||
for _, rule := range mod.Rules {
|
||||
var j int
|
||||
var found bool
|
||||
for i, a := range cpy {
|
||||
if rule.Ref().Equal(a.GetTargetPath()) {
|
||||
if a.Scope == annotationScopeDocument {
|
||||
rule.Annotations = append(rule.Annotations, a)
|
||||
} else if a.Scope == annotationScopeRule && rule.Loc().Row > a.Location.Row {
|
||||
j = i
|
||||
found = true
|
||||
rule.Annotations = append(rule.Annotations, a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if found && j < len(cpy) {
|
||||
cpy = append(cpy[:j], cpy[j+1:]...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func attachAnnotationsNodes(mod *Module) Errors {
|
||||
var errs Errors
|
||||
|
||||
|
||||
+2
@@ -2196,6 +2196,8 @@ func (c *Compiler) parseMetadataBlocks() {
|
||||
for _, err := range errs {
|
||||
c.err(err)
|
||||
}
|
||||
|
||||
attachRuleAnnotations(mod)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -713,6 +713,8 @@ func parseModule(filename string, stmts []Statement, comments []*Comment, regoCo
|
||||
return nil, errs
|
||||
}
|
||||
|
||||
attachRuleAnnotations(mod)
|
||||
|
||||
return mod, nil
|
||||
}
|
||||
|
||||
|
||||
+23
-7
@@ -185,11 +185,12 @@ type (
|
||||
// Rule represents a rule as defined in the language. Rules define the
|
||||
// content of documents that represent policy decisions.
|
||||
Rule struct {
|
||||
Default bool `json:"default,omitempty"`
|
||||
Head *Head `json:"head"`
|
||||
Body Body `json:"body"`
|
||||
Else *Rule `json:"else,omitempty"`
|
||||
Location *Location `json:"location,omitempty"`
|
||||
Default bool `json:"default,omitempty"`
|
||||
Head *Head `json:"head"`
|
||||
Body Body `json:"body"`
|
||||
Else *Rule `json:"else,omitempty"`
|
||||
Location *Location `json:"location,omitempty"`
|
||||
Annotations []*Annotations `json:"annotations,omitempty"`
|
||||
|
||||
// Module is a pointer to the module containing this rule. If the rule
|
||||
// was NOT created while parsing/constructing a module, this should be
|
||||
@@ -309,8 +310,8 @@ func (mod *Module) Copy() *Module {
|
||||
nodes[mod.Package] = cpy.Package
|
||||
|
||||
cpy.Annotations = make([]*Annotations, len(mod.Annotations))
|
||||
for i := range mod.Annotations {
|
||||
cpy.Annotations[i] = mod.Annotations[i].Copy(nodes[mod.Annotations[i].node])
|
||||
for i, a := range mod.Annotations {
|
||||
cpy.Annotations[i] = a.Copy(nodes[a.node])
|
||||
}
|
||||
|
||||
cpy.Comments = make([]*Comment, len(mod.Comments))
|
||||
@@ -663,6 +664,11 @@ func (rule *Rule) Compare(other *Rule) int {
|
||||
if cmp := rule.Body.Compare(other.Body); cmp != 0 {
|
||||
return cmp
|
||||
}
|
||||
|
||||
if cmp := annotationsCompare(rule.Annotations, other.Annotations); cmp != 0 {
|
||||
return cmp
|
||||
}
|
||||
|
||||
return rule.Else.Compare(other.Else)
|
||||
}
|
||||
|
||||
@@ -671,6 +677,12 @@ func (rule *Rule) Copy() *Rule {
|
||||
cpy := *rule
|
||||
cpy.Head = rule.Head.Copy()
|
||||
cpy.Body = rule.Body.Copy()
|
||||
|
||||
cpy.Annotations = make([]*Annotations, len(rule.Annotations))
|
||||
for i, a := range rule.Annotations {
|
||||
cpy.Annotations[i] = a.Copy(&cpy)
|
||||
}
|
||||
|
||||
if cpy.Else != nil {
|
||||
cpy.Else = rule.Else.Copy()
|
||||
}
|
||||
@@ -763,6 +775,10 @@ func (rule *Rule) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if len(rule.Annotations) != 0 {
|
||||
data["annotations"] = rule.Annotations
|
||||
}
|
||||
|
||||
return json.Marshal(data)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user