Previously we required namespace to be non-empty, but it never is for Cluster-scoped resources.
This change elides validation for missing namespaces, assuming cluster-scoping.
* Bump apimachinery
* Update code-generator
* Update API and client, some progress
* Hack the generator to work at all
* Hack the PodDisruptionBudget extension to fulfill the interfaces
* Bump apiextensions as well
* Fix conflict
* Better condition
* Roll back unnecessary codegen change
* Fix PodDisruptionBudget extensions
* Panic on not-yet-implemented like others
* Use consistent case for "Deprecated" comments
Not the most important thing ever, but the canonical string to use for
Deprecated warnings is case sensitive, and also it's nice to be
consistent.
* Add nolint comment
* 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
* Add GetObservers to tracker interface
This allows an arbitrary client to fetch all the observers of a given object. Ultimately, this enables an informer setup that can use this knowledge as a filter to decide whether or not the current object is actually watched by anything.
* Fix log line
* Add support for Selector in tracker.Reference.
`tracker.Reference` may now optionally replace `Name` with `Selector` to track zero or multiple resources of a particular `apiVersion`, `kind` and `namespace`.
Fixes: https://github.com/knative/pkg/issues/859
* Address code review comments
`TrackReference` is the same as `Track`, but takes a `tracker.Reference` instead. This type has been seeded with the subset of `corev1.ObjectReference` that the tracker currently consumes / supports, but the intention is to expand this type to allow inexact references that (optionally) use label selectors in place of name to reference objects.
See also: https://github.com/knative/pkg/issues/859
Stop using `t.Run` to segment things, since they aren't truly independent tests.
Use a longer lease/sleep as I have concerns that slow execution may be a part of the flakiness here.
* Some fixes to the spoof.go and exporter.go
While reviewing some other CL, I saw some avenues for improving
spoof.go, to log the URL that's being fetched, which would help in test
debugging and to use switch construct, rather than nested if's.
While testing the change, I noticed some shifty loggin from the
exporter, so I fixed that as well while I was there.
* Continuation of the previous cleanups.
* Fix the issues with formatting by executing a grep
* and fix compilation error
* lowercase error
* fix the newly changed unit test
To use this with a typical informer, e.g. the way `Route` would monitor `Configurations` and `Revisions`, you'd do something like:
```go
c := &Reconciler{
Base: reconciler.NewBase(opt, controllerAgentName),
...
}
impl := controller.NewImpl(c, c.Logger, "Routes")
t := New(impl.EnqueueKey, 30*time.Minute)
configInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: t.OnChanged,
UpdateFunc: controller.PassNew(t.OnChanged),
})
revisionInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: t.OnChanged,
UpdateFunc: controller.PassNew(t.OnChanged),
})
// Now use c.tracker.Track(revisionRef, route) or c.tracker.Track(configRef, route)
// each Reconcile(route) to refresh the cross-object leases.
c.tracker = t
```
To use this with a `duck.InformerFactory`, e.g. the way `Revision` will monitor `BuildRef`s you'd do something like:
```go
c := &Reconciler{
Base: reconciler.NewBase(opt, controllerAgentName),
...
}
impl := controller.NewImpl(c, c.Logger, "Revisions")
t := New(impl.EnqueueKey, 30*time.Minute)
cif := &duck.CachedInformerFactory{
Delegate: &duck.EnqueueInformerFactory{
Delegate: buildInformerFactory,
EventHandler: cache.ResourceEventHandlerFuncs{
AddFunc: t.OnChanged,
UpdateFunc: controller.PassNew(t.OnChanged),
},
},
}
// Now use: `c.buildInformerFactory.Get()` to access ObjectReferences.
c.buildInformerFactory = buildInformerFactory
// Now use: `c.tracker.Track(rev.Spec.BuildRef, rev)` to queue `rev`
// each time `rev.Spec.BuildRef` changes (expires 30 minutes after BuildRef
// points to something else).
c.tracker = t
```
Fixes: https://github.com/knative/pkg/issues/94