1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 16:06:56 +00:00
Commit graph

997 commits

Author SHA1 Message Date
Charles-Edouard Brétéché
b908b1037a
feat: consider validation actions (#12072)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-02-04 06:29:40 +02:00
Charles-Edouard Brétéché
884a77a044
feat: add context provider in admission handling (#12070)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-02-03 19:11:31 +02:00
Vishal Choudhary
7d8ed212a4
feat: create image data loader (#12036)
* feat: add image data loader to context

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* fix: build

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* fix: linter

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* feat: tests

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* fix: update types

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* feat: replace crane with remote

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* fix: linter

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* fix: linter

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

---------

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-02-03 13:42:40 +00:00
Mariam Fahmy
4c950dcb32
feat: use v1 of ValidatingAdmissionPolicies (#12050)
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
2025-01-31 14:21:43 +00:00
Charles-Edouard Brétéché
dfa9f2f727
feat(validating policies): add support for ns and object selectors (#12034)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-30 01:07:01 +02:00
Charles-Edouard Brétéché
30360e871a
feat: execute handler (#12033)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-29 11:24:13 -08:00
Charles-Edouard Brétéché
1d3a9294cc
feat: watch validating policies (#12008)
* feat: watch validating policies

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* rest config

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-28 16:24:40 +00:00
Charles-Edouard Brétéché
60315cb3a0
feat: add rest config support in setup code (#12019)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Co-authored-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
2025-01-28 14:53:14 +00:00
Mariam Fahmy
da717c4b17
feat: add validation action to VPs (#12017)
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
2025-01-28 14:34:26 +01:00
Charles-Edouard Brétéché
92436bf4ed
refactor: use k8s wait group (#12010)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-27 23:25:33 +00:00
Charles-Edouard Brétéché
f6494287cc
fix: make flags compatible with controller-runtime (#12009)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-27 22:42:39 +00:00
Charles-Edouard Brétéché
620ddd80d1
test: add more cli vp tests (#12006)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-27 17:17:08 +08:00
Charles-Edouard Brétéché
a5fe768a53
feat: implement cel engine context provider (#11995)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-24 15:42:58 +00:00
Charles-Edouard Brétéché
f5467fcd61
refactor: reduce generic policy interface (#11977)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-22 16:32:30 +00:00
Charles-Edouard Brétéché
61d69c9290
refactor: reduce generic policy interface (#11974)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-22 09:03:48 +00:00
Charles-Edouard Brétéché
54a8a53205
feat: add validating policy engine api wrapper (#11963)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-21 15:59:34 +08:00
Charles-Edouard Brétéché
6535cb763d
fix: cli schema generation (#11959)
* fix: cli schema generation

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix: cli schema generation

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-20 22:00:41 +08:00
Charles-Edouard Brétéché
a30fc14d4d
feat: add namespace support in CLI values (#11958)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-20 13:43:13 +02:00
Charles-Edouard Brétéché
5cc408dddb
feat: use policy provider (#11947)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-20 09:43:05 +00:00
Ammar Yasser
da3d5247fa
log non fatal parsing errors (#11932)
* log non fatal parsing errors

Signed-off-by: Your Name <you@example.com>

* log at the error level

Signed-off-by: Your Name <you@example.com>

* add check for nil

Signed-off-by: Your Name <you@example.com>

* add check for nil

Signed-off-by: Your Name <you@example.com>

---------

Signed-off-by: Your Name <you@example.com>
Co-authored-by: Your Name <you@example.com>
Co-authored-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
2025-01-17 15:46:57 +00:00
Charles-Edouard Brétéché
7351501ef6
feat(cli,apply): load validating policies (#11933)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-17 09:53:17 +00:00
shuting
97ed53f6bb
feat: register webhook configurations for validatingpolicies (#11892)
* feat: add spec.webhookConfiguration

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: refactor build webhook for kyverno policies

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: update yamls

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: add listers

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* feat: update api

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: remove matchPolicy

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: update crd yaml

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: add short name

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: update deepcopy

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: upadte spec

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: fix description

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: add missing files

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* feat: register webhook for validatingpolicies

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: fix import

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: add unit tests

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: update docs

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: update manifests

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: update unit tests

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* chore: update manifests

Signed-off-by: ShutingZhao <shuting@nirmata.com>

---------

Signed-off-by: ShutingZhao <shuting@nirmata.com>
2025-01-17 11:33:47 +02:00
Mariam Fahmy
782641d3ff
fix the result column for Kyverno test (#11842)
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
2025-01-16 15:29:30 +00:00
Mariam Fahmy
a72868bd6f
chore: move CEL package to admissionpolicy package (#11931)
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
2025-01-15 13:04:18 +00:00
Charles-Edouard Brétéché
a50911d8b5
refactor: cleanup cli apply functions (#11928)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-15 12:19:57 +02:00
Charles-Edouard Brétéché
4e84edff68
feat: add support for loading validating policies in the cli (#11883)
* feat: add support for loading validating policies in the cli

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* copy data

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* legacy loader

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-01-10 10:43:48 +00:00
raffis
306a2e47d9
fix(reports-controller): add a flag to disable reports sanity checks (#11867)
* fix(reports-controller): remove crd sanity check

Signed-off-by: Raffael Sahli <raffael.sahli@doodle.com>

* feat: add a flag to disable reports sanity checks

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* feat: add changelog

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

---------

Signed-off-by: Raffael Sahli <raffael.sahli@doodle.com>
Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
Co-authored-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
Co-authored-by: shuting <shuting@nirmata.com>
2025-01-09 17:03:23 +08:00
Charles-Edouard Brétéché
823661e4af
fix: sorting in fix test command (#11869) 2025-01-08 13:30:15 +00:00
Rokibul Hasan
236ac9c216
Add flag for JSON output in policy reports (#11840)
* Add flag for JSON output in policy reports

Signed-off-by: Rokibul Hasan <mdrokibulhasan@appscode.com>

* make codegen-docs-all

Signed-off-by: Rokibul Hasan <mdrokibulhasan@appscode.com>

---------

Signed-off-by: Rokibul Hasan <mdrokibulhasan@appscode.com>
Co-authored-by: shuting <shuting@nirmata.com>
2025-01-07 06:22:11 +00:00
Damien Degois
c282f71212
remove policy exception dependancy from globalcontext and add some tests (#11788)
Signed-off-by: Damien Degois <damien@degois.info>
Co-authored-by: shuting <shuting@nirmata.com>
2025-01-03 16:16:37 +00:00
Ammar Yasser
739e6a21c4
Mutate existing CLI support (#11453)
* feat: Add flags for target resources and add fake client initialization

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

* feat: Add fake discovery client and cluster bool in the policy processor

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

* refactor: Use the full mutation engine policy response in the engine response

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

* feat: Extract mutated targets from the policy responses and print them out

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

* feat: Add TargetResources field in the cli test schema

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

* chore: Generate CLI crds

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

* refactor: modify checkResult to take an arbitrary actual resource and resource name

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

* refactor: change getAndCompareResource to take a resource name and cascade it to GetResourceFromPath

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

* test: Create a simple test to test mutate existing in the CLI

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

* refactor: Allow GetResourceFromPath to select a resource with a name from a multi resource yaml

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

* refactor: Modify the runTest command to return the TestResponse type

- Create a fake client, load the target resources in it and use it in the PolicyProcessor.
- Create the TestResponse which contains Trigger and Target fields, each is a map of gvk/name to the responses corresponding to that resource.

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

* refactor: Rewrite output.go to use the TestResponse type

- Check for both target and trigger
- Create logic for appending the resource array in case no resources are passed
- Move row creation logic into a separate method to avoid code duplication
- Extract the proper target resource based on rule type
- Create a function to extract mutated target from the engine response

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

* chore: Move tests to the correct folder

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

* refactor: Use apiVersion/Kind/Name as the key in the test responses

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

* refactor: Use the apiVersion/Kind/name key schema in checking results and fix invalid resource name checking for generate policies

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

* fix: Use better variable names for rows

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

* refactor: Account for Generate resources being an array

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

* fix: Use generated resource name in checking the results and printing output

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

* chore: Uncomment checks printing

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

* fix: Remove bug in engine response creation

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

* fix: Move the generate logic into an else block

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

* fix: Fix namespace fetching bug in cel validator

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

* fix: Use pointer to int in the test counter

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

* chore: Remove redundant method

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

* fix: Skip resources not being found in the manifests

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

* fix: Create another field in the engine to denote if this is a cluster engine or an offline engine

Simply checking for the client being nil is no longer enough because for cli operations the client will be a fake client
A pointer to bool is chosen because callers who don't necessarily know what to pass should be able to pass nil

Signed-off-by: ammar <ammar.yasser@vodafone.com>

* fix: Add extra argument in fake client initiation

Signed-off-by: ammar <ammar.yasser@vodafone.com>

* fix: add extra argument in fuzz test

Signed-off-by: ammar <ammar.yasser@vodafone.com>

* fix: Add extra arg

Signed-off-by: ammar <ammar.yasser@vodafone.com>

* fix: Handle resources specified as ns/name as this schema will be deprecated in favor of apiVersion/Kind/Name

Signed-off-by: ammar <ammar.yasser@vodafone.com>

* fix: Fix linter complaints

Signed-off-by: ammar <ammar.yasser@vodafone.com>

* fix: Use comma separation as array separators as kubernetes names don't support commas

To avoid undefined array length on splitting on /
using commas will result in a fixed length since all resources will have an apiVersion, kind, namespace and name

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

* refactor: Change resource array type to an array of any instead of array of string

To support the use of a string or a TestResourceSpec

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

* refactor: Expect the resource array to be an array of string or array of TestResourceSpec

Assert that an array element is either of these types and match the resources in both cases according to the element type
Expect that the key in responses is now separated by commas instead of slashes

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

* refactor: Expect that the resource array is now of type array of any and modify tests that use it

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

* fix: Skip response check if the policy name isnt whats in the result

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

* fix: Match the name if its specified as ns/name

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

* fix: Fix linter complaint

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

* chore: Run codegen

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

* chore: Create CLI CRDs

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

* chore: Run codegen

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

* fix: Fix linter complaints

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

* fix: Cleanup invalid code used in FixTest to adapt it to the schema changes

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

* fix: Check if resource is nil before extracting

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

* fix: use the loadResources method to open targets in a directory

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

* fix: Account for target resources with the same name but different namespaces

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

* fix: Add CLI test for mutate existing with the same name

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

* refactor: Infer resource name and namespace from the actual resource and account for resources with the same name and namespace but different kinds

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

* chore: remove extra line

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

* feat: Add printing mutate existing resources to the output or to a file

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

* chore: Minor fixes

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

* chore: fix linter complaint

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

* chore: codegen

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

* fix: Revert result back to error

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

* fix: Use io discard to not print resources in the test command

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

* chore: Update vague comments and remove outdated ones

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

* refactor: Integrate mutate existing changes with diff generation

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

* refactor: Move resource key generation into a function

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

* chore: Add a mutate existing test that fails

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

* chore: fix linter complaint

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

* chore: Remove redundant comment

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

* refactor: Fix array of any assignment in cli test

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

* fix: Dont check duplicate strings for field that is an array of any

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

* bug: Fix appending to the wrong array

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

* chore: run fix tests

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

* chore: Run fix tests

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

---------

Signed-off-by: aerosouund <aerosound161@gmail.com>
Signed-off-by: ammar <ammar.yasser@vodafone.com>
Signed-off-by: Ammar Yasser <aerosound161@gmail.com>
Co-authored-by: ammar <ammar.yasser@vodafone.com>
Co-authored-by: shuting <shuting@nirmata.com>
2024-12-19 07:42:54 +00:00
shuting
37d6936902
fix: revert default background scan interval to 1h (#11754)
Signed-off-by: ShutingZhao <shuting@nirmata.com>
2024-12-12 11:22:10 +00:00
Darshan Poudel
88c55c2b9d
fix/duplicate-test-entries-deduplication (#11709)
Signed-off-by: Darshan808 <pranishpoudel10@gmail.com>
Co-authored-by: shuting <shuting@nirmata.com>
2024-12-12 08:54:24 +00:00
Tomas Aschan
8746a8ffbb
feat: Show textual diff when generate test fails (#11674)
* feat: Show textual diff when generate test fails

Signed-off-by: Tomas Aschan <tomasl@spotify.com>

* Tweak verbosity level for diff output

Signed-off-by: Tomas Aschan <tomasl@spotify.com>

* Display a rich diff of the expected and actual resources with --detailed-results

Signed-off-by: Tomas Aschan <tomasl@spotify.com>

---------

Signed-off-by: Tomas Aschan <tomasl@spotify.com>
2024-12-04 06:09:19 +00:00
Yann ILAS
d215ce5344
Fix(doc): correct invalid links in documentation (#11681)
* Fix doc: s|kustomize/patchesjson6902|kustomize/kustomization/patchesjson6902|

Signed-off-by: Yann ILAS <yann.ilas@gmail.com>

* Fix doc: s|kustomize/patchesstrategicmerge|kustomize/kustomization/patchesstrategicmerge|

Signed-off-by: Yann ILAS <yann.ilas@gmail.com>

---------

Signed-off-by: Yann ILAS <yann.ilas@gmail.com>
2024-12-02 13:31:33 +00:00
Mariam Fahmy
f36d5410ea
fix: check the patchedResources in kyverno-test (#11686)
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
2024-12-02 12:59:12 +00:00
Ammar Yasser
d100202d22
Print generate output cli (#11634)
* refactor: Configure the policy processor to print generated resources

Refactor printMutatedOutput to printOutput which prints mutate or generate resources to a file or standard output
Introduce processGenerateResponse which extracts generated resources from the policy response and passes them to printOutput

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

* chore: Update flag description to specify mutated and generated resources

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

* chore: Run codegen

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

---------

Signed-off-by: aerosouund <aerosound161@gmail.com>
2024-11-27 08:33:05 +00:00
Ammar Yasser
07d758265a
fix: Open the mutated resources file in append mode to allow additions to it (#11619)
Signed-off-by: ammar <ammar.yasser@vodafone.com>
Co-authored-by: ammar <ammar.yasser@vodafone.com>
2024-11-20 15:51:36 +00:00
Mariam Fahmy
9a9d46bb5b
fix: support VAP stable version v1 in the CLI (#11501)
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
2024-10-31 09:00:17 +00:00
Mariam Fahmy
2ff41d10ca
fix: add emitWarning field in v2beta1 (#11489)
* fix: add emitWarning field in v2beta1

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>

* fix: add artificathub changes

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>

---------

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
2024-10-30 15:17:59 +00:00
Mariam Fahmy
cbfeb32b1a
fix[breaking]: disable exceptions by default (#11426)
* fix[breaking]: disable exceptions by default

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>

* fix chainsaw tests

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>

* fix: add warning in helm chart for exceptions

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>

---------

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
2024-10-22 06:07:11 +00:00
Vishal Choudhary
e3b74f1384
feat: add options to configure resync period for informers in helm chart (#11420)
* feat: add options to configure resync period for informers in helm chart

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* fix: codegen

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

---------

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
2024-10-17 15:23:17 +08:00
Charles-Edouard Brétéché
a5e082303d
refactor: introduce autogen interface (#11418)
* refactor: introduce autogen interface

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix linter

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2024-10-16 15:24:37 +02:00
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
Charles-Edouard Brétéché
4d1683d167
refactor: move autogen v1 and v2 packages (#11416)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2024-10-16 08:51:38 +00:00
Vishal Choudhary
a7dd02a6d1
feat: update engine response.generatedResources to support multiple resource (#11398)
* fix: manually add generated_resources property

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* fix: update engine response

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* fix: nil check before deferences

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* fix: outdated errors

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* fix: linter

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

---------

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
Co-authored-by: shuting <shuting@nirmata.com>
2024-10-15 14:59:18 +08:00
Vishal Choudhary
ec546e6fb4
feat: add helm configuration for reporting in different rules (#11376)
* feat: add helm configuration for reporting in different rules (forgot signoff)

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* fix: linter and tests

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* feat: rename reporting.imageVerification

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

---------

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
Signed-off-by: ShutingZhao <shuting@nirmata.com>
Co-authored-by: shuting <shuting@nirmata.com>
2024-10-11 09:42:29 +00:00
Ammar Yasser
c56c60c136
Reports controller circuit breaker (#11329)
* chore: Fix spelling issue in breaker logging

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

* feat: Introduce circuit breaking in background report scanning

Add the breaker as a field of the background controller and use it in the storeReport method which handles report creation

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

* feat: Add required flags and instantiation for the circuit breaker in the background reports controller

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

* fix: Add flag for max background reports in the reports controller

Signed-off-by: ammar <ammar.yasser@vodafone.com>

* chore: Update flag description to use ephemeralreports instead of background reports

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

* chore: Use a less verbose description for the flag

Co-authored-by: shuting <shuting@nirmata.com>
Signed-off-by: Ammar Yasser <aerosound161@gmail.com>

---------

Signed-off-by: aerosouund <aerosound161@gmail.com>
Signed-off-by: ammar <ammar.yasser@vodafone.com>
Signed-off-by: Ammar Yasser <aerosound161@gmail.com>
Co-authored-by: ammar <ammar.yasser@vodafone.com>
Co-authored-by: Jim Bugwadia <jim@nirmata.com>
Co-authored-by: shuting <shuting@nirmata.com>
2024-10-11 07:34:41 +00:00
Mohd Kamaal
733063bb24
Add permission command to generate ClusterRole and ClusterRoleBinding (#11211)
* Add permission command to generate ClusterRole and ClusterRoleBinding

Signed-off-by: Mohdcode <mohdkamaal2019@gmail.com>

* Add permission command to generate ClusterRole and ClusterRoleBinding

Signed-off-by: Mohdcode <mohdkamaal2019@gmail.com>

* Update command_test.go

Signed-off-by: Mohd Kamaal <102820439+Mohdcode@users.noreply.github.com>

---------

Signed-off-by: Mohdcode <mohdkamaal2019@gmail.com>
Signed-off-by: Mohd Kamaal <102820439+Mohdcode@users.noreply.github.com>
Co-authored-by: Jim Bugwadia <jim@nirmata.com>
2024-10-10 14:03:16 +00:00
Vishal Choudhary
21fd92e3e4
feat: add --backgroundReports flag to disable mutateexisting and generate reporting (#11361)
Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
2024-10-09 10:43:59 +00:00