Skip to content

Commit

Permalink
Adjust imports for opa v1.0.0 release, hold back evaluator version to…
Browse files Browse the repository at this point in the history
… v0 language
  • Loading branch information
evankanderson committed Jan 8, 2025
1 parent 782eb8c commit 5d79bbf
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
6 changes: 3 additions & 3 deletions internal/engine/eval/rego/datasources.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"fmt"
"strings"

"github.com/open-policy-agent/opa/ast"
"github.com/open-policy-agent/opa/rego"
"github.com/open-policy-agent/opa/types"
"github.com/open-policy-agent/opa/v1/ast"
"github.com/open-policy-agent/opa/v1/rego"
"github.com/open-policy-agent/opa/v1/types"

v1datasources "github.com/mindersec/minder/pkg/datasources/v1"
"github.com/mindersec/minder/pkg/engine/v1/interfaces"
Expand Down
10 changes: 7 additions & 3 deletions internal/engine/eval/rego/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
"os"

"github.com/open-feature/go-sdk/openfeature"
"github.com/open-policy-agent/opa/rego"
"github.com/open-policy-agent/opa/topdown/print"
"github.com/open-policy-agent/opa/v1/ast"
"github.com/open-policy-agent/opa/v1/rego"
"github.com/open-policy-agent/opa/v1/topdown/print"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/types/known/structpb"

Expand Down Expand Up @@ -124,7 +125,10 @@ func (e *Evaluator) Eval(
obj := res.Object

// Register options to expose functions
regoFuncOptions := []func(*rego.Rego){}
regoFuncOptions := []func(*rego.Rego){
// TODO: figure out a Rego V1 migration path (https://github.com/mindersec/minder/issues/5262)
rego.SetRegoVersion(ast.RegoV0),
}

// Initialize the built-in minder library rego functions
regoFuncOptions = append(regoFuncOptions, instantiateRegoLib(ctx, e.featureFlags, res)...)
Expand Down
6 changes: 3 additions & 3 deletions internal/engine/eval/rego/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"github.com/go-git/go-billy/v5"
billyutil "github.com/go-git/go-billy/v5/util"
"github.com/open-feature/go-sdk/openfeature"
"github.com/open-policy-agent/opa/ast"
"github.com/open-policy-agent/opa/rego"
"github.com/open-policy-agent/opa/types"
"github.com/open-policy-agent/opa/v1/ast"
"github.com/open-policy-agent/opa/v1/rego"
"github.com/open-policy-agent/opa/v1/types"
"github.com/stacklok/frizbee/pkg/replacer"
"github.com/stacklok/frizbee/pkg/utils/config"
"gopkg.in/yaml.v3"
Expand Down
2 changes: 1 addition & 1 deletion internal/engine/eval/rego/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"strings"

"github.com/open-policy-agent/opa/rego"
"github.com/open-policy-agent/opa/v1/rego"
"google.golang.org/protobuf/reflect/protoreflect"

engerrors "github.com/mindersec/minder/internal/engine/errors"
Expand Down
6 changes: 4 additions & 2 deletions pkg/api/protobuf/go/minder/v1/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/go-playground/validator/v10"
"github.com/itchyny/gojq"
"github.com/open-policy-agent/opa/ast"
"github.com/open-policy-agent/opa/v1/ast"

"github.com/mindersec/minder/internal/util"
)
Expand Down Expand Up @@ -224,7 +224,9 @@ func (rego *RuleType_Definition_Eval_Rego) Validate() error {
return fmt.Errorf("%w: rego definition is empty", ErrInvalidRuleTypeDefinition)
}

_, err := ast.ParseModule("minder-ruletype-def.rego", rego.Def)
// TODO: figure out a Rego V1 migration path (https://github.com/mindersec/minder/issues/5262)
_, err := ast.ParseModuleWithOpts("minder-ruletype-def.rego", rego.Def,
ast.ParserOptions{RegoVersion: ast.RegoV0})
if err != nil {
return fmt.Errorf("%w: rego definition is invalid: %s", ErrInvalidRuleTypeDefinition, err)
}
Expand Down

0 comments on commit 5d79bbf

Please sign in to comment.