Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add REGO debugger to Mindev. #5229

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cmd/dev/app/rule_type/rttst.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func CmdTest() *cobra.Command {
testCmd.Flags().StringP("token", "t", "", "token to authenticate to the provider."+
"Can also be set via the TEST_AUTH_TOKEN environment variable.")
testCmd.Flags().StringArrayP("data-source", "d", []string{}, "YAML file containing the data source to test the rule with")
testCmd.Flags().BoolP("debug", "", false, "Start REGO debugger (only works for REGO-based rules types)")

if err := testCmd.MarkFlagRequired("rule-type"); err != nil {
fmt.Fprintf(os.Stderr, "Error marking flag as required: %s\n", err)
Expand Down Expand Up @@ -98,6 +99,7 @@ func testCmdRun(cmd *cobra.Command, _ []string) error {
token := viper.GetString("test.auth.token")
providerclass := cmd.Flag("provider")
providerconfig := cmd.Flag("provider-config")
debug := cmd.Flag("debug").Value.String() == "true"

dataSourceFileStrings, err := cmd.Flags().GetStringArray("data-source")
if err != nil {
Expand Down Expand Up @@ -197,7 +199,10 @@ func testCmdRun(cmd *cobra.Command, _ []string) error {

// TODO: use cobra context here
ctx := context.Background()
eng, err := rtengine.NewRuleTypeEngine(ctx, ruletype, prov, nil /*experiments*/, options.WithDataSources(dsRegistry))
eng, err := rtengine.NewRuleTypeEngine(ctx, ruletype, prov, nil, /*experiments*/
options.WithDataSources(dsRegistry),
options.WithDebugger(debug),
)
if err != nil {
return fmt.Errorf("cannot create rule type engine: %w", err)
}
Expand Down
Loading
Loading