feat: add --custom-resources flag to validator rules check as an alternate to -f#218
Merged
ahmad-ibra merged 9 commits intomainfrom Sep 9, 2024
Merged
feat: add --custom-resources flag to validator rules check as an alternate to -f#218ahmad-ibra merged 9 commits intomainfrom
ahmad-ibra merged 9 commits intomainfrom
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.
|
TylerGillson
reviewed
Sep 7, 2024
Member
TylerGillson
left a comment
There was a problem hiding this comment.
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?
TylerGillson
reviewed
Sep 9, 2024
Member
TylerGillson
left a comment
There was a problem hiding this comment.
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?
TylerGillson
approved these changes
Sep 9, 2024
ahmad-ibra
added a commit
to validator-labs/docs
that referenced
this pull request
Sep 9, 2024
## Issue N/A ## Description Document the usage of the `--custom-resources` flag which was added here: validator-labs/validatorctl#218
TylerGillson
added a commit
that referenced
this pull request
Sep 11, 2024
🤖 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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Resolves #178
Resolves #136
Description
This PR adds support for passing in custom resource documents to the
validator rules checkcommand via the--custom-resourcesflag. The--custom-resourcesflag 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
--crflag, 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.