1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-05 07:26:55 +00:00
kyverno/pkg/clients
gcp-cherry-pick-bot[bot] 5a82d68f5c
Selector with mutate target (#11208) (#11425)
* feature: Add LabelSelector as a field of resource spec to allow fetching by labels



* chore: Generate CRDs



* feat: Add the capability to fetch with label selector

- Add the label selector as a parameter to GetResources of the engine api client and the dclient.
- Use the label selector with list options in the dclient.
- convert a metav1.LabelSelector to a labels.Selector before fetching to be able to convert it to a string to be used with ListOptions.



* feat: Pass label selector to the GetResources method



* feat: Return the resource selector when resolving spec



* fix: Instantiate the fake client schema using the passed gvrToListKind map and by inferring schema from passed resources

All tests that use List will fail because the fake client doesn't infer the schema from the passed resources.
gvrToListKind can't be fully deprecated as some parts of kyverno use the fake client without passing resources to it (resource generation). And so both approaches have to be supported.

References:
- https://github.com/kubernetes/client-go/issues/983
- 46c1ad3baa



* test: Add labelSelector unit test to mutate existing test.

- Remove the unwanted call to GetResource.
- Pass an empty map of GVR to string to the fake client constructor.



* test: Add chainsaw test



* chore: Run codegen



* chore: Generate helm CRDs



* refactor: Put the LabelSelector in a separate struct

Many types use the ResourceSpec struct and not all of them support label selectors.
This removes the field into a separate schema dedicated to target selection called TargetSelector.
It has the ResourceSpec and the selector.



* chore: Run codegen after modifying selector comment



* chore: Run codegen



---------

Signed-off-by: aerosouund <aerosound161@gmail.com>
Co-authored-by: Ammar Yasser <aerosound161@gmail.com>
Co-authored-by: shuting <shuting@nirmata.com>
2024-10-17 10:37:12 +00:00
..
aggregator feat: use k8s 1.28 libs (#8037) 2023-08-18 03:54:05 +00:00
apiserver chore: bump cosign to v2.2.1 (#8855) 2023-11-09 12:22:35 +00:00
dclient Selector with mutate target (#11208) (#11425) 2024-10-17 10:37:12 +00:00
dynamic feat: improve instrumented clients (#7006) 2023-04-25 15:31:09 +00:00
kube feat: bump to k8s 1.31 (#10938) 2024-08-28 17:09:58 +00:00
kyverno feat: remove kyverno client v2beta1 (#10543) 2024-06-26 08:48:32 +00:00
metadata feat: improve instrumented clients (#7006) 2023-04-25 15:31:09 +00:00