Commit Graph

7 Commits

Author SHA1 Message Date
Matt Moore 16b36b7fca
Add support for admission webhook warnings. (#2498)
* Add support for admission webhook warnings.

This extends `apis.FieldError` to support designating certain FieldErrors as "warnings" (or explicitly as "errors", however, this is the default for back-compat).

You can turn an `apis.FieldError` into a warning using: `fe.At(apis.WarningLevel)` or force it into an error using: `fe.At(apis.ErrorLevel)`.

You can get the errors at a particular diagnostic level using: `fe.Filter(apis.WarningLevel)`.

This change also hooks this into the admission webhook infrastructure to support surfacing the "warning" level `apis.FieldError`s via the `Warnings` section of the `AdmissionResponse`.

Fixes: #2497

* Add a comment about the use of defer.
2022-05-02 21:56:57 +00:00
Victor Agababov a371418524
v2 (#1754) 2020-09-29 13:18:29 -07:00
Dave Protasowski caa444033b
use crd & webhook v1 APIs (#1391) 2020-06-19 08:43:25 -07:00
whaught d22642244e
Allow Unstructured callback from Validating Webhook (#1172)
* Add new callback pattern to pkg

* include the context

* typo

* Remove the empty instance of unstructured

* initialize the unstructured var

* Eliminate the unneeded pointer

* Pass a pointer to unstructured callback

* Create a validation specific context struct

* Move callback tests to own unit test case

* Switch from converting to decoding

* Update webhook/resourcesemantics/validation/validation.go

Co-Authored-By: Victor Agababov <vagababov@gmail.com>

* don't wrap context and include params

* split validation files

* include 2020 copyright

* include unit test for WithKubeClient

* Don't bother updating copyright date

* Inclue a unit test for panic

* Move dryRun to context

* Include context dry run unit test

* put the request operation in the context

* eliminate circular dep

* move kubeclient test out of context_test

* dont bother iterating callback map

* Callback takes a list of supported verbs

* Remove extra type

* Ensure Callback interface is public

* Alias Operation into validation

* alias Operation right in Webhook

* Update webhook/resourcesemantics/validation/validation_admit.go

Co-Authored-By: Victor Agababov <vagababov@gmail.com>

* Update webhook/resourcesemantics/validation/validation_admit_test.go

Co-Authored-By: Victor Agababov <vagababov@gmail.com>

* Update webhook/resourcesemantics/validation/validation_admit_test.go

Co-Authored-By: Victor Agababov <vagababov@gmail.com>

* Update webhook/resourcesemantics/validation/validation_admit.go

Co-Authored-By: Victor Agababov <vagababov@gmail.com>

* Update webhook/resourcesemantics/validation/validation_admit.go

Co-Authored-By: Victor Agababov <vagababov@gmail.com>

* Update webhook/resourcesemantics/validation/validation_admit_test.go

Co-Authored-By: Victor Agababov <vagababov@gmail.com>

* correct parens

* minor style fixes

* Rename Callback to Func

* Fix build error

* Switch callback to take a list with a factory

* keep descriptive names

* update comment

* Drop pointer, correct comments

* Add a unit test to disallow duplicate verbs

* fix comments, struct{} for set

* switch to variadic arg for NewCallback

Co-authored-by: Victor Agababov <vagababov@gmail.com>
2020-04-06 12:22:19 -07:00
cshou 1cc3c3e852
Update jsonpatch lib that correctly handle object removal (#1078)
* update jsonpatch lib

* add more patch tests for removal
2020-02-12 08:27:22 -08:00
Markus Thömmes 56c2594e4f Assorted linting fixes. (#840)
* Remove unused code.

* Remove unneeded loops.

* Remove unneeded Printf calls.

* Use time.Since instead of time.Now().Sub.

* Remove unused values.

* Rename error variable according to conventions.

* Return error last.

* Simplify array allocations.

* Remove leaky ticker.

* Remove Yoda conditions.

* Remove deprecated function to talk to GKE.

* Remove dot import.

* Remove empty critical section and replace with a channel operation.

* Add linter directives to explicitly state wanted weirdness.

* Update deps.

* Fix broken line.
2019-11-01 12:49:12 -07:00
Matt Moore 50398a29a7 Factor out test helpers to prepare for webhook package split. (#829) 2019-10-29 14:13:11 -07:00