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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 ClusterClass: allow accessing nestedFields via valueFrom.variable #5925

Conversation

sbueringer
Copy link
Member

Signed-off-by: Stefan B眉ringer buringerst@vmware.com

What this PR does / why we need it:
With this PR it's now possible to access nested fields of complex variables (objects and arrays) via .valueFrom.variable. This was already implemented in the JSON patch generator, but blocked by the webhook.

I think complex variables and the Patch validation were implemented at the same time so we missed it.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Signed-off-by: Stefan B眉ringer buringerst@vmware.com
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 11, 2022
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 11, 2022
// validating if the whole path is an existing variable.
// This could be done by re-using getVariableValue of the json patch
// generator but requires a refactoring first.
variableName := getVariableName(*jsonPatch.ValueFrom.Variable)
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm aware that we're duplicating more logic here, similar to how we did above with the builtin variable validation.

But I think for now it's the pragmatic thing to do. I think long-term we should clean it up so that the webhook can re-use code of the JSON patch generator for validation to allow more powerful validations (and less duplicate code/logic).

@sbueringer
Copy link
Member Author

/cc @fabriziopandini @killianmuldoon

@fabriziopandini
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 12, 2022
@fabriziopandini
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 13, 2022
@k8s-ci-robot k8s-ci-robot merged commit 077921f into kubernetes-sigs:main Jan 13, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.1 milestone Jan 13, 2022
@sbueringer sbueringer deleted the pr-allow-nested-valuefrom-variable branch January 13, 2022 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants