Commit Graph

14 Commits

Author SHA1 Message Date
Dave Protasowski ee1db869c7
Update linter config and address lint warnings/failures (#3068)
* fix whitespace linter

* fix usestdlibvars

* fix staticheck

* ignore spancheck warning

* fix linter perfsprint

* fix nolintlint feedback

* fix nilerr lint checks

* fix misspell

* fix mirror lint

* fix intrange linter

* fix gofumpt linter

* fix gosec linter - ignore warning since default min tls version is 1.3

* fix gocritic linter

* fix whitespace

* fix fatcontext linter

* fix errorlint

* fix errname linter

* fix copyloopvar (go1.22) linter

* fix bodyclose linter

* update linter config

* add script to format code

* fix unit test
2024-06-25 14:49:36 +00:00
Dave Protasowski 8535fcc248
gofumpt the repo (#3067)
* gofumpt the repo

* don't prefix numbers with 0 - otherwise they're octal
2024-06-25 07:27:07 +00:00
Paul Schweigert aad4309963
sets mutating webhook ReinvocationPolicy to ifNeeded (#2472)
Signed-off-by: Paul S. Schweigert <paulschw@us.ibm.com>
2022-06-07 15:53:37 +00:00
Pierangelo Di Pilato f4b57aef00
Fix invalid creator or lastModifier annotations on core resources (#2409)
When the admission request is for a resource with an empty string as
group, which happens on core resources, the `creator` or `lastModifier`
annotations are invalid since they become `/creator` or
`/lastModifier`.

This patch removes the `/` when group = `""`.

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2022-01-31 06:49:30 -08:00
Pierangelo Di Pilato 0a429cba1c
Allow Unstructured callback from Defaulting Webhook (#2363)
* Add support for callback defaults

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Put unstr object in ctx and set user info

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Move get callback at the top

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Panic when using delete verb

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Split tests and add callback ctx tests

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Set user info annotations

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Register Webhook Rules from callbacks

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>

* Adapt unstructured objects to apis.HasSpec

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>

* Change json tag name to match struct field name

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2022-01-14 06:18:42 -08:00
Dave Protasowski 0482448aac
allow unknown metadata fields (#2249)
* allow unknown metadata fields

* fix lint warnings

* include tests for nested structures in the metadata value
this is for catching any regressions
2021-09-02 07:33:06 -07:00
Victor Agababov 7bad843466
Enable golint and exclude some other generated or additional dirs (#1783)
* Enable golint and exclude some other generated or additional dirs

Also remove `test` ignore, since it's covered by path ignore rule.

* meh

* fixes

* more

* progressing

* further

* like a boss
2020-10-07 14:58:20 -07: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
Markus Thömmes c09083a601
Fix a few simple linter warnings: unused code, govet warnings etc. (#1191) 2020-04-06 08:21:20 -07:00
Matt Moore 1893541a0f
Scope the webhook secret informers to the system namespace. (#1158) 2020-03-12 18:29:29 -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
Victor Agababov 06d6b25dd6 Remove panics from the test and use t.Fatalf instead (#906) 2019-11-26 15:21:21 -08:00
Matt Moore 4836f680bb Split the resource semantic webhooks into separate AdmissionControllers (#848)
By combining our validation logic into our mutating webhook we were previously allowing for mutating webhooks evaluated after our own to modify our resources into invalid shapes.  There are no guarantees around ordering of mutating webhooks (that I could find), so the only way to remedy this properly is to split apart the two into separate webhook configurations:
 - `defaulting`: which runs during the mutating admission webhook phase
 - `validation`: which runs during the validating admission webhook phase.

The diagram in [this post](https://kubernetes.io/blog/2019/03/21/a-guide-to-kubernetes-admission-controllers/) is very helpful in illustrating the flow of webhooks.

Fixes: https://github.com/knative/pkg/issues/847
2019-11-14 16:51:02 -08:00