Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.

feat(params): enabling paramKind and paramRef to the policy#185

Merged
flavio merged 6 commits intokubewarden:mainfrom
jvanz:params
Oct 7, 2025
Merged

feat(params): enabling paramKind and paramRef to the policy#185
flavio merged 6 commits intokubewarden:mainfrom
jvanz:params

Conversation

@jvanz
Copy link
Copy Markdown
Member

@jvanz jvanz commented Sep 23, 2025

Description

Adds new policy settings to allow users to define policy parameters. To address that, now the policy has new settings fields that work in the same way that Kubernetes ValidatingAdmissionPolicy works.

Fix #161

Test

make test e2e-test

@jvanz jvanz self-assigned this Sep 23, 2025
@jvanz jvanz marked this pull request as ready for review September 23, 2025 16:35
@jvanz jvanz requested a review from a team as a code owner September 23, 2025 16:35
Comment thread internal/settings/settings.go Outdated
Comment thread internal/settings/settings_test.go Outdated
Comment thread internal/validate/namespace_object.go
Comment thread README.md
Comment thread README.md
@viccuad
Copy link
Copy Markdown
Member

viccuad commented Sep 25, 2025

Missing to review validate.go and validate_test.go, will get to it tomorrow.

Comment thread internal/validate/validate.go Outdated
Comment thread internal/validate/validate.go Outdated
Comment thread internal/validate/validate.go Outdated
Comment thread internal/validate/validate_test.go Outdated
Comment thread internal/validate/validate_test.go Outdated
Comment thread internal/validate/validate_test.go Outdated
Comment thread internal/validate/validate_test.go Outdated
Comment thread internal/validate/validate_test.go Outdated
Copy link
Copy Markdown
Member

@viccuad viccuad left a comment

Choose a reason for hiding this comment

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

I think it would be valuable to put all the params new functions under validate/{params.go,params_test.go}.

Comment thread go.mod Outdated
Comment thread internal/settings/settings_test.go Outdated
Comment thread internal/settings/settings_test.go Outdated
Comment thread internal/settings/settings_test.go Outdated
@jvanz jvanz force-pushed the params branch 2 times, most recently from 3f6d56b to 2b41289 Compare September 26, 2025 18:42
Comment thread internal/validate/validate.go Outdated
@jvanz jvanz force-pushed the params branch 2 times, most recently from 1a6586d to 92bb8bd Compare September 26, 2025 19:38
@jvanz jvanz requested review from flavio and viccuad September 26, 2025 19:41
Comment thread Makefile
Comment thread README.md
expression: "object.spec.replicas"
validations:
- expression: "variables.replicas <= 5"
- expression: "variables.replicas <= params.data.maxreplicas"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would include also the definition for the ConfigMap in this same YAML block to tie everything together. That way people don't need to know about VAPs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sorry, I did not understand the request. Do you want to add a comment with an example of the params ConfigMap resource in the yaml block?

Copy link
Copy Markdown
Member

@viccuad viccuad Oct 6, 2025

Choose a reason for hiding this comment

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

Yes, that was the idea.

I did that for kubewarden/docs#683 on the docs. I'm conflicted, as it just grows the example. What do you think about it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think we can added. It's small number of line and give a better understanding of what's going on.

Comment thread Makefile Outdated
Copy link
Copy Markdown
Member

@flavio flavio left a comment

Choose a reason for hiding this comment

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

LGTM, I left some minor comments

Comment thread internal/validate/params_test.go Outdated
Comment thread internal/validate/validate.go Outdated
@jvanz jvanz requested review from flavio and viccuad October 2, 2025 17:37
@jvanz
Copy link
Copy Markdown
Member Author

jvanz commented Oct 2, 2025

@viccuad @flavio , can you review again?

@viccuad let me know if you think that the documentation I wrote explaining the e2e test behavior is enough.

Copy link
Copy Markdown
Member

@viccuad viccuad left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

Reminder, we still need some changes to docs.kubewarden.io. Edit: opened kubewarden/docs#683.

Comment thread internal/settings/settings.go
jvanz and others added 6 commits October 7, 2025 09:58
Adds new policy settings to allow users to define policy parameters. To
address that, now the policy has new settings fields that work in the
same way that Kubernetes ValidatingAdmissionPolicy works.

Signed-off-by: José Guilherme Vanz <[email protected]>
Update linter version and fixes all the errors pointed by it.

Signed-off-by: José Guilherme Vanz <[email protected]>
Moves the functions used to manipulate and fetch parameters to a
dedicated file. And, refactor the evaluation functions to remove
duplicate code to that iterate and run evaluations.

Also fixes some review comments.

Signed-off-by: José Guilherme Vanz <[email protected]>
Updates the e2e tests target to generate the metadata.yml file used to
annonate the policy used in the e2e test run. Document this behaivour on
CONTRIBUTING.md.

Signed-off-by: José Guilherme Vanz <[email protected]>
Updates the evaluateValidation signature to return
(ValidationResponse,error).

Furthermore, fix a type and move more specific function down in the
files.

Signed-off-by: José Guilherme Vanz <[email protected]>
Updates the README example adding a ConfigMap definition to be used as
resource parameter.

Signed-off-by: José Guilherme Vanz <[email protected]>
@flavio flavio merged commit b8ac360 into kubewarden:main Oct 7, 2025
6 checks passed
@jvanz jvanz deleted the params branch October 7, 2025 14:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add parameters support

3 participants