1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-12 02:46:56 +00:00
kyverno/pkg/client/applyconfigurations/kyverno/v1
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
..
anyallconditions.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
apicall.go fix: global context crd improvements (#9621) 2024-02-02 17:42:20 +00:00
attestation.go feat:Add support for condition validation across multiple image verification attestations or context entry (#9960) 2024-09-05 10:33:37 +00:00
attestor.go feat: add support for signature algorithm in cosign cert and kms verification (#10086) 2024-09-05 06:57:44 +00:00
attestorset.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
autogenstatus.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
cel.go chore: remove v1alpha1 of VAPs and use v1beta1 (#10955) 2024-08-29 15:31:25 +00:00
certificateattestor.go feat: migrate ignoreSCT from rekor to ctlog (#8166) 2023-08-30 08:39:49 +02:00
clonefrom.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
clonelist.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
clusterpolicy.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
condition.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
configmapreference.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
contextapicall.go feat:support default value into apiCall context variables (#10594) 2024-09-05 13:57:44 +08:00
contextentry.go feat: add globalcontext loader and interface (#9602) 2024-02-05 11:24:37 +00:00
ctlog.go feat: add TSA cert chain support in cosign (#9961) 2024-03-30 20:50:07 +00:00
deny.go feat(json): unmarshal at decode time (#10700) 2024-08-05 15:46:50 +03:00
dryrunoption.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
foreachgeneration.go feat: foreach support for clone (#10888) 2024-08-29 11:59:22 +00:00
foreachmutation.go feat(mutate): minimize unmarshals (#10702) 2024-08-09 11:12:20 +00:00
foreachvalidation.go feat(json): unmarshal once per policy (#10701) 2024-07-30 10:52:41 +00:00
generatepattern.go feat: foreach support for clone (#10888) 2024-08-29 11:59:22 +00:00
generation.go feat: foreach support for clone (#10888) 2024-08-29 11:59:22 +00:00
globalcontextentryreference.go feat: add globalcontext loader and interface (#9602) 2024-02-05 11:24:37 +00:00
httpheader.go support HTTP headers in service API calls (#11041) 2024-09-09 21:04:08 +00:00
imageextractorconfig.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
imageregistry.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
imageregistrycredentials.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
imageverification.go feat:Add support for condition validation across multiple image verification attestations or context entry (#9960) 2024-09-05 10:33:37 +00:00
keylessattestor.go feat: add full regexp support to cosign (#10815) 2024-08-16 07:03:59 +00:00
manifests.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
matchresources.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
mutation.go feat: add mutateExistingOnPolicyUpdate field under the mutate rule (#10461) 2024-06-19 09:29:19 +00:00
objectfieldbinding.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
podsecurity.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
podsecuritystandard.go Unit tests for Pod Security Admission Integrations (#8585) 2023-12-26 22:28:08 +08:00
policy.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
policystatus.go feat: generate validating admission policies and their bindings from Kyverno policies (#7840) 2023-08-31 10:25:21 +00:00
rekor.go feat: migrate ignoreSCT from rekor to ctlog (#8166) 2023-08-30 08:39:49 +02:00
requestdata.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
resourcedescription.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
resourcefilter.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
resourcespec.go fix: generate policy fails if triggered resource name exceeds 63 characters limit (#8466) 2023-11-06 10:37:13 +00:00
rule.go feat: enable custom data in policy reports using properties (#10933) 2024-09-03 17:36:07 +00:00
rulecountstatus.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
secretreference.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
servicecall.go support HTTP headers in service API calls (#11041) 2024-09-09 21:04:08 +00:00
spec.go feat: show violations and mutations as warning (#10214) 2024-09-05 10:02:00 +00:00
statickeyattestor.go feat: migrate ignoreSCT from rekor to ctlog (#8166) 2023-08-30 08:39:49 +02:00
targetresourcespec.go Selector with mutate target (#11208) 2024-10-16 11:17:08 +00:00
targetselector.go Selector with mutate target (#11208) 2024-10-16 11:17:08 +00:00
userinfo.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
validateimageverification.go feat:Add support for condition validation across multiple image verification attestations or context entry (#9960) 2024-09-05 10:33:37 +00:00
validatingadmissionpolicystatus.go feat: generate validating admission policies and their bindings from Kyverno policies (#7840) 2023-08-31 10:25:21 +00:00
validation.go fix: allow changes to preexisting resources that violate a validate foreach, cel or pss policy (#10033) 2024-09-06 06:42:56 +00:00
validationfailureactionoverride.go feat: add applyconfiguration-gen support (#7768) 2023-07-10 15:23:25 +05:30
variable.go feat(json): reduce reliance on DocumentToUntyped() (#10724) 2024-07-29 11:57:20 +00:00
webhookconfiguration.go feat: migrate webhookTimeoutSeconds and failurePolicy (#10515) 2024-06-20 13:04:37 +00:00