-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Index additional printer columns for Gatekeeper constraints (#299)
* Use type assertions in GenericInformer Since the dynamic client is always used, the object will always be of type *unstructured.Unstructured, so no need to do anything but use type assertions. Signed-off-by: mprahl <[email protected]> * Index additional printer columns for Gatekeeper constraints Gatekeeper constraints are CRD based but the CRDs are generated based on user defined ConstraintTemplate objects. Because of this, indexing the constraint's `spec.enforcementAction` and `status.totalViolations` is a bit difficult with the current setup. This makes it so that the CRD's additionalPrinterColumns are automatically indexed. The scope of this change is limited to the constraints.gatekeeper.sh API group, but removing that check in the the `GenericResourceBuilder` function will enable it for all resources that don't have a custom transform. Note that the names from the additionalPrinterColumns in the CRD are converted to lowerCamelCase style when set as node properties. The separators are spaces and dashes (e.g. "enforcement action" and "enforcement-action" become "enforcementAction). Duplicate node properties are ignored, with a priority on the default generic property names. As part of this change, it made sense to also make `syncInformers` event driven so that it only gets run when there is a likely relevent change in a CRD (i.e. added, deleted, or the spec changed). This makes the indexing of new custom resources nearly instant while also sharing the CRD informer for keeping an up to date mapping of GVRs to additional printer columns. Lastly, main.go was refactored a bit to wait for the two main goroutines to end before exiting. This allows for some clean up when the interrupt signal is sent to the process. More refactoring to let every goroutine clean up should be considered. Relates: https://issues.redhat.com/browse/ACM-13278 https://issues.redhat.com/browse/ACM-12572 Signed-off-by: mprahl <[email protected]> * Add _isExternal field to Gatekeeper constraints Signed-off-by: mprahl <[email protected]> --------- Signed-off-by: mprahl <[email protected]>
- Loading branch information
Showing
13 changed files
with
945 additions
and
169 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.