build(deps): bump github.com/open-policy-agent/opa from 0.59.0 to 0.60.0
Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 0.59.0 to 0.60.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.59.0...v0.60.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
b62ba69bba
commit
f989854f0a
+22
-2
@@ -400,6 +400,7 @@ type Reader struct {
|
||||
lazyLoadingMode bool
|
||||
name string
|
||||
persist bool
|
||||
regoVersion ast.RegoVersion
|
||||
}
|
||||
|
||||
// NewReader is deprecated. Use NewCustomReader instead.
|
||||
@@ -503,11 +504,17 @@ func (r *Reader) WithBundlePersistence(persist bool) *Reader {
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *Reader) WithRegoVersion(version ast.RegoVersion) *Reader {
|
||||
r.regoVersion = version
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *Reader) ParserOptions() ast.ParserOptions {
|
||||
return ast.ParserOptions{
|
||||
ProcessAnnotation: r.processAnnotations,
|
||||
Capabilities: r.capabilities,
|
||||
JSONOptions: r.jsonOptions,
|
||||
RegoVersion: r.regoVersion,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1005,12 +1012,18 @@ func hashBundleFiles(hash SignatureHasher, b *Bundle) ([]FileInfo, error) {
|
||||
}
|
||||
|
||||
// FormatModules formats Rego modules
|
||||
// Modules will be formatted to comply with rego-v1, but Rego compatibility of individual parsed modules will be respected (e.g. if 'rego.v1' is imported).
|
||||
func (b *Bundle) FormatModules(useModulePath bool) error {
|
||||
return b.FormatModulesForRegoVersion(ast.RegoV0, true, useModulePath)
|
||||
}
|
||||
|
||||
// FormatModulesForRegoVersion formats Rego modules to comply with a given Rego version
|
||||
func (b *Bundle) FormatModulesForRegoVersion(version ast.RegoVersion, preserveModuleRegoVersion bool, useModulePath bool) error {
|
||||
var err error
|
||||
|
||||
for i, module := range b.Modules {
|
||||
if module.Raw == nil {
|
||||
module.Raw, err = format.Ast(module.Parsed)
|
||||
module.Raw, err = format.AstWithOpts(module.Parsed, format.Opts{RegoVersion: version})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1020,7 +1033,14 @@ func (b *Bundle) FormatModules(useModulePath bool) error {
|
||||
path = module.Path
|
||||
}
|
||||
|
||||
module.Raw, err = format.Source(path, module.Raw)
|
||||
opts := format.Opts{}
|
||||
if preserveModuleRegoVersion {
|
||||
opts.RegoVersion = module.Parsed.RegoVersion()
|
||||
} else {
|
||||
opts.RegoVersion = version
|
||||
}
|
||||
|
||||
module.Raw, err = format.SourceWithOpts(path, module.Raw, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user