feat: opt-in creating wg-policy PolicyReport #1030
Merged
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.
This PR adds our first feature gate! 🎉 The feature gate is currently disabled by default. If the feature gate is enabled, the operator will create wgpolicyk8s.io/v1alpha2 PolicyReport resources for completed scan jobs.
The proposed mapping from the Trivy scan results to the policy report is inspired by trivy-operator-polr-adapter.
The Kubernetes policy working group has defined newer/improved PolicyReport APIs, but the proposed group/version is currently used, and CRD is installed, by Kyverno (version 1.12.5). The API is also the only API currently supported by policy-reporter - making the choice rather simple. I have filed an issue to support newer APIs, kyverno/policy-reporter#461, but the suggested API seems like our best choice now.
Tests of this new opt-in is currently limited, and we should probably also add some docs to indicate that the feature is there and how it is supposed to be used. I hope to do this in a follow-up PR.