1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
Commit graph

70 commits

Author SHA1 Message Date
Abhinav Sinha
f0359f8272
Fixed error handling for negation anchors (#2986)
* Fixed error handling for negation anchors

Signed-off-by: Abhinav Sinha <abhinav@nirmata.com>

Co-authored-by: Vyankatesh Kudtarkar <vyankateshkd@gmail.com>
2022-01-19 15:39:07 +05:30
Jim Bugwadia
a9fef256c7
updates for foreach and mutate (#2891)
* updates for foreach and mutate

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* allow tests to pass on Windows

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* fix tests

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* fix linter check

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* add elementIndex variable

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* fmt

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* fix jsonResult usage

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* add mutate validation and fix error in validate.foreach

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* format

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* update message

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* do not skip validation for all array entries when one is skipped

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* add foreach tests

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* fix fmt

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* fix format errors

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* remove unused declarations

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* revert namespaceWithLabelYaml

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* fix mutate of element list

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* update CRDs

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* Update api/kyverno/v1/policy_types.go

Co-authored-by: Steven E. Harris <seh@panix.com>

* Update pkg/engine/forceMutate.go

Co-authored-by: Steven E. Harris <seh@panix.com>

* Update pkg/engine/forceMutate.go

Co-authored-by: Steven E. Harris <seh@panix.com>

* Update pkg/engine/forceMutate.go

Co-authored-by: Steven E. Harris <seh@panix.com>

* Update pkg/engine/mutation.go

Co-authored-by: Steven E. Harris <seh@panix.com>

* Update pkg/engine/mutation.go

Co-authored-by: Steven E. Harris <seh@panix.com>

* Update pkg/engine/mutation.go

Co-authored-by: Steven E. Harris <seh@panix.com>

* Update pkg/engine/validate/validate.go

Co-authored-by: Steven E. Harris <seh@panix.com>

* Update pkg/engine/validate/validate.go

Co-authored-by: Steven E. Harris <seh@panix.com>

* Update test/cli/test/custom-functions/policy.yaml

Co-authored-by: Steven E. Harris <seh@panix.com>

* Update test/cli/test/foreach/policies.yaml

Co-authored-by: Steven E. Harris <seh@panix.com>

* accept review comments and format

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* add comments to strategicMergePatch buffer

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* load context and evaluate preconditions foreach element

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* add test for foreach mutate context and precondition

* precondition testcase

* address review comments

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* update message

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

* format

Signed-off-by: Jim Bugwadia <jim@nirmata.com>

Co-authored-by: Steven E. Harris <seh@panix.com>
Co-authored-by: Vyankatesh Kudtarkar <vyankateshkd@gmail.com>
2022-01-05 09:36:33 +08:00
Anushka Mittal
3089edafa4
Extend new operators (#2788)
* extending new operators

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* Changes in file names

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* tests added

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* removed print statements

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* Changes to reduce code redundancy

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* Minor corrections in anyin and allin

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* added correction for anynotin and allnotin

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>
2022-01-04 17:37:00 +00:00
Lukasz Jakimczuk
40b579ccd7
Improving readability (#2638)
Signed-off-by: Łukasz Jakimczuk <lukasz.j@giantswarm.io>
2021-10-29 14:48:22 +02:00
Lukasz Jakimczuk
ca975b8e99
*Range Operators (#2622)
* Range operator: first iteration

Signed-off-by: Łukasz Jakimczuk <lukasz.j@giantswarm.io>

* Changing hyphen to colon

Signed-off-by: Łukasz Jakimczuk <lukasz.j@giantswarm.io>

* Accounting for negative numbers

Signed-off-by: Łukasz Jakimczuk <lukasz.j@giantswarm.io>

* View on the second version

Signed-off-by: Łukasz Jakimczuk <lukasz.j@giantswarm.io>

* Adding tests to the operator

Signed-off-by: Łukasz Jakimczuk <lukasz.j@giantswarm.io>

* Renoving negative support

Signed-off-by: Łukasz Jakimczuk <lukasz.j@giantswarm.io>

* Adding comment

Signed-off-by: Łukasz Jakimczuk <lukasz.j@giantswarm.io>

* Signing

Signed-off-by: Łukasz Jakimczuk <lukasz.j@giantswarm.io>

* Going for the regexp version of operator

Signed-off-by: Łukasz Jakimczuk <lukasz.j@giantswarm.io>

* Adding negative range operator

Signed-off-by: Łukasz Jakimczuk <lukasz.j@giantswarm.io>
2021-10-29 13:48:23 +02:00
Bricktop
d62234d776
Fix remaining static check findings (#2541)
Signed-off-by: Marcel Mueller <marcel.mueller1@rwth-aachen.de>
2021-10-13 16:00:41 -07:00
Bricktop
3f15ec5a1e
Remove dead code and unused variables (#2537)
* Remove dead code and unused variables

Signed-off-by: Marcel Mueller <marcel.mueller1@rwth-aachen.de>

* Remove unnecessary definitions

Signed-off-by: Marcel Mueller <marcel.mueller1@rwth-aachen.de>
2021-10-13 22:45:23 +02:00
Bricktop
3815b40c64
Fix various static checks related to condition handling (#2528)
Signed-off-by: Marcel Mueller <marcel.mueller1@rwth-aachen.de>
2021-10-13 11:29:45 +02:00
Bricktop
2d0df77963
Format error messages correctly (#2519)
* Format error messages correctly

Signed-off-by: Marcel Mueller <marcel.mueller1@rwth-aachen.de>

* No punctuation at the end or errors

Signed-off-by: Marcel Mueller <marcel.mueller1@rwth-aachen.de>

* Replace loop with simple if

Signed-off-by: Marcel Mueller <marcel.mueller1@rwth-aachen.de>

* Fix more errors

Signed-off-by: Marcel Mueller <marcel.mueller1@rwth-aachen.de>
2021-10-12 14:29:20 -07:00
Sachin
e16d773957
Remove unused function (#2517) 2021-10-11 12:46:28 -07:00
Bricktop
67a2466c32
Remove dead code in various packages (#2514) 2021-10-11 12:44:43 -07:00
shuting
b10947b975
Dynamic webhooks (#2425)
* support k8s 1.22, update admissionregistration.k8s.io/v1beta1  to admissionregistration.k8s.io/v1

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* - add failurePolicy to policy spec; - fix typo

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* - add schema validation for failurePolicy; - add a printer column

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* set default failure policy to fail if not defined

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* resolve conflicts

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* fix missing type for printerColumn

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* refactor policy controller

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* add webhook config manager

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* - build webhook objects per policy update; - add fail webhook to default webhook configurations

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* fix panic on policy update

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* build default webhook: match empty if autoUpdateWebhooks is enabled, otherwise match all

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* - set default webhook configs rule to empty; - handle policy deletion

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* reset webhook config if policies with a specific failurePolicy are cleaned up

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* handle wildcard pocliy

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* update default webhook timeout to 10s

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* cleanups

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* added webhook informer to re-create it immediately if missing

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* update tag webhookTimeoutSeconds description

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* fix e2e tests

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* fix linter issue

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* correct metric endpoint

Signed-off-by: ShutingZhao <shutting06@gmail.com>

* add pol.generate.kind to webhooks

Signed-off-by: ShutingZhao <shutting06@gmail.com>
2021-10-05 00:15:09 -07:00
Jim Bugwadia
731ffde0e7 fix messages and tests
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
2021-10-03 03:15:22 -07:00
Jim Bugwadia
89d1e4afab format
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
2021-10-02 16:57:40 -07:00
Jim Bugwadia
e0e6074afc add validation; add 'element' to context
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
2021-10-02 16:53:02 -07:00
Jim Bugwadia
1ebd2c99f2 add messages and set rule to skip when pattern does not match
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
2021-09-30 23:34:04 -07:00
Jim Bugwadia
6ae3063038 merge main
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
2021-09-30 11:53:33 -07:00
NoSkillGirl
9513cca68f removing commented test case
Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
2021-09-29 11:02:07 +05:30
NoSkillGirl
ff540bfb06 removing print statement
Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
2021-09-29 10:59:54 +05:30
NoSkillGirl
83a815d7cf added test cases
Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
2021-09-28 20:17:03 +05:30
Jim Bugwadia
3957a1400e fix deny check and fmt
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
2021-09-27 23:40:05 -07:00
Jim Bugwadia
a905a61581 fix deny rules
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
2021-09-27 14:28:55 -07:00
Jim Bugwadia
536b64bed1 fix tests
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
2021-09-26 21:15:13 -07:00
Jim Bugwadia
67660647d9 update tests
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
2021-09-26 18:30:53 -07:00
Jim Bugwadia
39061d91c4 implement validate.foreach
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
2021-09-26 02:12:31 -07:00
NoSkillGirl
f9c789967c added test cases
Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
2021-09-23 15:01:34 +05:30
NoSkillGirl
799ae0f80d added test cases
Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
2021-09-22 14:33:59 +05:30
NoSkillGirl
d6e977a34d updated logic for key in resources
Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
2021-09-22 01:51:57 +05:30
NoSkillGirl
aba3bad8fc adding logic for checking key in resources
Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
2021-09-21 20:15:09 +05:30
NoSkillGirl
4a5d4a2bac debugging
Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
2021-09-21 12:12:34 +05:30
Max Goncharenko
a0ff8bbd0b
Implement global anchor (#2311)
* implement global anchor for patch strategic merge

Signed-off-by: Max Goncharenko <kacejot@fex.net>

* fixed unit tests for mutation global anchor

Signed-off-by: Max Goncharenko <kacejot@fex.net>

* added global anchor in validation

Signed-off-by: Max Goncharenko <kacejot@fex.net>

* fix some global anchor issues found during testing

Signed-off-by: Max Goncharenko <kacejot@fex.net>

* run go tidy

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* fixed tests

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* fixed some tests

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* finish implementing global anchor

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* WIP: lower global anchor strictness

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* Revert "WIP: lower global anchor strictness"

This reverts commit 08e176a042.

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* global anchor for mutation

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>
2021-09-13 08:59:28 -07:00
Max Goncharenko
4c7ca97eac
Patch strategic merge preprocessing: implement anchor handling (#2156)
* finished walkMap

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* added validation to the patchStrategicMerge

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* finished fixing tests

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* fixed part of old tests

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* patchStrategicMerge anchor preprocessing is finished

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* fix #1915 and #1896

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* fix lint errors

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* removed debug logs

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* added failing test

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>

* Fix unnecessary deletion

Signed-off-by: Maxim Goncharenko <goncharenko.maxim@apriorit.com>
2021-07-23 10:53:37 -07:00
treydock
3b1fd912cb
Move log to debug for wildcard pattern matching (#2064)
Signed-off-by: Trey Dockendorf <tdockendorf@osc.edu>
2021-06-23 16:48:09 -07:00
Arsh Sharma
7e9be24d90
updating minio verison (#1956) 2021-06-09 19:16:26 -07:00
RinkiyaKeDad
29c6e901ab added test, removed comment
Signed-off-by: RinkiyaKeDad <arshsharma461@gmail.com>
2021-06-03 11:16:50 +05:30
RinkiyaKeDad
e94479717c fixed spacing problem in operators
Signed-off-by: RinkiyaKeDad <arshsharma461@gmail.com>
2021-06-02 12:16:54 +05:30
Max Goncharenko
0776b438d3
Support operators (>=, <, etc ...) on list values (#1838)
Signed-off-by: Max Goncharenko <kacejot@fex.net>
2021-04-28 13:31:55 -07:00
Max Goncharenko
24c4f06ecd Fix #1506; Resolve path reference in entire rule instead of just pattern/overlay
Signed-off-by: Max Goncharenko <kacejot@fex.net>
2021-03-16 13:45:40 +02:00
Max Goncharenko
536f364724
Add AND logical operator support (#1539)
Signed-off-by: Max Goncharenko <kacejot@fex.net>
2021-02-05 17:52:31 -08:00
shuting
ab5f2274f9
1314 validate rule (#1368)
* fixes 1314

* fix panic
2020-12-08 22:52:37 -08:00
Jim Bugwadia
1c2262b6e2 merge main 2020-12-04 16:52:10 -08:00
Jim Bugwadia
f3b644f624 handle anchors in keys 2020-12-04 15:59:15 -08:00
Jim Bugwadia
13a9a4721a
wildcard label and annotation keys validate patterns (#1360) 2020-12-04 12:05:24 -08:00
Jim Bugwadia
44afdf2f95 wildcard label and annotation keys validate patterns 2020-12-04 09:28:30 -08:00
Shuting Zhao
e985ee4031 correct misspelled words 2020-11-17 12:01:01 -08:00
Shuting Zhao
8e0650804f improve error log 2020-11-03 15:41:17 -08:00
Shuting Zhao
d8d5160bce fix #1192 2020-11-03 15:31:58 -08:00
Jim Bugwadia
062d794cad fix conversion errors 2020-10-22 11:59:11 -07:00
Shuting Zhao
cdc5190c56 update nirmata/kyverno to kyverno/kyverno 2020-10-07 11:12:31 -07:00
Mohan B E
a827f88dc7
resolved conditional anchor issue and added validation to pattern labels (#1060)
* resolved conditional anchor issue and added validation to pattern labels

* restored IsConditionAnchor

* added annotation and anypattern validation

* added conditional anchor key checker

* reverted docs

* fixed tests

* modified validation

* modified validate condition check
2020-08-28 18:22:22 -07:00