Commit Graph

53 Commits

Author SHA1 Message Date
Scott Nichols 70762ec49b Reintroduce FieldError (#77)
* Testing an idea for field errors.

* wrap other tests for webhook.

* move FieldError to Error, FieldErrors to FieldError

* Rename files to reflect their type.

* Reworked this to require no changes externally.

* test also.

* gotta cover those tests.

* nil check

* Adding Also.

* Clean up comments.

* Don't delete the tests.

* Null check test the clear.

* Fix nits.

* FieldError is now non-mutating.

* More errorf formatting fixes.

* I can make this even simpiler

* I can make this even MORE simpiler

* Add comment to make flow of also clear.

* fix comment, optimize make errors
2018-09-20 09:24:19 -07:00
Matt Moore c15d7c8f22 Eliminate custom methods from GenericCRD (#78)
* Prune the GenericCRD spec to what is used.

Encapsulate our change detection slightly.

* Support common spec mutations via duck typing.

This adds support for performing common mutations to objects via duck types and JSON patching.

Fixes: https://github.com/knative/pkg/issues/76

* Eliminate getSpecJSON thru schemaless duck typing.

This leverages a one-off trick to get the JSON of the spec field from arbitrary types.
2018-09-18 14:25:19 -07:00
Grant Rodgers 6f0348fb69 Rename Targettable to Targetable (#73) 2018-09-18 12:47:18 -07:00
Scott Nichols 67830c7a64 Adding common condition status. (#66)
* Adding common condition status.

* Saw another test that could be useful to have. added.

* ran hack/update-codegen.sh

* added ConditionSucceeded.

* moving the interface to just wrap the Condition[] object.

* checkpoint.

* Starting to reintegrate the work done in serving.

* Fixed up the unit tests.

* improve the test coverage on MarkTrue

* Moving conditionals to duck api.

* Adding more tests.

* Adding get/set tests.

* Some final nits for this ducking class.
2018-09-17 12:33:18 -07:00
Matt Moore 9a13caa7a1 WIP Define a package with which to support duck typed definitions. (#71)
This also sketches out the skeletons for Targettable, Subscribable, and Conditions.
2018-09-15 19:08:17 -07:00
Scott Nichols f0ec8c5ac7 Adding ViaIndex, ViaKey, ViaFieldIndex, ViaFieldKey to FieldErrors (#55)
* Adding .ViaIndex(1). to make spec.param[1] easier to do.

* Adding ViaKey

* fix order of bag example.

* Add code coverage to missed line.

* Adding ViaFieldIndex helper

* cleaning up.

* compress more.

* more cleanup

* test name
2018-09-14 21:07:17 -07:00
jonjohnsonjr 2a7e950c4e Rename kmeta.NewOwnerReference to NewControllerRef (#70)
This is more accurate, since we're creating a controller ref (and keeps
the naming consistent with metav1).

Also, adds a test!
2018-09-13 15:01:16 -07:00
jonjohnsonjr bfddf2d91b Introduce an OwnerRefable interface (#69)
* Introduce an OwnerRefable interface

An OwnerRefable type provides sufficient information that we can
construct a metav1.OwnerReference from it, e.g. for
kmeta.NewOwnerReference, which does just that.

* Move interface to kmeta
2018-09-13 14:14:16 -07:00
Matt Moore d14ed384b0 Switch kmeta/labels to use metav1.ObjectMetaAccessor (#68) 2018-09-13 11:29:16 -07:00
Matt Moore 5f353e5de8 Create a kmeta package for libraries acting on ObjectMeta. (#67)
This bootstraps this package with a useful collection of label methods for managing sub-resources.  I'd initially written this as a way of managing versioned DaemonSet resources as part of WarmImage ([see here](62cad8045a/pkg/reconciler/warmimage/resources/meta.go (L28))).

I am upstreaming this here because I want to take advantage of it in Build for managing Image cache subresources of [Cluster]BuildTemplate resources.
2018-09-13 10:45:16 -07:00
Dave Protasowski 8fc80deb20 Few changes to the configmap package (#59)
* Few changes to the configmap package

- New* methods return concrete types
- defaultImpl is now InformedWatcher
- fixedImpl is now StaticWatcher
- Included a new ManualWatcher that mimics the InformedWatcher
  in behaviour. ie. allows updates - making this a true 'mock'

* Include note about embedding the ManualWatcher in the InformedWatcher

* Update static_watcher.go

Fix some godoc
2018-09-12 07:42:16 -07:00
Dave Protasowski 0122abd983 The test logger will now log the correct caller (#63)
Previous, since we weren't skipping, the logged caller
would be 'logging.go'
2018-09-06 14:16:14 -07:00
srinivashegde86 e7a4b0d534 Dont call flag.parse in pkg/test (#62)
* Dont call flag.parse in pkg

* Remove unused import
2018-09-06 10:06:14 -07:00
Adriano Cunha b2135236d0 Update test-infra dependency (#61)
Includes:
* fixes to `library.sh` in order to have some `hack` scripts working again;
* better checking of PRs where presubmit tests are unnecessary;
2018-09-05 06:57:14 -07:00
srinivashegde86 382a2bff0a Make kube_checks generic so that it can be used in serving (#58)
* Make kube_checks generic

* Use logging lib in cleanup
2018-08-31 16:01:12 -07:00
Ville Aikas 760afb6c09 cleanup (#57) 2018-08-30 09:36:12 -07:00
Adriano Cunha eedc0a939d Make verify-codegen.sh compatible with OS X (#54)
OS X's `mktemp` has no `-p` flag.
2018-08-26 08:42:02 -07:00
srinivashegde86 6eff182b87 Remove docker repo from e2e flags (#53) 2018-08-24 13:44:59 -07:00
Adriano Cunha 4be5c07977 Vendor the test-infra scripts (#52)
* shared scripts from test-infra live in //vendor/github.com/knative/test-infra/scripts;
* update `update-deps.sh` to keep only the scripts folder;
* all bash scripts were updated to use the vendored scripts;

Part of knative/test-infra#30.
2018-08-23 21:30:59 -07:00
srinivashegde86 8c687df30f Update WaitForEndpointState to return response (#51)
* Update WaitForEndpointState to return response

* remove extra vars
2018-08-23 13:42:59 -07:00
srinivashegde86 8f6a3be149 Update knative/pkg/test (#50) 2018-08-23 12:03:59 -07:00
Matt Moore 3ca427071d Add a logkey for the reconcile key. (#49)
This adds a logkey.Key for attaching the key being reconciled to a logger we embed into the context passed to Reconcile.  The point of this is to enable us to eliminate [this](928d580756/pkg/reconciler/v1alpha1/service/service.go (L101-L104)) boilerplate from each of the Reconcilers.

These aren't identical, this has the form:
  knative.dev/key: foo/bar

What it's replacing has the form:
  knative.dev/namespace: foo
  serving.knative.dev/service: bar

However, the type information present in the latter is redundant with the controller type that [should already be embedded](928d580756/pkg/reconciler/reconciler.go (L80)) in the logger.
2018-08-23 09:48:59 -07:00
Zhimin Xiang 62d2560a1f Add Istio DestinationRule and Policy into Istio apis and clients (#43)
* initial draft

* fix incorrect dependency on knative/serving

* 1. Move StringMatch from istio/v1alpha3 to istio/common/v1alpha1. 2. Add field excludedPaths into Policy

* fix typo
2018-08-22 16:16:59 -07:00
srinivashegde86 f4a77d7708 Add a common test clients file (#46)
* Add the common test client

* Update vendor dirs

* Add blank lines in boiler plate doc
2018-08-20 16:10:58 -07:00
srinivashegde86 450739d6f8 Add common test logging module (#45)
* Add common test logging module

* Update references to logging lib

* Add error functions
2018-08-20 16:04:59 -07:00
Scott Nichols a3bc2db77a Remove strict name metadata check to be shareable in eventing (#44)
* Do not valdiate name meta for all objects.

* Remove the test too.
2018-08-14 08:45:57 -07:00
srinivashegde86 8bdbf4eeb9 Add the common test e2e files (#39)
* Add the common test e2e files

* Update deps

* Add the constants and remove serving related methods
2018-08-13 11:28:56 -07:00
Matt Moore bc264c290f
Add deepcopy-gen for VolatileTime. (#42) 2018-08-09 16:32:03 -07:00
Matt Moore 7a0c09e11a
Support multiple group/kind contexts in shared webhook. (#41)
In order to have a single webhook support multiple domain contexts, this reworks the `Handlers` argument to embed the `schema.GroupVersion` by wrapping the existing keys with it as a `schema.GroupVersionKind`.

This is mostly straightforward, but one oddity is that I discovered that `AdmissionRequest` gets this same tuple as the less capable `metav1.GroupVersionKind`, so there's a silly conversion we have to do.

I tried this manually vendored in serving with KPA and things worked great.
2018-08-09 16:00:55 -07:00
Matt Moore f2beac9894
Move VolatileTime into knative/pkg (#40) 2018-08-09 15:58:51 -07:00
Matt Moore 3b51a7246c Update to the 1.11 client libraries. (#38) 2018-08-06 09:54:11 -07:00
Scott Andrews a088fee622 Add Istio client from knative/serving (#35)
* Add Istio client from knative/serving

- Add Istio types in 'apis/istio/v1alpha3'
- Update codegen scripts
- Generate client in 'client'
- Add @tcnghia as owner for 'apis/istio'

Fixes #1

* nix linguring serving package dep

* cleanup vendor cache

* Mark /client as generated

* Fix verify-codegen script

* Run verify-codegen.sh via presubmit-tests.sh

* Remove Gatewaies -> Gateway hack

Looks like we don't need it anymore
2018-08-03 16:14:10 -07:00
Scott Nichols 5182837041 flipped the error text around. fixed. (#36) 2018-08-02 13:13:38 -07:00
Scott Nichols c1e9219cee Adding more field errors. (#34)
* Adding mutually exclusive fields error.

* Adding ErrMissingOneOf, ErrMultipleOneOf, ErrInvalidParameterName

* Adding gitignore.

* Change to ErrInvalidKeyName.

* Use ... semantic.

* those pesky newlines.
2018-08-02 10:05:37 -07:00
Matt Moore bf6f9e373f Move our base controller infrastructure into knative/pkg. (#33)
The `controller.go` is from: https://github.com/knative/serving/pull/1770, however, this adds 100% coverage of `controller.go`, which we have been missing in `knative/serving`.

This also adds a `context.Context` to the `Reconcile` signature, to enable better sharing of logger setup across controllers.

Fixes: https://github.com/knative/pkg/issues/8
2018-08-01 14:32:37 -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
Shashwathi bba99e266c Use fallback named logger (#30) 2018-07-31 14:19:37 -07:00
Shashwathi 9a6f5abda8 Use more verbose error msg (#31) 2018-07-31 09:38:37 -07:00
Yanwei Guo 94bc05ad25 Add yanweiguo as owner of logging directory (#29) 2018-07-30 21:34:37 -07:00
Matt Moore 484160f313 Set up issue and PR templates for pkg. (#28)
Fixes: https://github.com/knative/pkg/issues/10
2018-07-30 13:09:36 -07:00
Matt Moore d6c701b0b1 Copy pkg/signals verbatim from Serving. (#25) 2018-07-30 13:05:36 -07:00
Matt Moore 03fb14296d Make the fields of the AdmissionController public. (#24) 2018-07-27 21:27:36 -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
Matt Moore 9d1975b29f Drop the fixed list of `knative/serving` components from logging. (#22) 2018-07-27 10:14:36 -07:00
Matt Moore 8b7b2d7cfb Move the logging packages from serving into pkg. (#21) 2018-07-27 09:53:35 -07:00
Adriano Cunha 16665d8163 Initial set of files for //test (#18)
* Initial set of files for //test

Currently there are no tests, but this will enable finishing setup Prow.

* Add build and unit tests

* Update README with instruction on how to run the unit tests
2018-07-26 16:46:35 -07:00
Matt Moore 84f0a719d7 Add comments to exported error helpers. (#20)
Noticed via the go report!
2018-07-26 16:40:35 -07:00
Matt Moore 63b563207a Add "godoc" and "go report" badges (#19) 2018-07-26 16:39:37 -07:00
Matt Moore 945c05cc41
Bring in the API utilities from `pkg/apis/serving/v1alpha1` used for validation and defaulting in the webhook. (#13)
Fixes: https://github.com/knative/pkg/issues/12
2018-07-26 12:14:57 -07:00
Matt Moore f8e84c0d02
Copy `pkg/configmap` over from `knative/serving`. (#11) 2018-07-25 14:56:29 -07:00