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

馃尡 Add Cluster and ClusterClass variable defaulting and validation #5615

Conversation

killianmuldoon
Copy link
Contributor

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

Introduce webhook functions to validate the variables contained in a Cluster against their definitions in a ClusterClass, validate that the definitions of variables in a clusterClass are valid, and default the variables in a Cluster based on the defaulting defined in their schemas.

Fixes #5612

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 9, 2021
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 9, 2021
@killianmuldoon killianmuldoon changed the title [WIP] 馃尡 Add Cluster and ClusterClass variable defaulting and validation 馃尡 [WIP]Add Cluster and ClusterClass variable defaulting and validation Nov 9, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 9, 2021
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 17, 2021
@killianmuldoon killianmuldoon force-pushed the pr-clusterclass-variable-validation-defaulting branch from d279ff8 to c7e1785 Compare November 22, 2021 12:35
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 22, 2021
internal/topology/variables/doc.go Show resolved Hide resolved
webhooks/cluster.go Outdated Show resolved Hide resolved
internal/topology/variables/util.go Outdated Show resolved Hide resolved
internal/topology/variables/util.go Outdated Show resolved Hide resolved

// DefaultClusterVariables defaults variables which do not exist in clusterVariable, if they
// have a default value in the corresponding schema in clusterClassVariable.
func DefaultClusterVariables(clusterVariables []clusterv1.ClusterVariable, clusterClassVariables []clusterv1.ClusterClassVariable, fldPath *field.Path) ([]clusterv1.ClusterVariable, field.ErrorList) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func DefaultClusterVariables(clusterVariables []clusterv1.ClusterVariable, clusterClassVariables []clusterv1.ClusterClassVariable, fldPath *field.Path) ([]clusterv1.ClusterVariable, field.ErrorList) {
func DefaultClusterVariables(clusterVariables []clusterv1.ClusterVariable, clusterClassVariables []clusterv1.ClusterClassVariable) ([]clusterv1.ClusterVariable, field.ErrorList) {

all the checks in this func are referring to to spec.topology.variables.

Copy link
Member

Choose a reason for hiding this comment

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

Just felt like a best practice to pass in the relative field path which fits the struct we pass in which is then further amended. It makes it a lot easier to track per function if the path is constructed correctly

Copy link
Member

Choose a reason for hiding this comment

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

internal/topology/variables/cluster_variable_validation.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 22, 2021
@killianmuldoon killianmuldoon force-pushed the pr-clusterclass-variable-validation-defaulting branch from c7e1785 to 2ebd776 Compare November 23, 2021 11:14
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 23, 2021
@killianmuldoon killianmuldoon force-pushed the pr-clusterclass-variable-validation-defaulting branch 6 times, most recently from ee697dd to d8dc4e3 Compare November 24, 2021 10:49
Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

Looks great so far. A few nits.

Disclaimer: only reviewed "prod" (non-test) code

@killianmuldoon killianmuldoon force-pushed the pr-clusterclass-variable-validation-defaulting branch from d8dc4e3 to cd38690 Compare November 24, 2021 12:59
@killianmuldoon killianmuldoon changed the title 馃尡 [WIP]Add Cluster and ClusterClass variable defaulting and validation 馃尡 Add Cluster and ClusterClass variable defaulting and validation Nov 24, 2021
@killianmuldoon killianmuldoon force-pushed the pr-clusterclass-variable-validation-defaulting branch from bca111b to 67076b5 Compare November 24, 2021 13:01
@killianmuldoon killianmuldoon force-pushed the pr-clusterclass-variable-validation-defaulting branch from 067f668 to 7ccd337 Compare November 24, 2021 13:23
Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

looks great!

internal/webhooks/cluster_test.go Outdated Show resolved Hide resolved
@killianmuldoon killianmuldoon force-pushed the pr-clusterclass-variable-validation-defaulting branch from 0211793 to 14ab981 Compare November 24, 2021 15:12
@killianmuldoon killianmuldoon force-pushed the pr-clusterclass-variable-validation-defaulting branch 2 times, most recently from 141f967 to fbc1117 Compare November 24, 2021 16:52
Signed-off-by: Stefan B眉ringer buringerst@vmware.com
Signed-off-by: killianmuldoon <kmuldoon@vmware.com>

Co-authored-by: killianmuldoon kmuldoon@vmware.com
@killianmuldoon killianmuldoon force-pushed the pr-clusterclass-variable-validation-defaulting branch from fbc1117 to 9099eb5 Compare November 24, 2021 17:02
@fabriziopandini
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 25, 2021
@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 Nov 25, 2021
@k8s-ci-robot k8s-ci-robot merged commit cce1f96 into kubernetes-sigs:main Nov 25, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.1 milestone Nov 25, 2021
@sbueringer sbueringer deleted the pr-clusterclass-variable-validation-defaulting branch November 29, 2021 09:10
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cluster/ClusterClass: variable validation and defaulting
4 participants