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 eval details template for deny-by-default rule. #4647

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

blkt
Copy link
Contributor

@blkt blkt commented Oct 4, 2024

Summary

This change adds a template used to produce evaluation details for the rego/deny-by-default evaluation engine.

This template allows the user defining the rule to output a message variable with a custom message to show when the evaluation fails.

Fixes stacklok/minder-stories#42

Change Type

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Unit and manual tested.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

@blkt blkt self-assigned this Oct 4, 2024
@coveralls
Copy link

coveralls commented Oct 4, 2024

Coverage Status

coverage: 53.193% (-0.07%) from 53.264%
when pulling ff8a17d on feat/rego-deny-by-default-eval-details-template
into 49f192a on main.

@blkt blkt force-pushed the feat/rego-deny-by-default-eval-details-template branch 4 times, most recently from 530b44f to d4d4b8e Compare October 4, 2024 15:33
@blkt blkt marked this pull request as ready for review October 4, 2024 15:35
@@ -177,7 +177,7 @@ func (r *RuleTypeEngine) Eval(

// Process evaluation
logger.Info().Msg("entity evaluation - evaluation started")
err := r.ruleEvaluator.Eval(ctx, params.GetRule().Def, result)
err := r.ruleEvaluator.Eval(ctx, params.GetRule().Def, inf.Entity, result)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could turn this into the same pattern as the one used here to limit the changes across the code base, let me know what you folks prefer.

@blkt blkt force-pushed the feat/rego-deny-by-default-eval-details-template branch from d4d4b8e to db05cd9 Compare October 4, 2024 15:42
This change adds a template used to produce evaluation details for the
`rego/deny-by-default` evaluation engine.

This template allows the user defining the rule to output a `message`
variable with a custom message to show when the evaluation fails.

Fixes stacklok/minder-stories#42
@blkt blkt force-pushed the feat/rego-deny-by-default-eval-details-template branch from db05cd9 to e741b32 Compare October 4, 2024 15:55
@@ -0,0 +1 @@
Evaluation {{ .status }}: {{ .message }}{{ with .entityName }} for entity {{ . }}{{ end }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on https://github.com/stacklok/minder-stories/issues/42#issuecomment-2394190172 should this be Evaluation {{ .status }}: {{ .message }}{{ with .entityName }} for {{ . }}{{ end }}?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, should we remove the Evaluation {{ .status }}: prefix? I think all the places that would use this already show the status separately from the details.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I might have prematurely optimized for the other cases (non failed ones).
I'll remove that.

@blkt blkt merged commit 337c455 into main Oct 7, 2024
19 checks passed
@blkt blkt deleted the feat/rego-deny-by-default-eval-details-template branch October 7, 2024 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants