1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-15 17:51:20 +00:00
kyverno/pkg/client
Ammar Yasser 9a8e35d787
Selector with mutate target (#11208)
* feature: Add LabelSelector as a field of resource spec to allow fetching by labels

Signed-off-by: aerosouund <aerosound161@gmail.com>

* chore: Generate CRDs

Signed-off-by: aerosouund <aerosound161@gmail.com>

* 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.

Signed-off-by: aerosouund <aerosound161@gmail.com>

* feat: Pass label selector to the GetResources method

Signed-off-by: aerosouund <aerosound161@gmail.com>

* feat: Return the resource selector when resolving spec

Signed-off-by: aerosouund <aerosound161@gmail.com>

* 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

Signed-off-by: aerosouund <aerosound161@gmail.com>

* 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.

Signed-off-by: aerosouund <aerosound161@gmail.com>

* test: Add chainsaw test

Signed-off-by: aerosouund <aerosound161@gmail.com>

* chore: Run codegen

Signed-off-by: aerosouund <aerosound161@gmail.com>

* chore: Generate helm CRDs

Signed-off-by: aerosouund <aerosound161@gmail.com>

* 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.

Signed-off-by: aerosouund <aerosound161@gmail.com>

* chore: Run codegen after modifying selector comment

Signed-off-by: aerosouund <aerosound161@gmail.com>

* chore: Run codegen

Signed-off-by: aerosouund <aerosound161@gmail.com>

---------

Signed-off-by: aerosouund <aerosound161@gmail.com>
Co-authored-by: shuting <shuting@nirmata.com>
2024-10-16 11:17:08 +00:00
..
applyconfigurations Selector with mutate target (#11208) 2024-10-16 11:17:08 +00:00
clientset/versioned feat: remove kyverno client v2beta1 (#10543) 2024-06-26 08:48:32 +00:00
informers/externalversions feat: remove kyverno client v2beta1 (#10543) 2024-06-26 08:48:32 +00:00
listers feat: bump update request api version (#10508) 2024-06-20 09:44:43 +00:00