-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: add --custom-resources flag to validator rules check as an alternate to -f #218
Conversation
ad10303
to
05d28db
Compare
Codecov ReportAttention: Patch coverage is @@ Coverage Diff @@
## main #218 +/- ##
==========================================
+ Coverage 53.33% 53.43% +0.09%
==========================================
Files 45 46 +1
Lines 6272 6367 +95
==========================================
+ Hits 3345 3402 +57
- Misses 2082 2105 +23
- Partials 845 860 +15
Continue to review full report in Codecov by Sentry.
|
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.
Nice work! This is awesome. One tiny nit... sorry 😁
Can you please raise a follow up PR in the docs repo to cover this new usage?
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.
I'm having naming hesitancy about --cr
. Typically the long name for flags is not abbreviated. What do you think about --cr-path
? Or --custom-resources
?
## Issue N/A ## Description Document the usage of the `--custom-resources` flag which was added here: validator-labs/validatorctl#218
🤖 I have created a release *beep* *boop* --- ## [0.2.0](v0.1.4...v0.2.0) (2024-09-11) ### ⚠ BREAKING CHANGES * remove role privilege rules ([#217](#217)) ### Features * add --custom-resources flag to validator rules check as an alternate to -f ([#218](#218)) ([4aa14b6](4aa14b6)) ### Bug Fixes * add missing Host.Config.Storage privilege & document ([#212](#212)) ([c7408a6](c7408a6)) ### Docs * remove subcommand docs from repo ([#205](#205)) ([57ca6cb](57ca6cb)) ### Dependency Updates * **deps:** update golang.org/x/exp digest to e7e105d ([#214](#214)) ([c4ac163](c4ac163)) ### Refactoring * remove role privilege rules ([#217](#217)) ([b0976db](b0976db)) * update `executePlugins` function to operate on a slice of `PluginSpec`'s ([#206](#206)) ([97875f3](97875f3)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Issue
Resolves #178
Resolves #136
Description
This PR adds support for passing in custom resource documents to the
validator rules check
command via the--custom-resources
flag. The--custom-resources
flag can receive either a path to a directory or to a file.File selection
If a directory path is provided, we check each file within the directory for CR documents. Note that we walk the entire file tree from a particular directory. This means that users are able to organize their CRs in a manner like this:
In the above example, we'll look for CRs within the slice of all 3 files found (combined.yaml, network.yaml, and oci.yaml). Users have the flexibility to organize their CRs as they desire.
If a single file is instead passed in via the
--cr
flag, we only work with a slice containing the single file that was provided.CR Unmarshalling
Given a slice of files (which may only contain a single file), we range over each file and attempt the following:
We try to read all the CR documents that are contained in that file and run validations against them.
For instance, if the path to the following file is passed in:
We'll run validations against both he network and the oci plugin rules that are defined in the file. Users can choose to store all CRs in a single file, or spread them across multiple files. Whatever configuration they choose will work.
Error handling
Succesfull validation can result in a lot of text being printed to a users terminal. Given this, I wanted to avoid "hiding" an error in the flood of validation results. If any CR document is invalid, an error message will be returned and no validations will run. It'll be obvious what failed and how to fix it.