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

Generalize Query Param Verifier #108620

Merged
merged 2 commits into from
Mar 15, 2022

Conversation

kevindelgado
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

Pre-Req of #108350

Generalizes the dry-run verifier for arbitrary query params and adds support for the fieldValidation query param

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 10, 2022
@k8s-ci-robot
Copy link
Contributor

@kevindelgado: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubectl labels Mar 10, 2022
@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Mar 10, 2022
@@ -499,7 +499,7 @@ func (f *TestFactory) UnstructuredClientForMapping(mapping *meta.RESTMapping) (r
}

// Validator returns a validation schema
func (f *TestFactory) Validator(validate bool) (validation.Schema, error) {
func (f *TestFactory) Validator(validateDirective cmdutil.ValidationDirective, verifier *resource.QueryParamVerifier) (validation.Schema, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this something you wanted to take in that pull-request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@apelisse
Copy link
Member

the diff is not showing me the change this is doing to swagger, but I'm confused why swagger changed?

@apelisse
Copy link
Member

Looks good beside the minor nits that I've mentioned.

@kevindelgado
Copy link
Contributor Author

the diff is not showing me the change this is doing to swagger, but I'm confused why swagger changed?

Looks like the swagger artifact in the cli-runtime repo is not auto-updated from k/k so I had to copy over what's in k/k/api/openapi-spec/swagger.json since it hasn't been updated here sincethe fieldValidation query param was introduced in 1.23

@apelisse
Copy link
Member

OK, I double checked this, thanks!
/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 Mar 10, 2022
@kevindelgado
Copy link
Contributor Author

/assign @liggitt

func NewDryRunVerifier(dynamicClient dynamic.Interface, openAPIGetter discovery.OpenAPISchemaInterface) *DryRunVerifier {
return &DryRunVerifier{
func NewQueryParamVerifier(dynamicClient dynamic.Interface, openAPIGetter discovery.OpenAPISchemaInterface, queryParam VerifiableQueryParam) *QueryParamVerifier {
return &QueryParamVerifier{
finder: NewCRDFinder(CRDFromDynamic(dynamicClient)),
Copy link
Member

Choose a reason for hiding this comment

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

@apelisse NewCRDFinder#cacheCRDs initializes on first use... do we care this work won't be shared across dry-run and field-validator verifiers?

Copy link
Member

@liggitt liggitt Mar 14, 2022

Choose a reason for hiding this comment

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

It looks like that is only used when the GVK cannot be located in the schema. interestingly, it also requires the user to have list permission on CRDs to work. --dry-run=server was much less frequent than validation, which will be true by default. We may need to revisit the fallback to CRDs when we start using this for field validation to make sure we're not modifying the behavior for types that cannot be located server-side

Copy link
Member

Choose a reason for hiding this comment

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

@apelisse NewCRDFinder#cacheCRDs initializes on first use... do we care this work won't be shared across dry-run and field-validator verifiers?

Yes, that's going to cause a double list on CRDs. At this point, I think it's fairly safe to remove the dryRunVerifier though?

--dry-run=server was much less frequent than validation, which will be true by default. We may need to revisit the fallback to CRDs when we start using this for field validation to make sure we're not modifying the behavior for types that cannot be located server-side

We could catch errors and do client-side validation or no validation at all (probably the former to avoid astonishment) when we can't determine if CRDs support validation?

@liggitt
Copy link
Member

liggitt commented Mar 14, 2022

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: apelisse, kevindelgado, liggitt

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 Mar 14, 2022
@k8s-ci-robot k8s-ci-robot merged commit 226a762 into kubernetes:master Mar 15, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.24 milestone Mar 15, 2022
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. area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/cli Categorizes an issue or PR as relevant to SIG CLI. 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.

None yet

4 participants