Skip to content

Commit

Permalink
Merge branch 'main' into aws-metadata-token-file
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaddalozzo authored Sep 5, 2024
2 parents b37e173 + 3587ccf commit 7347b4b
Show file tree
Hide file tree
Showing 13 changed files with 379 additions and 250 deletions.
2 changes: 2 additions & 0 deletions ast/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ var RegoV1CompatibleRef = Ref{VarTerm("rego"), StringTerm("v1")}
// RegoVersion defines the Rego syntax requirements for a module.
type RegoVersion int

const DefaultRegoVersion = RegoVersion(0)

const (
// RegoV0 is the default, original Rego syntax.
RegoV0 RegoVersion = iota
Expand Down
8 changes: 7 additions & 1 deletion bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ func (m Manifest) Equal(other Manifest) bool {
if m.RegoVersion != nil && other.RegoVersion != nil && *m.RegoVersion != *other.RegoVersion {
return false
}
if !reflect.DeepEqual(m.FileRegoVersions, other.FileRegoVersions) {

// If both are nil, or both are empty, we consider them equal.
if !(len(m.FileRegoVersions) == 0 && len(other.FileRegoVersions) == 0) &&
!reflect.DeepEqual(m.FileRegoVersions, other.FileRegoVersions) {
return false
}

Expand Down Expand Up @@ -1092,6 +1095,9 @@ func (b *Bundle) FormatModulesForRegoVersion(version ast.RegoVersion, preserveMo
opts := format.Opts{}
if preserveModuleRegoVersion {
opts.RegoVersion = module.Parsed.RegoVersion()
opts.ParserOptions = &ast.ParserOptions{
RegoVersion: opts.RegoVersion,
}
} else {
opts.RegoVersion = version
}
Expand Down
1 change: 1 addition & 0 deletions compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,7 @@ func (o *optimizer) getSupportForEntrypoint(queries []ast.Body, e *ast.Term, res
path := e.Value.(ast.Ref)
name := ast.Var(path[len(path)-1].Value.(ast.String))
module := &ast.Module{Package: &ast.Package{Path: path[:len(path)-1]}}
module.SetRegoVersion(o.regoVersion)

for _, query := range queries {
// NOTE(tsandall): when the query refers to the original entrypoint, throw it
Expand Down
Loading

0 comments on commit 7347b4b

Please sign in to comment.