Skip to content

Commit 23614cc

Browse files
authored
OPA v1.14.0 (#1902)
And some minor updates related to that. Disable advertising semantic token support until the feature is ready. Signed-off-by: Anders Eknert <anders.eknert@apple.com>
1 parent b2678c6 commit 23614cc

8 files changed

Lines changed: 16 additions & 68 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<!-- markdownlint-disable MD041 -->
99

1010
[![Build Status](https://github.com/open-policy-agent/regal/workflows/Build/badge.svg)](https://github.com/open-policy-agent/regal/actions)
11-
![OPA v1.13.1](https://www.openpolicyagent.org/badge/v1.13.1)
11+
![OPA v1.14.0](https://www.openpolicyagent.org/badge/v1.14.0)
1212
[![codecov](https://codecov.io/github/open-policy-agent/regal/graph/badge.svg?token=EQK01YF3X3)](https://codecov.io/github/StyraInc/regal)
1313
[![Downloads](https://img.shields.io/github/downloads/open-policy-agent/regal/total.svg)](https://github.com/open-policy-agent/regal/releases)
1414

build/capabilities.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3110,8 +3110,8 @@
31103110
"decl": {
31113111
"args": [
31123112
{
3113-
"description": "the object to patch",
3114-
"name": "object",
3113+
"description": "the object, array or set to patch",
3114+
"name": "target",
31153115
"type": "any"
31163116
},
31173117
{

docs/readme-sections/badges.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- markdownlint-disable MD041 -->
22

33
[![Build Status](https://github.com/open-policy-agent/regal/workflows/Build/badge.svg)](https://github.com/open-policy-agent/regal/actions)
4-
![OPA v1.13.1](https://www.openpolicyagent.org/badge/v1.13.1)
4+
![OPA v1.14.0](https://www.openpolicyagent.org/badge/v1.14.0)
55
[![codecov](https://codecov.io/github/open-policy-agent/regal/graph/badge.svg?token=EQK01YF3X3)](https://codecov.io/github/StyraInc/regal)
66
[![Downloads](https://img.shields.io/github/downloads/open-policy-agent/regal/total.svg)](https://github.com/open-policy-agent/regal/releases)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/json-iterator/go v1.1.12
1717
github.com/jstemmer/go-junit-report/v2 v2.1.0
1818
github.com/olekukonko/tablewriter v1.1.3
19-
github.com/open-policy-agent/opa v1.13.1-0.20260224105757-9b2143cdf99c
19+
github.com/open-policy-agent/opa v1.14.0
2020
github.com/owenrumney/go-sarif/v2 v2.3.3
2121
github.com/pdevine/go-asciisprite v0.1.6
2222
github.com/pkg/profile v1.7.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
259259
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
260260
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
261261
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
262-
github.com/open-policy-agent/opa v1.13.1-0.20260224105757-9b2143cdf99c h1:M0JmKoepLqGXvf7WV+wGrsfNUuvcEfjITOXo3bbblsY=
263-
github.com/open-policy-agent/opa v1.13.1-0.20260224105757-9b2143cdf99c/go.mod h1:e+JSg7BVV9/vRcD5HYTUeyKIrvigPxYX6T1KcVUaHaM=
262+
github.com/open-policy-agent/opa v1.14.0 h1:sdG94h9GrZQQcTaH70fJhOuU+/C2FAeeAo8mSPssV/U=
263+
github.com/open-policy-agent/opa v1.14.0/go.mod h1:e+JSg7BVV9/vRcD5HYTUeyKIrvigPxYX6T1KcVUaHaM=
264264
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
265265
github.com/owenrumney/go-sarif v1.1.1/go.mod h1:dNDiPlF04ESR/6fHlPyq7gHKmrM0sHUvAGjsoh8ZH0U=
266266
github.com/owenrumney/go-sarif/v2 v2.3.3 h1:ubWDJcF5i3L/EIOER+ZyQ03IfplbSU1BLOE26uKQIIU=

internal/explorer/stages.go

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
type CompileResult struct {
20-
Stage string
20+
Stage ast.StageID
2121
Result *ast.Module
2222
Error string
2323
}
@@ -32,52 +32,13 @@ func (cr *CompileResult) FormattedResult() string {
3232
return string(formatted)
3333
}
3434

35-
type stage struct{ name, metricName string }
36-
37-
// NOTE(sr): copied from 0.68.0. When upgrading OPA to v1.14.0, let's use its v1/ast.AllStages().
38-
var stages = []stage{
39-
{"ResolveRefs", "compile_stage_resolve_refs"},
40-
{"InitLocalVarGen", "compile_stage_init_local_var_gen"},
41-
{"RewriteRuleHeadRefs", "compile_stage_rewrite_rule_head_refs"},
42-
{"CheckKeywordOverrides", "compile_stage_check_keyword_overrides"},
43-
{"CheckDuplicateImports", "compile_stage_check_duplicate_imports"},
44-
{"RemoveImports", "compile_stage_remove_imports"},
45-
{"SetModuleTree", "compile_stage_set_module_tree"},
46-
{"SetRuleTree", "compile_stage_set_rule_tree"},
47-
{"RewriteLocalVars", "compile_stage_rewrite_local_vars"},
48-
{"RewriteTemplateStrings", "compile_stage_rewrite_template_strings"},
49-
{"CheckVoidCalls", "compile_stage_check_void_calls"},
50-
{"RewritePrintCalls", "compile_stage_rewrite_print_calls"},
51-
{"RewriteExprTerms", "compile_stage_rewrite_expr_terms"},
52-
{"ParseMetadataBlocks", "compile_stage_parse_metadata_blocks"},
53-
{"SetAnnotationSet", "compile_stage_set_annotationset"},
54-
{"RewriteRegoMetadataCalls", "compile_stage_rewrite_rego_metadata_calls"},
55-
{"SetGraph", "compile_stage_set_graph"},
56-
{"RewriteComprehensionTerms", "compile_stage_rewrite_comprehension_terms"},
57-
{"RewriteRefsInHead", "compile_stage_rewrite_refs_in_head"},
58-
{"RewriteWithValues", "compile_stage_rewrite_with_values"},
59-
{"CheckRuleConflicts", "compile_stage_check_rule_conflicts"},
60-
{"CheckUndefinedFuncs", "compile_stage_check_undefined_funcs"},
61-
{"CheckSafetyRuleHeads", "compile_stage_check_safety_rule_heads"},
62-
{"CheckSafetyRuleBodies", "compile_stage_check_safety_rule_bodies"},
63-
{"RewriteEquals", "compile_stage_rewrite_equals"},
64-
{"RewriteDynamicTerms", "compile_stage_rewrite_dynamic_terms"},
65-
{"RewriteTestRulesForTracing", "compile_stage_rewrite_test_rules_for_tracing"}, // must run after RewriteDynamicTerms
66-
{"CheckRecursion", "compile_stage_check_recursion"},
67-
{"CheckTypes", "compile_stage_check_types"},
68-
{"CheckUnsafeBuiltins", "compile_state_check_unsafe_builtins"},
69-
{"CheckDeprecatedBuiltins", "compile_state_check_deprecated_builtins"},
70-
{"BuildRuleIndices", "compile_stage_rebuild_indices"},
71-
{"BuildComprehensionIndices", "compile_stage_rebuild_comprehension_indices"},
72-
{"BuildRequiredCapabilities", "compile_stage_build_required_capabilities"},
73-
}
74-
7535
func CompilerStages(path, rego string, useStrict, useAnno, usePrint bool) []CompileResult {
7636
c := regal_compile.NewCompilerWithRegalBuiltins().
7737
WithStrict(useStrict).
7838
WithEnablePrintStatements(usePrint).
7939
WithUseTypeCheckAnnotations(useAnno)
8040

41+
stages := ast.AllStages()
8142
result := append(make([]CompileResult, 0, len(stages)+1), CompileResult{Stage: "ParseModule"})
8243
opts := parse.ParserOptions()
8344
opts.ProcessAnnotation = useAnno
@@ -93,11 +54,11 @@ func CompilerStages(path, rego string, useStrict, useAnno, usePrint bool) []Comp
9354

9455
for i := range stages {
9556
stage := stages[i]
96-
c = c.WithStageAfter(stage.name, ast.CompilerStageDefinition{
97-
Name: stage.name + "Record",
98-
MetricName: stage.metricName + "_record",
57+
c = c.WithStageAfterID(stage, ast.CompilerStageDefinition{
58+
Name: string(stage) + "Record",
59+
MetricName: string(stage) + "_record",
9960
Stage: func(c0 *ast.Compiler) *ast.Error {
100-
result = append(result, CompileResult{Stage: stage.name, Result: getOne(c0.Modules)})
61+
result = append(result, CompileResult{Stage: stage, Result: getOne(c0.Modules)})
10162

10263
return nil
10364
},
@@ -107,7 +68,7 @@ func CompilerStages(path, rego string, useStrict, useAnno, usePrint bool) []Comp
10768
if c.Compile(map[string]*ast.Module{path: mod}); len(c.Errors) > 0 {
10869
// stage after the last than ran successfully
10970
stage := stages[len(result)-1]
110-
result = append(result, CompileResult{Stage: stage.name + ": Failure", Error: c.Errors.Error()})
71+
result = append(result, CompileResult{Stage: stage + ": Failure", Error: c.Errors.Error()})
11172
}
11273

11374
return result

internal/lsp/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,7 +2415,7 @@ func (l *LanguageServer) handleExplorerCommand(ctx context.Context, params types
24152415

24162416
for _, cs := range compileResults {
24172417
stage := types.ExplorerStageResult{
2418-
Name: cs.Stage,
2418+
Name: string(cs.Stage),
24192419
Error: cs.Error != "",
24202420
}
24212421

@@ -2482,7 +2482,7 @@ func (l *LanguageServer) handleExplorerCommand(ctx context.Context, params types
24822482
continue
24832483
}
24842484

2485-
stageName := strings.ReplaceAll(cs.Stage, " ", "_")
2485+
stageName := strings.ReplaceAll(string(cs.Stage), " ", "_")
24862486
filename := filepath.Join(tmpDir, fmt.Sprintf("%02d_%s_%s.txt", i, baseName, stageName))
24872487

24882488
if err := os.WriteFile(filename, []byte(output), 0o600); err != nil {

internal/util/util.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,6 @@ func MapValues[K comparable, V, R any](m map[K]V, f func(V) R) map[K]R {
8383
return mapped
8484
}
8585

86-
func FilterInPlace[T any](s []T, f func(T) bool) []T {
87-
n := 0
88-
89-
for i := range s {
90-
if f(s[i]) {
91-
s[n] = s[i]
92-
n++
93-
}
94-
}
95-
96-
return s[:n]
97-
}
98-
9986
// Filter returns a new slice containing only the elements of s that
10087
// satisfy the predicate f. This function runs each element of s through
10188
// f twice in order to allocate exactly what is needed. This is commonly

0 commit comments

Comments
 (0)