Commit Graph

20 Commits

Author SHA1 Message Date
Dave Protasowski eaa823c765
bump k8s to v1.20.7 (#2145)
* bump k8s deps to v1.20.7

* fix migrator test pkg

* dynamicclient now expects List types to be declare either via a scheme or manually

* fix error message comparison

* drop excess vendor licenses

* Using the injection fake dynamic client will preserve pre-1.20 behaviour

This is accomplished by preprocessing the scheme/fixtures and declaring
a custom scheme were we map our types & lists to unstructured.* types

* revert webhook factory changes

* ensure objects to the dynamic client are unstructured

* seed the default dynamic client with k8s scheme

* include duckv1 types in default fake dynamic client scheme

* use default k8s scheme
looks like eventing adds to this scheme but we should import the correct one vs the one from the  fake package

* drop duckv1 from default scheme

* set APIVersion/Kind if empty

* refactor ToUnstructured helper to a new package
2021-06-10 06:56:43 -07:00
Victor Agababov a371418524
v2 (#1754) 2020-09-29 13:18:29 -07:00
Markus Thömmes 5fbbde31b3
Align linters with serving (enables stylecheck and asciicheck) (#1738) 2020-09-23 07:37:40 -07:00
Matt Moore bfc0cee945
Implement the second wave of per-reconciler leaderelection (#1302)
* Implement the second wave of per-reconciler leaderelection.

Detailed design: https://docs.google.com/document/d/1i_QHjQO2T3SNv49xjZLWlivcc0UvZN1Tbw2NKxThkyM/edit#
Issue: https://github.com/knative/pkg/issues/1181

* incorporate vagababov feedback

* Improve controller.go coverage
2020-06-19 09:47:25 -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
Matt Moore 3bada55aab
Drops the Serving-specific stats reporter logic from knative/pkg (#1114) 2020-02-21 10:02:07 -08: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
Dave Protasowski 88d4536182
Conversion Webhook Framework (#993)
* ConversionController implementation

This controller will reconcile target CRDs with the correct
conversion webhook configuration. Specifically, the HTTP path and
CA bundle will be updated.

Additionally, the conversion controller will perform the given
conversions through a hub and spoke model utilizing the
apis.Convertible interface.

* Webhook now can host ConversionControllers

* injection/sharedmain now supports webhook.ConversionControllers

These conversion controllers will be hosted by the webhook that
the sharedmain will start

* support defaulting & include godoc
2020-02-03 08:59:29 -08:00
Matt Moore b26ddf762b This should be done directly in Serving, not in knative/pkg. (#946) 2019-12-16 13:19:02 -08:00
Matt Moore 891c2876dd Implement a base library for implementing "Pod Spec"-able bindings. (#915)
This PR adds facilities to make it easier to create both components of a Binding
over "Pod Spec"-able resources.  Rather than rehashing it all here, please look
at `./pkg/webhook/psbinding/README.md` for more details.
2019-12-02 08:58:34 -08:00
Ville Aikas 944655d6cc fix comment, followup to 911 (#912)
* fix comment, followup to 911

* Update webhook/testing/listers.go

Co-Authored-By: Victor Agababov <vagababov@gmail.com>
2019-11-28 13:49:22 -08:00
Matt Moore 20ef0b737b This has three small table testing changes. (#911)
I'm splitting this off of another change that needed them, the three changes are:

1. Give the PostConditions callbacks in TableRow access to the Reconciler
  resource.  It turns out this is incredibly useful to have the `TableRow`
  program an admission controller and then test that programming by calling
  `Admit()`.

1. Surface the test resources in our webhook "listers", and add the testing
  scheme.

1. Change the `objKey` to only use reflection as a fallback.  The existing logic
  doesn't work properly when a mix of real resources and unstructured.Unstructured
  is used for the same resource.
2019-11-28 11:10:22 -08:00
Slavomir Kaslev ddf3968b65 Migrate pkg to istio.io/client-go apis (#882)
* Add istio api packages from istio.io/api and istio.io/client-go

* Codegen istio client for apis from istio.io/client-go

* Remove our istio apis
2019-11-26 11:41:21 -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 d4ce001394 This refactors our core webhook logic to be reconciler-based. (#833)
This is the culmination of a large number of changes to refactor our webhook logic, and adopt a reconciler-based approach to make it resilient to unexected system events (e.g. rogue GCs!).

For more details on how this is consumed, see the new `webhook/README.md`.

Fixes: https://github.com/knative/pkg/issues/782
Closes: https://github.com/knative/pkg/issues/529
Fixes: https://github.com/knative/pkg/issues/450
Related: https://github.com/knative/pkg/issues/141
2019-10-31 10:17:13 -07:00
Matt Moore 0442aed564 Create a new singleton Reconciler for the webhook secret. (#832)
* Create a new singleton Reconciler for the webhook secret.

This change creates a new Reconciler (not yet hooked up) that ensures that the
webhook secret has the appropriate shape.  I call this a "singleton Reconciler"
because this reconciler exists to effectively reconcile a single resource, which
will be a pattern for the webhook's reconcilers.

* Address linter problems
2019-10-30 08:23:13 -07:00
Matt Moore 50398a29a7 Factor out test helpers to prepare for webhook package split. (#829) 2019-10-29 14:13:11 -07:00
Matt Moore fdf2fdcd93 Move the test resource out of `./webhook`. (#32)
This is so that other things can more naturally write tests using this same test resource.
2018-07-31 16:02:37 -07:00
Matt Moore 4d4c00734e Pull the webhook from `knative/serving` into `knative/pkg`. (#23)
This pulls the Knative webhook logic (oriented around the interfaces in `knative/pkg/apis`) into `knative/pkg`.

The code is largely copied as-is, with `keep.go` excluded.  The main changes are to the test code, which in `knative/serving` still operate in terms of the serving types.

Fixes: https://github.com/knative/pkg/issues/9
2018-07-27 19:03:36 -07:00