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

Allow --local-crds flag to receive multiple values #101

Conversation

doom
Copy link
Contributor

@doom doom commented Mar 24, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR allows the --local-crds flag to receive multiple values.

Which issue(s) this PR fixes:

Fixes #100

Special notes for your reviewer:

N/A

Does this PR introduce a user-facing change?

Updated the `--local-crds` flag to allow receiving multiple values

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 24, 2024
Copy link

linux-foundation-easycla bot commented Mar 24, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Mar 24, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @doom!

It looks like this is your first PR to kubernetes-sigs/kubectl-validate 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kubectl-validate has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 24, 2024
pkg/cmd/validate.go Outdated Show resolved Hide resolved
pkg/cmd/validate.go Outdated Show resolved Hide resolved
for _, dir := range k.dirs {
files, err := utils.ReadDir(k.fs, dir)
if err != nil {
return nil, fmt.Errorf("error listing %s: %w", dir, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to stop if any of the directory fails? I think we do
But do we want to report all errors if multiple directories fail? I suspect so too, thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree for a better user experience we likely should accumulate and report all errors at once.
However it seems the current strategy for this function is to fail as soon as any error is encountered (e.g. first file that cannot be read). Perhaps we could revisit it outside of this PR ?

Copy link
Contributor

Choose a reason for hiding this comment

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

sgtm

pkg/openapiclient/local_crds.go Show resolved Hide resolved
@kannon92
Copy link
Contributor

/retest

@kannon92
Copy link
Contributor

/ok-to-test

Not sure why the CI is stuck..

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Mar 26, 2024
@doom
Copy link
Contributor Author

doom commented Mar 27, 2024

/ok-to-test

Not sure why the CI is stuck..

Hey @kannon92 ! Not very familiar with the process, but from my side the workflow is still marked as awaiting approval from a maintainer (and links to these docs). Would you or @apelisse be able to do that ?

@alexzielenski
Copy link
Contributor

I marked it as ok to test

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 28, 2024
@doom doom force-pushed the allow-local-crds-flag-to-receive-multiple-values branch from 0eb921d to 64b569c Compare March 28, 2024 19:10
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 28, 2024
@doom
Copy link
Contributor Author

doom commented Mar 31, 2024

Hey @alexzielenski, thank you ! I have rebased the branch on top of main to fix go.mod diffs, could you please re-approve the workflow run ?

@alexzielenski
Copy link
Contributor

/approve

Thanks for this! Will defer lgtm for a bit in case @apelisse has anything to add

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexzielenski, doom

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 Apr 1, 2024
@doom doom requested a review from apelisse April 3, 2024 09:05
@monotek
Copy link
Member

monotek commented Apr 10, 2024

I ran into an issue recently, where in my CRDs directory, where i had to copy all my CRDs, a non CRD yaml file existed, which caused kubectl-validate to fail, like below.

kubectl-validate namespaces/visual-regression-tracker --local-crds ./crds
Error: no kind "ClusterPolicy" is registered for version "kyverno.io/v1" in scheme "pkg/runtime/scheme.go:100"

So if multiple directories would be possible for --local-crds imho there should be some check if the files in the directories are valid CRDs.
I guess checking for "kind: CustomResourceDefinition" in the file is is enough?
All other files should be ignored.

@alexzielenski
Copy link
Contributor

So if multiple directories would be possible for --local-crds imho there should be some check if the files in the directories are valid CRDs.
I guess checking for "kind: CustomResourceDefinition" in the file is is enough?
All other files should be ignored.

That is valid, I agree we should ignore non-crds in those directories. Could you file a separate issue to track this?

@alexzielenski
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 10, 2024
@k8s-ci-robot k8s-ci-robot merged commit 25f6de4 into kubernetes-sigs:main Apr 10, 2024
5 checks passed
@monotek
Copy link
Member

monotek commented Apr 10, 2024

So if multiple directories would be possible for --local-crds imho there should be some check if the files in the directories are valid CRDs.
I guess checking for "kind: CustomResourceDefinition" in the file is is enough?
All other files should be ignored.

That is valid, I agree we should ignore non-crds in those directories. Could you file a separate issue to track this?

done :)

#110

@doom doom deleted the allow-local-crds-flag-to-receive-multiple-values branch April 11, 2024 12:29
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. 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

Allow --local-crds flag to receive multiple values
6 participants