-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Generalize Query Param Verifier #108620
Conversation
@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 The 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. |
e9878ff
to
d8202f0
Compare
@@ -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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
the diff is not showing me the change this is doing to swagger, but I'm confused why swagger changed? |
Looks good beside the minor nits that I've mentioned. |
d8202f0
to
bc68466
Compare
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 |
OK, I double checked this, thanks! |
/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)), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
/lgtm |
[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 |
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?