There are a number of notable differences:
* Selector is part of Spec not Status,
* Selector is structured vs. `string`,
* The Replicas in Spec is a pointer.
* Change VerifyType to return an error instead of panicking
Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
* Move the use of `VerifyType` in tests
Those calls to `duck.VerifyType` are done at runtime and thus could be
costly at program startup. Putting them under tests ensure we still
assert those types but during unit testing.
Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
* Use reflection to get and set conditions.
* Update comment.
* limiting the object on the way in, no need to double check it is a struct.
* Reorder the class, and add a comment for getConditions
* Adding relection and duck type checking.
* Fix typos.
This defines a simple test duck type called PodSpecable, which has the same shape for embedding a corev1.PodTemplateSpec as numerous core Kubernetes resource: ReplicaSet, Deployment, StatefulSet, DaemonSet, and Job.
This starts to sketch common libraries for instantiating informers/listers for a particular GroupVersionResource as one of our duck types.
You can instantiate a duck.InformerFactory like so:
```go
dynaClient, err := dynamic.NewForConfig(cfg)
if err != nil {
logger.Fatalf("Error building dynamic clientset: %v", err)
}
// Cache as the outermost layer so we only register the EventHandler once.
dif := &duck.CachedInformerFactory{
Delegate: &duck.EnqueueInformerFactory{
Delegate: &duck.TypedInformerFactory{
Client: dynaClient,
Type: &duckv1alpha1.Target{},
ResyncPeriod: 30 * time.Second,
StopChannel: stopCh,
},
EventHandler: cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
// Enqueue, obj is: *duckerv1alpha1.Target
},
UpdateFunc: func(old, new interface{}) {
// Enqueue, old and new are: *duckerv1alpha1.Target
},
},
},
}
```
Then, as you come across new GroupVersionResources that you want to handle:
```go
informer, lister, err := dif.Get(gvr)
if err != nil {
logger.Fatalf("Error starting shared index informer: %v", err)
}
```
With the `duck.TypedInformerFactory` the objects will be returned as the provided `Type:`, so in this example, you could safely write:
```go
elt, err := lister.ByNamespace(ns).Get(name)
if err != nil { ... }
target := elt.(*duckv1alpha1.Target)
// Stuff involving target.
```
* first cut of defining Subscribable and Channelable
* address pr feedback
* remove now unnecessary From*Unstructured conversions
* address pr comments, add util_test
* Introduce LegacyTarget and make Target more structured
* add extra level of structure in Sinkable
* move util* to duck/util, change Sinkable string to SinkableDomain as per pr comments
* add callableDomain
* oops
* address PR feedback
* clarify comments
* Move util to pkg/duck
* Normalize the names of Status structs.
* 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
* 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.
* 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.
* 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
* 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