Auto-update dependencies (#140)

Produced via:
  `dep ensure -update knative.dev/test-infra knative.dev/pkg`
/assign n3wscott
This commit is contained in:
Matt Moore 2019-11-26 10:26:22 -08:00 committed by Knative Prow Robot
parent 14ff67345c
commit e1d118d28c
48 changed files with 1728 additions and 83 deletions

6
Gopkg.lock generated
View File

@ -933,7 +933,7 @@
[[projects]]
branch = "master"
digest = "1:c2a4335822f3689f4322e6b814a280932b3064079e9792ff3da51987313602de"
digest = "1:4835d8c504bc12fd7e44d97f9e6ab5e84e0384be0ffba1f264efc61043c733c5"
name = "knative.dev/pkg"
packages = [
"apis",
@ -952,7 +952,7 @@
"metrics/metricskey",
]
pruneopts = "T"
revision = "2ec0f8da50578dcc3d830571d0de24de834579c8"
revision = "6305a6322febad96fdb4f0d879d0e2b34c8a79b1"
[[projects]]
branch = "master"
@ -963,7 +963,7 @@
"tools/dep-collector",
]
pruneopts = "UT"
revision = "fad831028edbe066665977ea7bf366c3d5c0a2d1"
revision = "4aaba3b76d04d8bbb0b3289ec05df0ee6051fa52"
[[projects]]
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"

View File

@ -12,6 +12,7 @@ are as follows:
| Label | Duck-Type |
| ----------------------------------- | ----------------------------------------------------------------------------- |
| `duck.knative.dev/addressable=true` | [Addressable](https://godoc.org/knative.dev/pkg/apis/duck/v1#AddressableType) |
| `duck.knative.dev/binding=true` | [Binding](https://godoc.org/knative.dev/pkg/apis/duck/v1alpha1#Binding) |
| `duck.knative.dev/source=true` | [Source](https://godoc.org/knative.dev/pkg/apis/duck/v1#Source) |
## Addressable Shape
@ -26,6 +27,38 @@ status:
url: http://host/path?query
```
## Binding Shape
Binding is expected to be in the following shape:
(with direct subject)
```yaml
apiVersion: group/version
kind: Kind
spec:
subject:
apiVersion: group/version
kind: SomeKind
namespace: the-namespace
name: a-name
```
(with indirect subject)
```yaml
apiVersion: group/version
kind: Kind
spec:
subject:
apiVersion: group/version
kind: SomeKind
namespace: the-namespace
selector:
matchLabels:
key: value
```
## Source Shape
Source is expected to be in the following shape:

View File

@ -27,9 +27,11 @@ import (
"knative.dev/pkg/apis/duck"
)
// +genduck
// Addressable provides a generic mechanism for a custom resource
// definition to indicate a destination for message delivery.
//
// Addressable is the schema for the destination information. This is
// typically stored in the object's `status`, as this information may
// be generated by the controller.
@ -44,7 +46,6 @@ var (
_ apis.Convertible = (*Addressable)(nil)
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// AddressableType is a skeleton type wrapping Addressable in the manner we expect

View File

@ -25,11 +25,12 @@ import (
"knative.dev/pkg/apis/duck"
)
// +genduck
// PodSpecable is implemented by types containing a PodTemplateSpec
// in the manner of ReplicaSet, Deployment, DaemonSet, StatefulSet.
type PodSpecable corev1.PodTemplateSpec
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// WithPod is the shell that demonstrates how PodSpecable types wrap

View File

@ -30,7 +30,7 @@ import (
// Source is an Implementable "duck type".
var _ duck.Implementable = (*Source)(nil)
// +genclient
// +genduck
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Source is the minimum resource shape to adhere to the Source Specification.

View File

@ -28,13 +28,14 @@ import (
"knative.dev/pkg/apis/duck"
)
// +genduck
// Conditions is a simple wrapper around apis.Conditions to implement duck.Implementable.
type Conditions apis.Conditions
// Conditions is an Implementable "duck type".
var _ duck.Implementable = (*Conditions)(nil)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// KResource is a skeleton type wrapping Conditions in the manner we expect

View File

@ -29,9 +29,11 @@ import (
"knative.dev/pkg/apis/duck/v1beta1"
)
// +genduck
// Addressable provides a generic mechanism for a custom resource
// definition to indicate a destination for message delivery.
//
// Addressable is the schema for the destination information. This is
// typically stored in the object's `status`, as this information may
// be generated by the controller.
@ -48,7 +50,6 @@ var (
_ apis.Convertible = (*Addressable)(nil)
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// AddressableType is a skeleton type wrapping Addressable in the manner we expect

View File

@ -0,0 +1,92 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"knative.dev/pkg/apis"
"knative.dev/pkg/apis/duck"
"knative.dev/pkg/tracker"
)
// +genduck
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Binding is a duck type that specifies the partial schema to which all
// Binding implementations should adhere.
type Binding struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec BindingSpec `json:"spec"`
}
// Verify that Binding implements the appropriate interfaces.
var (
_ duck.Implementable = (*Binding)(nil)
_ duck.Populatable = (*Binding)(nil)
_ apis.Listable = (*Binding)(nil)
)
// BindingSpec specifies the spec portion of the Binding partial-schema.
type BindingSpec struct {
// Subject references the resource(s) whose "runtime contract" should be
// augmented by Binding implementations.
Subject tracker.Reference `json:"subject"`
}
// GetFullType implements duck.Implementable
func (*Binding) GetFullType() duck.Populatable {
return &Binding{}
}
// Populate implements duck.Populatable
func (t *Binding) Populate() {
t.Spec = BindingSpec{
Subject: tracker.Reference{
APIVersion: "apps/v1",
Kind: "Deployment",
Namespace: "default",
// Name and Selector are mutually exclusive,
// but we fill them both in for this test.
Name: "bazinga",
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"foo": "bar",
"baz": "blah",
},
},
},
}
}
// GetListType implements apis.Listable
func (*Binding) GetListType() runtime.Object {
return &BindingList{}
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// BindingList is a list of Binding resources
type BindingList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Binding `json:"items"`
}

View File

@ -27,6 +27,8 @@ import (
"knative.dev/pkg/apis/duck"
)
// +genduck
// Conditions is the schema for the conditions portion of the payload
type Conditions []Condition
@ -118,7 +120,6 @@ func (c *Condition) IsUnknown() bool {
// Conditions is an Implementable "duck type".
var _ duck.Implementable = (*Conditions)(nil)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// KResource is a skeleton type wrapping Conditions in the manner we expect

View File

@ -24,6 +24,8 @@ import (
"knative.dev/pkg/apis/duck"
)
// +genduck
// LegacyTargetable left around until we migrate to Addressable in the
// dependent resources. Addressable has more structure in the way it
// defines the fields. LegacyTargetable only assumed a single string
@ -32,7 +34,7 @@ import (
// This is to support existing resources until they migrate.
//
// Do not use this for anything new, use Addressable
//
// LegacyTargetable is the old schema for the addressable portion
// of the payload
//
@ -44,7 +46,6 @@ type LegacyTargetable struct {
// LegacyTargetable is an Implementable "duck type".
var _ duck.Implementable = (*LegacyTargetable)(nil)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// LegacyTarget is a skeleton type wrapping LegacyTargetable in the manner we

View File

@ -24,6 +24,8 @@ import (
"knative.dev/pkg/apis/duck"
)
// +genduck
// Targetable is an earlier version of the Callable interface.
// Callable is a higher-level interface which implements Addressable
// but further promises that the destination may synchronously return
@ -31,7 +33,7 @@ import (
//
// Targetable implementations should instead implement Addressable and
// include an `eventing.knative.dev/returns=any` annotation.
//
// Targetable is retired; implement Addressable for now.
type Targetable struct {
DomainInternal string `json:"domainInternal,omitempty"`
@ -40,7 +42,6 @@ type Targetable struct {
// Targetable is an Implementable "duck type".
var _ duck.Implementable = (*Targetable)(nil)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Target is a skeleton type wrapping Targetable in the manner we expect

View File

@ -122,6 +122,83 @@ func (in *AddressableTypeList) DeepCopyObject() runtime.Object {
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Binding) DeepCopyInto(out *Binding) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Binding.
func (in *Binding) DeepCopy() *Binding {
if in == nil {
return nil
}
out := new(Binding)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *Binding) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BindingList) DeepCopyInto(out *BindingList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Binding, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BindingList.
func (in *BindingList) DeepCopy() *BindingList {
if in == nil {
return nil
}
out := new(BindingList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *BindingList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BindingSpec) DeepCopyInto(out *BindingSpec) {
*out = *in
in.Subject.DeepCopyInto(&out.Subject)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BindingSpec.
func (in *BindingSpec) DeepCopy() *BindingSpec {
if in == nil {
return nil
}
out := new(BindingSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Condition) DeepCopyInto(out *Condition) {
*out = *in

View File

@ -28,9 +28,11 @@ import (
v1 "knative.dev/pkg/apis/duck/v1"
)
// +genduck
// Addressable provides a generic mechanism for a custom resource
// definition to indicate a destination for message delivery.
//
// Addressable is the schema for the destination information. This is
// typically stored in the object's `status`, as this information may
// be generated by the controller.
@ -45,7 +47,6 @@ var (
_ apis.Convertible = (*Addressable)(nil)
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// AddressableType is a skeleton type wrapping Addressable in the manner we expect

View File

@ -30,7 +30,7 @@ import (
// Source is an Implementable "duck type".
var _ duck.Implementable = (*Source)(nil)
// +genclient
// +genduck
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Source is the minimum resource shape to adhere to the Source Specification.

View File

@ -28,13 +28,14 @@ import (
"knative.dev/pkg/apis/duck"
)
// +genduck
// Conditions is a simple wrapper around apis.Conditions to implement duck.Implementable.
type Conditions apis.Conditions
// Conditions is an Implementable "duck type".
var _ duck.Implementable = (*Conditions)(nil)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// KResource is a skeleton type wrapping Conditions in the manner we expect

View File

@ -20,6 +20,7 @@ import (
"encoding/json"
"fmt"
"knative.dev/pkg/apis"
"knative.dev/pkg/kmp"
)
@ -36,6 +37,8 @@ type Implementable interface {
// duck type. It will generally have TypeMeta, ObjectMeta, and a Status field
// wrapping a Fooable field.
type Populatable interface {
apis.Listable
// Populate fills in all possible fields, so that we can verify that
// they roundtrip properly through JSON.
Populate()

View File

@ -0,0 +1,60 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package addressable
import (
"context"
duck "knative.dev/pkg/apis/duck"
v1 "knative.dev/pkg/apis/duck/v1"
controller "knative.dev/pkg/controller"
injection "knative.dev/pkg/injection"
dynamicclient "knative.dev/pkg/injection/clients/dynamicclient"
logging "knative.dev/pkg/logging"
)
func init() {
injection.Default.RegisterDuck(WithDuck)
}
// Key is used for associating the Informer inside the context.Context.
type Key struct{}
func WithDuck(ctx context.Context) context.Context {
dc := dynamicclient.Get(ctx)
dif := &duck.CachedInformerFactory{
Delegate: &duck.TypedInformerFactory{
Client: dc,
Type: (&v1.Addressable{}).GetFullType(),
ResyncPeriod: controller.GetResyncPeriod(ctx),
StopChannel: ctx.Done(),
},
}
return context.WithValue(ctx, Key{}, dif)
}
// Get extracts the typed informer from the context.
func Get(ctx context.Context) duck.InformerFactory {
untyped := ctx.Value(Key{})
if untyped == nil {
logging.FromContext(ctx).Panic(
"Unable to fetch knative.dev/pkg/apis/duck.InformerFactory from context.")
}
return untyped.(duck.InformerFactory)
}

View File

@ -0,0 +1,30 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package fake
import (
addressable "knative.dev/pkg/client/injection/ducks/duck/v1/addressable"
injection "knative.dev/pkg/injection"
)
var Get = addressable.Get
func init() {
injection.Fake.RegisterDuck(addressable.WithDuck)
}

View File

@ -0,0 +1,60 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package conditions
import (
"context"
duck "knative.dev/pkg/apis/duck"
v1 "knative.dev/pkg/apis/duck/v1"
controller "knative.dev/pkg/controller"
injection "knative.dev/pkg/injection"
dynamicclient "knative.dev/pkg/injection/clients/dynamicclient"
logging "knative.dev/pkg/logging"
)
func init() {
injection.Default.RegisterDuck(WithDuck)
}
// Key is used for associating the Informer inside the context.Context.
type Key struct{}
func WithDuck(ctx context.Context) context.Context {
dc := dynamicclient.Get(ctx)
dif := &duck.CachedInformerFactory{
Delegate: &duck.TypedInformerFactory{
Client: dc,
Type: (&v1.Conditions{}).GetFullType(),
ResyncPeriod: controller.GetResyncPeriod(ctx),
StopChannel: ctx.Done(),
},
}
return context.WithValue(ctx, Key{}, dif)
}
// Get extracts the typed informer from the context.
func Get(ctx context.Context) duck.InformerFactory {
untyped := ctx.Value(Key{})
if untyped == nil {
logging.FromContext(ctx).Panic(
"Unable to fetch knative.dev/pkg/apis/duck.InformerFactory from context.")
}
return untyped.(duck.InformerFactory)
}

View File

@ -0,0 +1,30 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package fake
import (
conditions "knative.dev/pkg/client/injection/ducks/duck/v1/conditions"
injection "knative.dev/pkg/injection"
)
var Get = conditions.Get
func init() {
injection.Fake.RegisterDuck(conditions.WithDuck)
}

View File

@ -0,0 +1,30 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package fake
import (
podspecable "knative.dev/pkg/client/injection/ducks/duck/v1/podspecable"
injection "knative.dev/pkg/injection"
)
var Get = podspecable.Get
func init() {
injection.Fake.RegisterDuck(podspecable.WithDuck)
}

View File

@ -0,0 +1,60 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package podspecable
import (
"context"
duck "knative.dev/pkg/apis/duck"
v1 "knative.dev/pkg/apis/duck/v1"
controller "knative.dev/pkg/controller"
injection "knative.dev/pkg/injection"
dynamicclient "knative.dev/pkg/injection/clients/dynamicclient"
logging "knative.dev/pkg/logging"
)
func init() {
injection.Default.RegisterDuck(WithDuck)
}
// Key is used for associating the Informer inside the context.Context.
type Key struct{}
func WithDuck(ctx context.Context) context.Context {
dc := dynamicclient.Get(ctx)
dif := &duck.CachedInformerFactory{
Delegate: &duck.TypedInformerFactory{
Client: dc,
Type: (&v1.PodSpecable{}).GetFullType(),
ResyncPeriod: controller.GetResyncPeriod(ctx),
StopChannel: ctx.Done(),
},
}
return context.WithValue(ctx, Key{}, dif)
}
// Get extracts the typed informer from the context.
func Get(ctx context.Context) duck.InformerFactory {
untyped := ctx.Value(Key{})
if untyped == nil {
logging.FromContext(ctx).Panic(
"Unable to fetch knative.dev/pkg/apis/duck.InformerFactory from context.")
}
return untyped.(duck.InformerFactory)
}

View File

@ -0,0 +1,30 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package fake
import (
source "knative.dev/pkg/client/injection/ducks/duck/v1/source"
injection "knative.dev/pkg/injection"
)
var Get = source.Get
func init() {
injection.Fake.RegisterDuck(source.WithDuck)
}

View File

@ -0,0 +1,60 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package source
import (
"context"
duck "knative.dev/pkg/apis/duck"
v1 "knative.dev/pkg/apis/duck/v1"
controller "knative.dev/pkg/controller"
injection "knative.dev/pkg/injection"
dynamicclient "knative.dev/pkg/injection/clients/dynamicclient"
logging "knative.dev/pkg/logging"
)
func init() {
injection.Default.RegisterDuck(WithDuck)
}
// Key is used for associating the Informer inside the context.Context.
type Key struct{}
func WithDuck(ctx context.Context) context.Context {
dc := dynamicclient.Get(ctx)
dif := &duck.CachedInformerFactory{
Delegate: &duck.TypedInformerFactory{
Client: dc,
Type: (&v1.Source{}).GetFullType(),
ResyncPeriod: controller.GetResyncPeriod(ctx),
StopChannel: ctx.Done(),
},
}
return context.WithValue(ctx, Key{}, dif)
}
// Get extracts the typed informer from the context.
func Get(ctx context.Context) duck.InformerFactory {
untyped := ctx.Value(Key{})
if untyped == nil {
logging.FromContext(ctx).Panic(
"Unable to fetch knative.dev/pkg/apis/duck.InformerFactory from context.")
}
return untyped.(duck.InformerFactory)
}

View File

@ -0,0 +1,60 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package addressable
import (
"context"
duck "knative.dev/pkg/apis/duck"
v1alpha1 "knative.dev/pkg/apis/duck/v1alpha1"
controller "knative.dev/pkg/controller"
injection "knative.dev/pkg/injection"
dynamicclient "knative.dev/pkg/injection/clients/dynamicclient"
logging "knative.dev/pkg/logging"
)
func init() {
injection.Default.RegisterDuck(WithDuck)
}
// Key is used for associating the Informer inside the context.Context.
type Key struct{}
func WithDuck(ctx context.Context) context.Context {
dc := dynamicclient.Get(ctx)
dif := &duck.CachedInformerFactory{
Delegate: &duck.TypedInformerFactory{
Client: dc,
Type: (&v1alpha1.Addressable{}).GetFullType(),
ResyncPeriod: controller.GetResyncPeriod(ctx),
StopChannel: ctx.Done(),
},
}
return context.WithValue(ctx, Key{}, dif)
}
// Get extracts the typed informer from the context.
func Get(ctx context.Context) duck.InformerFactory {
untyped := ctx.Value(Key{})
if untyped == nil {
logging.FromContext(ctx).Panic(
"Unable to fetch knative.dev/pkg/apis/duck.InformerFactory from context.")
}
return untyped.(duck.InformerFactory)
}

View File

@ -0,0 +1,30 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package fake
import (
addressable "knative.dev/pkg/client/injection/ducks/duck/v1alpha1/addressable"
injection "knative.dev/pkg/injection"
)
var Get = addressable.Get
func init() {
injection.Fake.RegisterDuck(addressable.WithDuck)
}

View File

@ -0,0 +1,60 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package binding
import (
"context"
duck "knative.dev/pkg/apis/duck"
v1alpha1 "knative.dev/pkg/apis/duck/v1alpha1"
controller "knative.dev/pkg/controller"
injection "knative.dev/pkg/injection"
dynamicclient "knative.dev/pkg/injection/clients/dynamicclient"
logging "knative.dev/pkg/logging"
)
func init() {
injection.Default.RegisterDuck(WithDuck)
}
// Key is used for associating the Informer inside the context.Context.
type Key struct{}
func WithDuck(ctx context.Context) context.Context {
dc := dynamicclient.Get(ctx)
dif := &duck.CachedInformerFactory{
Delegate: &duck.TypedInformerFactory{
Client: dc,
Type: (&v1alpha1.Binding{}).GetFullType(),
ResyncPeriod: controller.GetResyncPeriod(ctx),
StopChannel: ctx.Done(),
},
}
return context.WithValue(ctx, Key{}, dif)
}
// Get extracts the typed informer from the context.
func Get(ctx context.Context) duck.InformerFactory {
untyped := ctx.Value(Key{})
if untyped == nil {
logging.FromContext(ctx).Panic(
"Unable to fetch knative.dev/pkg/apis/duck.InformerFactory from context.")
}
return untyped.(duck.InformerFactory)
}

View File

@ -0,0 +1,30 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package fake
import (
binding "knative.dev/pkg/client/injection/ducks/duck/v1alpha1/binding"
injection "knative.dev/pkg/injection"
)
var Get = binding.Get
func init() {
injection.Fake.RegisterDuck(binding.WithDuck)
}

View File

@ -0,0 +1,60 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package conditions
import (
"context"
duck "knative.dev/pkg/apis/duck"
v1alpha1 "knative.dev/pkg/apis/duck/v1alpha1"
controller "knative.dev/pkg/controller"
injection "knative.dev/pkg/injection"
dynamicclient "knative.dev/pkg/injection/clients/dynamicclient"
logging "knative.dev/pkg/logging"
)
func init() {
injection.Default.RegisterDuck(WithDuck)
}
// Key is used for associating the Informer inside the context.Context.
type Key struct{}
func WithDuck(ctx context.Context) context.Context {
dc := dynamicclient.Get(ctx)
dif := &duck.CachedInformerFactory{
Delegate: &duck.TypedInformerFactory{
Client: dc,
Type: (&v1alpha1.Conditions{}).GetFullType(),
ResyncPeriod: controller.GetResyncPeriod(ctx),
StopChannel: ctx.Done(),
},
}
return context.WithValue(ctx, Key{}, dif)
}
// Get extracts the typed informer from the context.
func Get(ctx context.Context) duck.InformerFactory {
untyped := ctx.Value(Key{})
if untyped == nil {
logging.FromContext(ctx).Panic(
"Unable to fetch knative.dev/pkg/apis/duck.InformerFactory from context.")
}
return untyped.(duck.InformerFactory)
}

View File

@ -0,0 +1,30 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package fake
import (
conditions "knative.dev/pkg/client/injection/ducks/duck/v1alpha1/conditions"
injection "knative.dev/pkg/injection"
)
var Get = conditions.Get
func init() {
injection.Fake.RegisterDuck(conditions.WithDuck)
}

View File

@ -0,0 +1,30 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package fake
import (
legacytargetable "knative.dev/pkg/client/injection/ducks/duck/v1alpha1/legacytargetable"
injection "knative.dev/pkg/injection"
)
var Get = legacytargetable.Get
func init() {
injection.Fake.RegisterDuck(legacytargetable.WithDuck)
}

View File

@ -0,0 +1,60 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package legacytargetable
import (
"context"
duck "knative.dev/pkg/apis/duck"
v1alpha1 "knative.dev/pkg/apis/duck/v1alpha1"
controller "knative.dev/pkg/controller"
injection "knative.dev/pkg/injection"
dynamicclient "knative.dev/pkg/injection/clients/dynamicclient"
logging "knative.dev/pkg/logging"
)
func init() {
injection.Default.RegisterDuck(WithDuck)
}
// Key is used for associating the Informer inside the context.Context.
type Key struct{}
func WithDuck(ctx context.Context) context.Context {
dc := dynamicclient.Get(ctx)
dif := &duck.CachedInformerFactory{
Delegate: &duck.TypedInformerFactory{
Client: dc,
Type: (&v1alpha1.LegacyTargetable{}).GetFullType(),
ResyncPeriod: controller.GetResyncPeriod(ctx),
StopChannel: ctx.Done(),
},
}
return context.WithValue(ctx, Key{}, dif)
}
// Get extracts the typed informer from the context.
func Get(ctx context.Context) duck.InformerFactory {
untyped := ctx.Value(Key{})
if untyped == nil {
logging.FromContext(ctx).Panic(
"Unable to fetch knative.dev/pkg/apis/duck.InformerFactory from context.")
}
return untyped.(duck.InformerFactory)
}

View File

@ -0,0 +1,30 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package fake
import (
targetable "knative.dev/pkg/client/injection/ducks/duck/v1alpha1/targetable"
injection "knative.dev/pkg/injection"
)
var Get = targetable.Get
func init() {
injection.Fake.RegisterDuck(targetable.WithDuck)
}

View File

@ -0,0 +1,60 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package targetable
import (
"context"
duck "knative.dev/pkg/apis/duck"
v1alpha1 "knative.dev/pkg/apis/duck/v1alpha1"
controller "knative.dev/pkg/controller"
injection "knative.dev/pkg/injection"
dynamicclient "knative.dev/pkg/injection/clients/dynamicclient"
logging "knative.dev/pkg/logging"
)
func init() {
injection.Default.RegisterDuck(WithDuck)
}
// Key is used for associating the Informer inside the context.Context.
type Key struct{}
func WithDuck(ctx context.Context) context.Context {
dc := dynamicclient.Get(ctx)
dif := &duck.CachedInformerFactory{
Delegate: &duck.TypedInformerFactory{
Client: dc,
Type: (&v1alpha1.Targetable{}).GetFullType(),
ResyncPeriod: controller.GetResyncPeriod(ctx),
StopChannel: ctx.Done(),
},
}
return context.WithValue(ctx, Key{}, dif)
}
// Get extracts the typed informer from the context.
func Get(ctx context.Context) duck.InformerFactory {
untyped := ctx.Value(Key{})
if untyped == nil {
logging.FromContext(ctx).Panic(
"Unable to fetch knative.dev/pkg/apis/duck.InformerFactory from context.")
}
return untyped.(duck.InformerFactory)
}

View File

@ -0,0 +1,60 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package addressable
import (
"context"
duck "knative.dev/pkg/apis/duck"
v1beta1 "knative.dev/pkg/apis/duck/v1beta1"
controller "knative.dev/pkg/controller"
injection "knative.dev/pkg/injection"
dynamicclient "knative.dev/pkg/injection/clients/dynamicclient"
logging "knative.dev/pkg/logging"
)
func init() {
injection.Default.RegisterDuck(WithDuck)
}
// Key is used for associating the Informer inside the context.Context.
type Key struct{}
func WithDuck(ctx context.Context) context.Context {
dc := dynamicclient.Get(ctx)
dif := &duck.CachedInformerFactory{
Delegate: &duck.TypedInformerFactory{
Client: dc,
Type: (&v1beta1.Addressable{}).GetFullType(),
ResyncPeriod: controller.GetResyncPeriod(ctx),
StopChannel: ctx.Done(),
},
}
return context.WithValue(ctx, Key{}, dif)
}
// Get extracts the typed informer from the context.
func Get(ctx context.Context) duck.InformerFactory {
untyped := ctx.Value(Key{})
if untyped == nil {
logging.FromContext(ctx).Panic(
"Unable to fetch knative.dev/pkg/apis/duck.InformerFactory from context.")
}
return untyped.(duck.InformerFactory)
}

View File

@ -0,0 +1,30 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package fake
import (
addressable "knative.dev/pkg/client/injection/ducks/duck/v1beta1/addressable"
injection "knative.dev/pkg/injection"
)
var Get = addressable.Get
func init() {
injection.Fake.RegisterDuck(addressable.WithDuck)
}

View File

@ -0,0 +1,60 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package conditions
import (
"context"
duck "knative.dev/pkg/apis/duck"
v1beta1 "knative.dev/pkg/apis/duck/v1beta1"
controller "knative.dev/pkg/controller"
injection "knative.dev/pkg/injection"
dynamicclient "knative.dev/pkg/injection/clients/dynamicclient"
logging "knative.dev/pkg/logging"
)
func init() {
injection.Default.RegisterDuck(WithDuck)
}
// Key is used for associating the Informer inside the context.Context.
type Key struct{}
func WithDuck(ctx context.Context) context.Context {
dc := dynamicclient.Get(ctx)
dif := &duck.CachedInformerFactory{
Delegate: &duck.TypedInformerFactory{
Client: dc,
Type: (&v1beta1.Conditions{}).GetFullType(),
ResyncPeriod: controller.GetResyncPeriod(ctx),
StopChannel: ctx.Done(),
},
}
return context.WithValue(ctx, Key{}, dif)
}
// Get extracts the typed informer from the context.
func Get(ctx context.Context) duck.InformerFactory {
untyped := ctx.Value(Key{})
if untyped == nil {
logging.FromContext(ctx).Panic(
"Unable to fetch knative.dev/pkg/apis/duck.InformerFactory from context.")
}
return untyped.(duck.InformerFactory)
}

View File

@ -0,0 +1,30 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package fake
import (
conditions "knative.dev/pkg/client/injection/ducks/duck/v1beta1/conditions"
injection "knative.dev/pkg/injection"
)
var Get = conditions.Get
func init() {
injection.Fake.RegisterDuck(conditions.WithDuck)
}

View File

@ -0,0 +1,30 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package fake
import (
source "knative.dev/pkg/client/injection/ducks/duck/v1beta1/source"
injection "knative.dev/pkg/injection"
)
var Get = source.Get
func init() {
injection.Fake.RegisterDuck(source.WithDuck)
}

View File

@ -0,0 +1,60 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package source
import (
"context"
duck "knative.dev/pkg/apis/duck"
v1beta1 "knative.dev/pkg/apis/duck/v1beta1"
controller "knative.dev/pkg/controller"
injection "knative.dev/pkg/injection"
dynamicclient "knative.dev/pkg/injection/clients/dynamicclient"
logging "knative.dev/pkg/logging"
)
func init() {
injection.Default.RegisterDuck(WithDuck)
}
// Key is used for associating the Informer inside the context.Context.
type Key struct{}
func WithDuck(ctx context.Context) context.Context {
dc := dynamicclient.Get(ctx)
dif := &duck.CachedInformerFactory{
Delegate: &duck.TypedInformerFactory{
Client: dc,
Type: (&v1beta1.Source{}).GetFullType(),
ResyncPeriod: controller.GetResyncPeriod(ctx),
StopChannel: ctx.Done(),
},
}
return context.WithValue(ctx, Key{}, dif)
}
// Get extracts the typed informer from the context.
func Get(ctx context.Context) duck.InformerFactory {
untyped := ctx.Value(Key{})
if untyped == nil {
logging.FromContext(ctx).Panic(
"Unable to fetch knative.dev/pkg/apis/duck.InformerFactory from context.")
}
return untyped.(duck.InformerFactory)
}

View File

@ -0,0 +1,130 @@
/*
Copyright 2019 The Knative Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package generators
import (
"io"
clientgentypes "k8s.io/code-generator/cmd/client-gen/types"
"k8s.io/gengo/generator"
"k8s.io/gengo/namer"
"k8s.io/gengo/types"
"k8s.io/klog"
)
// duckGenerator produces logic to register a duck.InformerFactory for a particular
// type onto context.
type duckGenerator struct {
generator.DefaultGen
outputPackage string
groupVersion clientgentypes.GroupVersion
groupGoName string
typeToGenerate *types.Type
imports namer.ImportTracker
}
var _ generator.Generator = (*duckGenerator)(nil)
func (g *duckGenerator) Filter(c *generator.Context, t *types.Type) bool {
// Only process the type for this informer generator.
return t == g.typeToGenerate
}
func (g *duckGenerator) Namers(c *generator.Context) namer.NameSystems {
publicPluralNamer := &ExceptionNamer{
Exceptions: map[string]string{
// these exceptions are used to deconflict the generated code
// you can put your fully qualified package like
// to generate a name that doesn't conflict with your group.
// "k8s.io/apis/events/v1beta1.Event": "EventResource"
},
KeyFunc: func(t *types.Type) string {
return t.Name.Package + "." + t.Name.Name
},
Delegate: namer.NewPublicPluralNamer(map[string]string{
"Endpoints": "Endpoints",
}),
}
return namer.NameSystems{
"raw": namer.NewRawNamer(g.outputPackage, g.imports),
"publicPlural": publicPluralNamer,
}
}
func (g *duckGenerator) Imports(c *generator.Context) (imports []string) {
imports = append(imports, g.imports.ImportLines()...)
return
}
func (g *duckGenerator) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error {
sw := generator.NewSnippetWriter(w, c, "{{", "}}")
klog.V(5).Infof("processing type %v", t)
m := map[string]interface{}{
"group": namer.IC(g.groupGoName),
"type": t,
"version": namer.IC(g.groupVersion.Version.String()),
"injectionRegisterDuck": c.Universe.Type(types.Name{Package: "knative.dev/pkg/injection", Name: "Default.RegisterDuck"}),
"getResyncPeriod": c.Universe.Type(types.Name{Package: "knative.dev/pkg/controller", Name: "GetResyncPeriod"}),
"dynamicGet": c.Universe.Type(types.Name{Package: "knative.dev/pkg/injection/clients/dynamicclient", Name: "Get"}),
"duckTypedInformerFactory": c.Universe.Type(types.Name{Package: "knative.dev/pkg/apis/duck", Name: "TypedInformerFactory"}),
"duckCachedInformerFactory": c.Universe.Type(types.Name{Package: "knative.dev/pkg/apis/duck", Name: "CachedInformerFactory"}),
"duckInformerFactory": c.Universe.Type(types.Name{Package: "knative.dev/pkg/apis/duck", Name: "InformerFactory"}),
"loggingFromContext": c.Universe.Function(types.Name{
Package: "knative.dev/pkg/logging",
Name: "FromContext",
}),
}
sw.Do(duckFactory, m)
return sw.Error()
}
var duckFactory = `
func init() {
{{.injectionRegisterDuck|raw}}(WithDuck)
}
// Key is used for associating the Informer inside the context.Context.
type Key struct{}
func WithDuck(ctx context.Context) context.Context {
dc := {{.dynamicGet|raw}}(ctx)
dif := &{{.duckCachedInformerFactory|raw}}{
Delegate: &{{.duckTypedInformerFactory|raw}}{
Client: dc,
Type: (&{{.type|raw}}{}).GetFullType(),
ResyncPeriod: {{.getResyncPeriod|raw}}(ctx),
StopChannel: ctx.Done(),
},
}
return context.WithValue(ctx, Key{}, dif)
}
// Get extracts the typed informer from the context.
func Get(ctx context.Context) {{.duckInformerFactory|raw}} {
untyped := ctx.Value(Key{})
if untyped == nil {
{{.loggingFromContext|raw}}(ctx).Panic(
"Unable to fetch {{.duckInformerFactory}} from context.")
}
return untyped.({{.duckInformerFactory|raw}})
}
`

View File

@ -0,0 +1,104 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package generators
import (
"io"
clientgentypes "k8s.io/code-generator/cmd/client-gen/types"
"k8s.io/gengo/generator"
"k8s.io/gengo/namer"
"k8s.io/gengo/types"
"k8s.io/klog"
)
// fakeDuckGenerator produces a file of listers for a given GroupVersion and
// type.
type fakeDuckGenerator struct {
generator.DefaultGen
outputPackage string
imports namer.ImportTracker
typeToGenerate *types.Type
groupVersion clientgentypes.GroupVersion
groupGoName string
duckInjectionPkg string
}
var _ generator.Generator = (*fakeDuckGenerator)(nil)
func (g *fakeDuckGenerator) Filter(c *generator.Context, t *types.Type) bool {
// Only process the type for this duck generator.
return t == g.typeToGenerate
}
func (g *fakeDuckGenerator) Namers(c *generator.Context) namer.NameSystems {
publicPluralNamer := &ExceptionNamer{
Exceptions: map[string]string{
// these exceptions are used to deconflict the generated code
// you can put your fully qualified package like
// to generate a name that doesn't conflict with your group.
// "k8s.io/apis/events/v1beta1.Event": "EventResource"
},
KeyFunc: func(t *types.Type) string {
return t.Name.Package + "." + t.Name.Name
},
Delegate: namer.NewPublicPluralNamer(map[string]string{
"Endpoints": "Endpoints",
}),
}
return namer.NameSystems{
"raw": namer.NewRawNamer(g.outputPackage, g.imports),
"publicPlural": publicPluralNamer,
}
}
func (g *fakeDuckGenerator) Imports(c *generator.Context) (imports []string) {
imports = append(imports, g.imports.ImportLines()...)
return
}
func (g *fakeDuckGenerator) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error {
sw := generator.NewSnippetWriter(w, c, "{{", "}}")
klog.V(5).Infof("processing type %v", t)
m := map[string]interface{}{
"withDuck": c.Universe.Type(types.Name{Package: g.duckInjectionPkg, Name: "WithDuck"}),
"duckGet": c.Universe.Function(types.Name{Package: g.duckInjectionPkg, Name: "Get"}),
"group": namer.IC(g.groupGoName),
"type": t,
"version": namer.IC(g.groupVersion.Version.String()),
"injectionRegisterDuck": c.Universe.Function(types.Name{
Package: "knative.dev/pkg/injection",
Name: "Fake.RegisterDuck",
}),
}
sw.Do(injectionFakeDuck, m)
return sw.Error()
}
var injectionFakeDuck = `
var Get = {{.duckGet|raw}}
func init() {
{{.injectionRegisterDuck|raw}}({{.withDuck|raw}})
}
`

View File

@ -48,22 +48,12 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
versionPackagePath := filepath.Join(arguments.OutputPackagePath)
var packageList generator.Packages
typesForGroupVersion := make(map[clientgentypes.GroupVersion][]*types.Type)
groupVersions := make(map[string]clientgentypes.GroupVersions)
groupGoNames := make(map[string]string)
for _, inputDir := range arguments.InputDirs {
p := context.Universe.Package(vendorless(inputDir))
objectMeta, _, err := objectMetaForPackage(p) // TODO: ignoring internal.
if err != nil {
klog.Fatal(err)
}
if objectMeta == nil {
// no types in this package had genclient
continue
}
var gv clientgentypes.GroupVersion
var targetGroupVersions map[string]clientgentypes.GroupVersions
@ -95,22 +85,16 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
// Generate the informer factory and fake.
packageList = append(packageList, versionFactoryPackages(versionPackagePath, boilerplate, customArgs)...)
var typesToGenerate []*types.Type
var typesWithInformers []*types.Type
var duckTypes []*types.Type
for _, t := range p.Types {
tags := util.MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
if !tags.GenerateClient || tags.NoVerbs || !tags.HasVerb("list") || !tags.HasVerb("watch") {
continue
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
if tags.NeedsInformerInjection() {
typesWithInformers = append(typesWithInformers, t)
}
typesToGenerate = append(typesToGenerate, t)
if _, ok := typesForGroupVersion[gv]; !ok {
typesForGroupVersion[gv] = []*types.Type{}
if tags.NeedsDuckInjection() {
duckTypes = append(duckTypes, t)
}
typesForGroupVersion[gv] = append(typesForGroupVersion[gv], t)
}
if len(typesToGenerate) == 0 {
continue
}
groupVersionsEntry, ok := targetGroupVersions[groupPackageName]
@ -123,34 +107,52 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
groupVersionsEntry.Versions = append(groupVersionsEntry.Versions, clientgentypes.PackageVersion{Version: gv.Version, Package: gvPackage})
targetGroupVersions[groupPackageName] = groupVersionsEntry
orderer := namer.Orderer{Namer: namer.NewPrivateNamer(0)}
typesToGenerate = orderer.OrderTypes(typesToGenerate)
if len(typesWithInformers) != 0 {
orderer := namer.Orderer{Namer: namer.NewPrivateNamer(0)}
typesWithInformers = orderer.OrderTypes(typesWithInformers)
// Generate the informer and fake, for each type.
packageList = append(packageList, versionInformerPackages(versionPackagePath, groupPackageName, gv, groupGoNames[groupPackageName], boilerplate, typesToGenerate, customArgs)...)
// Generate the informer and fake, for each type.
packageList = append(packageList, versionInformerPackages(versionPackagePath, groupPackageName, gv, groupGoNames[groupPackageName], boilerplate, typesWithInformers, customArgs)...)
}
if len(duckTypes) != 0 {
orderer := namer.Orderer{Namer: namer.NewPrivateNamer(0)}
duckTypes = orderer.OrderTypes(duckTypes)
// Generate a duck-typed informer for each type.
packageList = append(packageList, versionDuckPackages(versionPackagePath, groupPackageName, gv, groupGoNames[groupPackageName], boilerplate, duckTypes, customArgs)...)
}
}
return packageList
}
// objectMetaForPackage returns the type of ObjectMeta used by package p.
func objectMetaForPackage(p *types.Package) (*types.Type, bool, error) {
generatingForPackage := false
for _, t := range p.Types {
if !util.MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...)).GenerateClient {
continue
}
generatingForPackage = true
for _, member := range t.Members {
if member.Name == "ObjectMeta" {
return member.Type, isInternal(member), nil
}
}
// Tags represents a genclient configuration for a single type.
type Tags struct {
util.Tags
GenerateDuck bool
}
func (t Tags) NeedsInformerInjection() bool {
return t.GenerateClient && !t.NoVerbs && t.HasVerb("list") && t.HasVerb("watch")
}
func (t Tags) NeedsDuckInjection() bool {
return t.GenerateDuck
}
// MustParseClientGenTags calls ParseClientGenTags but instead of returning error it panics.
func MustParseClientGenTags(lines []string) Tags {
ret := Tags{
Tags: util.MustParseClientGenTags(lines),
}
if generatingForPackage {
return nil, false, fmt.Errorf("unable to find ObjectMeta for any types in package %s", p.Path)
}
return nil, false, nil
values := types.ExtractCommentTags("+", lines)
// log.Printf("GOT values %v", values)
_, ret.GenerateDuck = values["genduck"]
return ret
}
// isInternal returns true if the tags for a member do not contain a json tag
@ -193,8 +195,8 @@ func versionClientsPackages(basePackage string, boilerplate []byte, customArgs *
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := util.MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.GenerateClient && tags.HasVerb("list") && tags.HasVerb("watch")
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsInformerInjection()
},
})
@ -219,8 +221,8 @@ func versionClientsPackages(basePackage string, boilerplate []byte, customArgs *
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := util.MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.GenerateClient && tags.HasVerb("list") && tags.HasVerb("watch")
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsInformerInjection()
},
})
@ -252,8 +254,8 @@ func versionFactoryPackages(basePackage string, boilerplate []byte, customArgs *
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := util.MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.GenerateClient && tags.HasVerb("list") && tags.HasVerb("watch")
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsInformerInjection()
},
})
@ -279,8 +281,8 @@ func versionFactoryPackages(basePackage string, boilerplate []byte, customArgs *
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := util.MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.GenerateClient && tags.HasVerb("list") && tags.HasVerb("watch")
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsInformerInjection()
},
})
@ -323,8 +325,8 @@ func versionInformerPackages(basePackage string, groupPkgName string, gv clientg
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := util.MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.GenerateClient && tags.HasVerb("list") && tags.HasVerb("watch")
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsInformerInjection()
},
})
@ -351,8 +353,75 @@ func versionInformerPackages(basePackage string, groupPkgName string, gv clientg
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := util.MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.GenerateClient && tags.HasVerb("list") && tags.HasVerb("watch")
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsInformerInjection()
},
})
}
return vers
}
func versionDuckPackages(basePackage string, groupPkgName string, gv clientgentypes.GroupVersion, groupGoName string, boilerplate []byte, typesToGenerate []*types.Type, customArgs *informergenargs.CustomArgs) []generator.Package {
packagePath := filepath.Join(basePackage, "ducks", groupPkgName, strings.ToLower(gv.Version.NonEmpty()))
vers := make([]generator.Package, 0, len(typesToGenerate))
for _, t := range typesToGenerate {
// Fix for golang iterator bug.
t := t
packagePath := packagePath + "/" + strings.ToLower(t.Name.Name)
// Impl
vers = append(vers, &generator.DefaultPackage{
PackageName: strings.ToLower(t.Name.Name),
PackagePath: packagePath,
HeaderText: boilerplate,
GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) {
// Impl
generators = append(generators, &duckGenerator{
DefaultGen: generator.DefaultGen{
OptionalName: strings.ToLower(t.Name.Name),
},
outputPackage: packagePath,
groupVersion: gv,
groupGoName: groupGoName,
typeToGenerate: t,
imports: generator.NewImportTracker(),
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsDuckInjection()
},
})
// Fake
vers = append(vers, &generator.DefaultPackage{
PackageName: "fake",
PackagePath: packagePath + "/fake",
HeaderText: boilerplate,
GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) {
// Impl
generators = append(generators, &fakeDuckGenerator{
DefaultGen: generator.DefaultGen{
OptionalName: "fake",
},
outputPackage: packagePath + "/fake",
imports: generator.NewImportTracker(),
typeToGenerate: t,
groupVersion: gv,
groupGoName: groupGoName,
duckInjectionPkg: packagePath,
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsDuckInjection()
},
})
}

View File

@ -36,7 +36,7 @@ ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
# Knative Injection
${REPO_ROOT_DIR}/hack/generate-knative.sh "injection" \
knative.dev/pkg/client knative.dev/pkg/apis \
"istio:v1alpha3 istio/authentication:v1alpha1" \
"istio:v1alpha3 istio/authentication:v1alpha1 duck:v1alpha1,v1beta1,v1" \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt
OUTPUT_PKG="knative.dev/pkg/client/injection/kube" \

View File

@ -0,0 +1,40 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package injection
import (
"context"
)
// DuckFactoryInjector holds the type of a callback that attaches a particular
// duck-type informer factory to a context.
type DuckFactoryInjector func(context.Context) context.Context
func (i *impl) RegisterDuck(ii DuckFactoryInjector) {
i.m.Lock()
defer i.m.Unlock()
i.ducks = append(i.ducks, ii)
}
func (i *impl) GetDucks() []DuckFactoryInjector {
i.m.RLock()
defer i.m.RUnlock()
// Copy the slice before returning.
return append(i.ducks[:0:0], i.ducks...)
}

View File

@ -56,6 +56,12 @@ func (i *impl) SetupInformers(ctx context.Context, cfg *rest.Config) (context.Co
ctx = ifi(ctx)
}
// Based on the reconcilers we have linked, build up a set of duck informer factories
// and inject them onto the context.
for _, duck := range i.GetDucks() {
ctx = duck(ctx)
}
// Based on the reconcilers we have linked, build up a set of informers
// and inject them onto the context.
var inf controller.Informer

View File

@ -43,6 +43,12 @@ type Interface interface {
// GetInformerFactories fetches all of the registered informer factory injectors.
GetInformerFactories() []InformerFactoryInjector
// RegisterDuck registers a new duck.InformerFactory for a particular type.
RegisterDuck(ii DuckFactoryInjector)
// GetDucks accesses the set of registered ducks.
GetDucks() []DuckFactoryInjector
// RegisterInformer registers a new injector callback for associating
// a new informer with a context.
RegisterInformer(InformerInjector)
@ -81,4 +87,5 @@ type impl struct {
clients []ClientInjector
factories []InformerFactoryInjector
informers []InformerInjector
ducks []DuckFactoryInjector
}

View File

@ -32,7 +32,7 @@ import (
"knative.dev/pkg/network"
"knative.dev/pkg/tracker"
"knative.dev/pkg/injection/clients/dynamicclient"
"knative.dev/pkg/client/injection/ducks/duck/v1beta1/addressable"
)
// URIResolver resolves Destinations and ObjectReferences into a URI.
@ -48,12 +48,7 @@ func NewURIResolver(ctx context.Context, callback func(types.NamespacedName)) *U
ret.tracker = tracker.New(callback, controller.GetTrackerLease(ctx))
ret.informerFactory = &pkgapisduck.CachedInformerFactory{
Delegate: &pkgapisduck.EnqueueInformerFactory{
Delegate: &pkgapisduck.TypedInformerFactory{
Client: dynamicclient.Get(ctx),
Type: &duckv1beta1.AddressableType{},
ResyncPeriod: controller.GetResyncPeriod(ctx),
StopChannel: ctx.Done(),
},
Delegate: addressable.Get(ctx),
EventHandler: controller.HandleAll(ret.tracker.OnChanged),
},
}