1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-29 02:45:06 +00:00
kyverno/pkg
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
..
auth fix: add the resource name to the SubjectAccessReview (#10221) 2024-08-07 12:46:44 +00:00
autogen refactor: move autogen v1 and v2 packages (#11416) 2024-10-16 08:51:38 +00:00
background feat: update engine response.generatedResources to support multiple resource (#11398) 2024-10-15 14:59:18 +08:00
breaker Reports controller circuit breaker (#11329) 2024-10-11 07:34:41 +00:00
client Selector with mutate target (#11208) 2024-10-16 11:17:08 +00:00
clients Selector with mutate target (#11208) 2024-10-16 11:17:08 +00:00
config chore: use ptr package (#11346) 2024-10-07 14:10:20 +00:00
controllers refactor: move autogen v1 and v2 packages (#11416) 2024-10-16 08:51:38 +00:00
cosign fix: Allow images to be pulled from insecure registry when allowInsecureRegistry flag is set to true (#10934) (#11243) 2024-10-07 15:29:12 +00:00
engine Selector with mutate target (#11208) 2024-10-16 11:17:08 +00:00
event chore: remove v1alpha1 of VAPs and use v1beta1 (#10955) 2024-08-29 15:31:25 +00:00
exceptions chore: use v2 clients for policy exceptions (#10530) 2024-06-24 16:36:55 +00:00
globalcontext fix(status): status comparison is wrong (#11203) 2024-09-24 15:17:38 +00:00
images fix: Allow images to be pulled from insecure registry when allowInsecureRegistry flag is set to true (#10934) (#11243) 2024-10-07 15:29:12 +00:00
imageverifycache fix: properly use useCache field in image verification policies (#10709) 2024-08-19 14:26:07 +00:00
informers feat: delete webhook configurations after kyverno is uninstalled (#10782) 2024-09-04 10:59:59 +00:00
leaderelection Remove dependency on github.com/pkg/errors (#6165) 2023-02-01 14:38:04 +08:00
logging chore(log): add caller (#10874) 2024-08-16 14:08:55 +00:00
metrics chore: pin go.opentelemetry.io/otel/semconv/v1.24.0 (#11256) 2024-09-27 16:39:55 +05:30
notary fix: Allow images to be pulled from insecure registry when allowInsecureRegistry flag is set to true (#10934) (#11243) 2024-10-07 15:29:12 +00:00
policy refactor: move autogen v1 and v2 packages (#11416) 2024-10-16 08:51:38 +00:00
policycache refactor: move autogen v1 and v2 packages (#11416) 2024-10-16 08:51:38 +00:00
profiling refactor: introduce cmd internal package (#5404) 2022-11-18 22:21:15 +08:00
pss fix: concurrent map read and map write when applying a validate.podSecurity rule (#11012) 2024-09-04 17:05:10 +00:00
registryclient fix: Allow images to be pulled from insecure registry when allowInsecureRegistry flag is set to true (#10934) (#11243) 2024-10-07 15:29:12 +00:00
tls chore: set cert renewal time to 15 days before expiration (#8567) 2023-12-06 13:37:01 +00:00
toggle feat: add dumpPatch flag (#11237) 2024-09-25 13:11:43 +00:00
tracing chore: pin go.opentelemetry.io/otel/semconv/v1.24.0 (#11256) 2024-09-27 16:39:55 +05:30
userinfo refactor: reduce userinfos deps and add unit tests (#6524) 2023-03-10 09:09:19 +00:00
utils feat: update engine response.generatedResources to support multiple resource (#11398) 2024-10-15 14:59:18 +08:00
validatingadmissionpolicy feat: use pointer in rule (exclude field) (#11050) 2024-09-10 11:14:49 +00:00
validation refactor: move autogen v1 and v2 packages (#11416) 2024-10-16 08:51:38 +00:00
version fix: use golang builtin version management (#7654) 2023-06-30 23:27:06 +00:00
webhooks refactor: move autogen v1 and v2 packages (#11416) 2024-10-16 08:51:38 +00:00