diff --git a/Gopkg.lock b/Gopkg.lock index 1eb10fc4..bd2bfc70 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -966,7 +966,7 @@ [[projects]] branch = "master" - digest = "1:6e2169542b76688fe02763aee6b53dedc9d71acb8608705393c4230ffae94e68" + digest = "1:4d466bcd929b5ae71fddc9153076b396c5d05479f03b2ae6318c3433578205dc" name = "knative.dev/pkg" packages = [ "apis", @@ -986,18 +986,18 @@ "reconciler", ] pruneopts = "T" - revision = "1cc7b7152937735a29c9d6fdaf3b244684aa850e" + revision = "5d8a01d12cc825688b14117af294139fee2270eb" [[projects]] branch = "master" - digest = "1:691951c6805590983ccea7c6dbca360bcb58af5f4d60f75af9499903bb3039e9" + digest = "1:043997c1e0120a3c74c981acf40438f54db2753a756e8896fc67fd9edb9ccea9" name = "knative.dev/test-infra" packages = [ "scripts", "tools/dep-collector", ] pruneopts = "UT" - revision = "9a261621df10478b791e5a320481766b38b43471" + revision = "fb304f6a7ac965fb3eb5cb16d5e0301ca60e3247" [[projects]] digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c" diff --git a/vendor/knative.dev/pkg/.gitignore b/vendor/knative.dev/pkg/.gitignore index 2a316661..38ead0a4 100644 --- a/vendor/knative.dev/pkg/.gitignore +++ b/vendor/knative.dev/pkg/.gitignore @@ -12,3 +12,6 @@ bazel-* # Emacs files *~ + +# Generated Test Code +test/genclient diff --git a/vendor/knative.dev/pkg/Gopkg.lock b/vendor/knative.dev/pkg/Gopkg.lock index eb55ee4f..cae75bce 100644 --- a/vendor/knative.dev/pkg/Gopkg.lock +++ b/vendor/knative.dev/pkg/Gopkg.lock @@ -1442,6 +1442,7 @@ "k8s.io/apimachinery/pkg/version", "k8s.io/apimachinery/pkg/watch", "k8s.io/client-go/discovery", + "k8s.io/client-go/discovery/fake", "k8s.io/client-go/dynamic", "k8s.io/client-go/dynamic/fake", "k8s.io/client-go/informers", @@ -1469,6 +1470,7 @@ "k8s.io/client-go/tools/clientcmd", "k8s.io/client-go/tools/metrics", "k8s.io/client-go/tools/record", + "k8s.io/client-go/util/flowcontrol", "k8s.io/client-go/util/retry", "k8s.io/client-go/util/workqueue", "k8s.io/code-generator/cmd/client-gen", diff --git a/vendor/knative.dev/pkg/apis/test/example/register.go b/vendor/knative.dev/pkg/apis/test/example/register.go new file mode 100644 index 00000000..aafd960c --- /dev/null +++ b/vendor/knative.dev/pkg/apis/test/example/register.go @@ -0,0 +1,21 @@ +/* +Copyright 2020 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 example + +const ( + GroupName = "example.knative.dev" +) diff --git a/vendor/knative.dev/pkg/apis/test/example/v1alpha1/doc.go b/vendor/knative.dev/pkg/apis/test/example/v1alpha1/doc.go new file mode 100644 index 00000000..fa5248c0 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/test/example/v1alpha1/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2020 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. +*/ + +// +k8s:deepcopy-gen=package +// +groupName=sample.knative.dev +package v1alpha1 diff --git a/vendor/knative.dev/pkg/apis/test/example/v1alpha1/foo_types.go b/vendor/knative.dev/pkg/apis/test/example/v1alpha1/foo_types.go new file mode 100644 index 00000000..22ac876f --- /dev/null +++ b/vendor/knative.dev/pkg/apis/test/example/v1alpha1/foo_types.go @@ -0,0 +1,93 @@ +/* +Copyright 2020 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 ( + "context" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +genreconciler +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Foo is for testing. +type Foo struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the Foo (from the client). + // +optional + Spec FooSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the Foo (from the controller). + // +optional + Status FooStatus `json:"status,omitempty"` +} + +// Check that Foo can be validated and defaulted. +var _ apis.Validatable = (*Foo)(nil) +var _ apis.Defaultable = (*Foo)(nil) +var _ kmeta.OwnerRefable = (*Foo)(nil) + +// FooSpec holds the desired state of the Foo (from the client). +type FooSpec struct{} + +// FooStatus communicates the observed state of the Foo (from the controller). +type FooStatus struct { + duckv1.Status `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// FooList is a list of Foo resources +type FooList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Foo `json:"items"` +} + +// -- lifecycle -- + +func (fs *FooStatus) InitializeConditions() {} + +// GetGroupVersionKind implements kmeta.OwnerRefable +func (f *Foo) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Bar") +} + +// -- Defaults -- + +// SetDefaults implements apis.Defaultable +func (f *Foo) SetDefaults(ctx context.Context) { + // Nothing to default. +} + +// -- Validation -- + +// Validate implements apis.Validatable +func (f *Foo) Validate(ctx context.Context) *apis.FieldError { + // Nothing to validate. + return nil +} diff --git a/vendor/knative.dev/pkg/apis/test/example/v1alpha1/register.go b/vendor/knative.dev/pkg/apis/test/example/v1alpha1/register.go new file mode 100644 index 00000000..7eb98a52 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/test/example/v1alpha1/register.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 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" + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis/test/example" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: example.GroupName, Version: "v1alpha1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &Foo{}, + &FooList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/knative.dev/pkg/apis/test/example/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/apis/test/example/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000..8b9b19b1 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/test/example/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,119 @@ +// +build !ignore_autogenerated + +/* +Copyright 2020 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 deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Foo) DeepCopyInto(out *Foo) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Foo. +func (in *Foo) DeepCopy() *Foo { + if in == nil { + return nil + } + out := new(Foo) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Foo) 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 *FooList) DeepCopyInto(out *FooList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Foo, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FooList. +func (in *FooList) DeepCopy() *FooList { + if in == nil { + return nil + } + out := new(FooList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FooList) 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 *FooSpec) DeepCopyInto(out *FooSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FooSpec. +func (in *FooSpec) DeepCopy() *FooSpec { + if in == nil { + return nil + } + out := new(FooSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FooStatus) DeepCopyInto(out *FooStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FooStatus. +func (in *FooStatus) DeepCopy() *FooStatus { + if in == nil { + return nil + } + out := new(FooStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/pkg/apis/test/pub/register.go b/vendor/knative.dev/pkg/apis/test/pub/register.go new file mode 100644 index 00000000..aafd960c --- /dev/null +++ b/vendor/knative.dev/pkg/apis/test/pub/register.go @@ -0,0 +1,21 @@ +/* +Copyright 2020 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 example + +const ( + GroupName = "example.knative.dev" +) diff --git a/vendor/knative.dev/pkg/apis/test/pub/v1alpha1/bar_types.go b/vendor/knative.dev/pkg/apis/test/pub/v1alpha1/bar_types.go new file mode 100644 index 00000000..2eefcd87 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/test/pub/v1alpha1/bar_types.go @@ -0,0 +1,93 @@ +/* +Copyright 2020 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 ( + "context" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +genreconciler:class=example.com/filter.class +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Bar is for testing. +type Bar struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the Bar (from the client). + // +optional + Spec BarSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the Bar (from the controller). + // +optional + Status BarStatus `json:"status,omitempty"` +} + +// Check that Bar can be validated and defaulted. +var _ apis.Validatable = (*Bar)(nil) +var _ apis.Defaultable = (*Bar)(nil) +var _ kmeta.OwnerRefable = (*Bar)(nil) + +// BarSpec holds the desired state of the Bar (from the client). +type BarSpec struct{} + +// BarStatus communicates the observed state of the Bar (from the controller). +type BarStatus struct { + duckv1.Status `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// BarList is a list of Bar resources +type BarList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Bar `json:"items"` +} + +// -- lifecycle -- + +func (bs *BarStatus) InitializeConditions() {} + +// GetGroupVersionKind implements kmeta.OwnerRefable +func (b *Bar) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Bar") +} + +// -- Defaults -- + +// SetDefaults implements apis.Defaultable +func (b *Bar) SetDefaults(ctx context.Context) { + // Nothing to default. +} + +// -- Validation -- + +// Validate implements apis.Validatable +func (b *Bar) Validate(ctx context.Context) *apis.FieldError { + // Nothing to validate. + return nil +} diff --git a/vendor/knative.dev/pkg/apis/test/pub/v1alpha1/doc.go b/vendor/knative.dev/pkg/apis/test/pub/v1alpha1/doc.go new file mode 100644 index 00000000..fa5248c0 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/test/pub/v1alpha1/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2020 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. +*/ + +// +k8s:deepcopy-gen=package +// +groupName=sample.knative.dev +package v1alpha1 diff --git a/vendor/knative.dev/pkg/apis/test/pub/v1alpha1/register.go b/vendor/knative.dev/pkg/apis/test/pub/v1alpha1/register.go new file mode 100644 index 00000000..c5abe49a --- /dev/null +++ b/vendor/knative.dev/pkg/apis/test/pub/v1alpha1/register.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 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" + "k8s.io/apimachinery/pkg/runtime/schema" + pub "knative.dev/pkg/apis/test/pub" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: pub.GroupName, Version: "v1alpha1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &Bar{}, + &BarList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/knative.dev/pkg/apis/test/pub/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/apis/test/pub/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000..cdc5ab57 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/test/pub/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,119 @@ +// +build !ignore_autogenerated + +/* +Copyright 2020 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 deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Bar) DeepCopyInto(out *Bar) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Bar. +func (in *Bar) DeepCopy() *Bar { + if in == nil { + return nil + } + out := new(Bar) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Bar) 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 *BarList) DeepCopyInto(out *BarList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Bar, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BarList. +func (in *BarList) DeepCopy() *BarList { + if in == nil { + return nil + } + out := new(BarList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BarList) 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 *BarSpec) DeepCopyInto(out *BarSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BarSpec. +func (in *BarSpec) DeepCopy() *BarSpec { + if in == nil { + return nil + } + out := new(BarSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BarStatus) DeepCopyInto(out *BarStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BarStatus. +func (in *BarStatus) DeepCopy() *BarStatus { + if in == nil { + return nil + } + out := new(BarStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/packages.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/packages.go index ac28b2aa..f65bc2ba 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/packages.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/packages.go @@ -165,13 +165,31 @@ func MustParseClientGenTags(lines []string) Tags { } values := types.ExtractCommentTags("+", lines) - // log.Printf("GOT values %v", values) + _, ret.GenerateDuck = values["genduck"] - _, ret.GenerateReconciler = values["genreconciler"] + + _, genRec := values["genreconciler"] + _, genRecClass := values["genreconciler:class"] + // Generate Reconciler code if genreconciler OR genreconciler:class exist. + if genRec || genRecClass { + ret.GenerateReconciler = true + } return ret } +func extractReconcilerClassTag(t *types.Type) (string, bool) { + comments := append(append([]string{}, t.SecondClosestCommentLines...), t.CommentLines...) + values := types.ExtractCommentTags("+", comments)["genreconciler:class"] + for _, v := range values { + if len(v) == 0 { + continue + } + return v, true + } + return "", false +} + // isInternal returns true if the tags for a member do not contain a json tag func isInternal(m types.Member) bool { return !strings.Contains(m.Tags, "json") @@ -387,6 +405,8 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp // Fix for golang iterator bug. t := t + reconcilerClass, hasReconcilerClass := extractReconcilerClassTag(t) + packagePath := filepath.Join(packagePath, strings.ToLower(t.Name.Name)) clientPackagePath := filepath.Join(basePackage, "client") @@ -412,6 +432,8 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp clientPkg: clientPackagePath, informerPackagePath: informerPackagePath, schemePkg: filepath.Join(customArgs.VersionedClientSetPackage, "scheme"), + reconcilerClass: reconcilerClass, + hasReconcilerClass: hasReconcilerClass, }) return generators @@ -438,6 +460,8 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp outputPackage: filepath.Join(packagePath, "stub"), imports: generator.NewImportTracker(), informerPackagePath: informerPackagePath, + reconcilerClass: reconcilerClass, + hasReconcilerClass: hasReconcilerClass, }) return generators @@ -459,12 +483,16 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp DefaultGen: generator.DefaultGen{ OptionalName: "reconciler", }, - typeToGenerate: t, - outputPackage: packagePath, - imports: generator.NewImportTracker(), - clientsetPkg: customArgs.VersionedClientSetPackage, - listerName: t.Name.Name + "Lister", - listerPkg: listerPackagePath, + typeToGenerate: t, + outputPackage: packagePath, + imports: generator.NewImportTracker(), + clientsetPkg: customArgs.VersionedClientSetPackage, + listerName: t.Name.Name + "Lister", + listerPkg: listerPackagePath, + groupGoName: groupGoName, + groupVersion: gv, + reconcilerClass: reconcilerClass, + hasReconcilerClass: hasReconcilerClass, }) return generators diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go index 125d090f..05db6d6d 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go @@ -37,6 +37,9 @@ type reconcilerControllerGenerator struct { clientPkg string schemePkg string informerPackagePath string + + reconcilerClass string + hasReconcilerClass bool } var _ generator.Generator = (*reconcilerControllerGenerator)(nil) @@ -63,8 +66,10 @@ func (g *reconcilerControllerGenerator) GenerateType(c *generator.Context, t *ty klog.V(5).Infof("processing type %v", t) m := map[string]interface{}{ - "type": t, - "group": g.groupName, + "type": t, + "group": g.groupName, + "class": g.reconcilerClass, + "hasClass": g.hasReconcilerClass, "controllerImpl": c.Universe.Type(types.Name{ Package: "knative.dev/pkg/controller", Name: "Impl", @@ -149,13 +154,14 @@ const ( defaultControllerAgentName = "{{.type|lowercaseSingular}}-controller" defaultFinalizerName = "{{.type|allLowercasePlural}}.{{.group}}" defaultQueueName = "{{.type|allLowercasePlural}}" + {{if .hasClass}}classAnnotationKey = "{{ .class }}"{{end}} ) // NewImpl returns a {{.controllerImpl|raw}} that handles queuing and feeding work from // the queue through an implementation of {{.controllerReconciler|raw}}, delegating to // the provided Interface and optional Finalizer methods. OptionsFn is used to return // {{.controllerOptions|raw}} to be used but the internal reconciler. -func NewImpl(ctx {{.contextContext|raw}}, r Interface, optionsFns ...{{.controllerOptionsFn|raw}}) *{{.controllerImpl|raw}} { +func NewImpl(ctx {{.contextContext|raw}}, r Interface{{if .hasClass}}, classValue string{{end}}, optionsFns ...{{.controllerOptionsFn|raw}}) *{{.controllerImpl|raw}} { logger := {{.loggingFromContext|raw}}(ctx) // Check the options function input. It should be 0 or 1. @@ -189,6 +195,7 @@ func NewImpl(ctx {{.contextContext|raw}}, r Interface, optionsFns ...{{.controll Lister: {{.type|lowercaseSingular}}Informer.Lister(), Recorder: recorder, reconciler: r, + {{if .hasClass}}classValue: classValue,{{end}} } impl := {{.controllerNewImpl|raw}}(rec, logger, defaultQueueName) diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller_stub.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller_stub.go index e7a1428b..594a6881 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller_stub.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller_stub.go @@ -35,6 +35,8 @@ type reconcilerControllerStubGenerator struct { reconcilerPkg string informerPackagePath string + reconcilerClass string + hasReconcilerClass bool } var _ generator.Generator = (*reconcilerControllerStubGenerator)(nil) @@ -61,7 +63,9 @@ func (g *reconcilerControllerStubGenerator) GenerateType(c *generator.Context, t klog.V(5).Infof("processing type %v", t) m := map[string]interface{}{ - "type": t, + "type": t, + "class": g.reconcilerClass, + "hasClass": g.hasReconcilerClass, "informerGet": c.Universe.Function(types.Name{ Package: g.informerPackagePath, Name: "Get", @@ -103,9 +107,10 @@ func NewController( {{.type|lowercaseSingular}}Informer := {{.informerGet|raw}}(ctx) // TODO: setup additional informers here. + {{if .hasClass}}// TODO: pass in the expected value for the class annotation filter.{{end}} r := &Reconciler{} - impl := {{.reconcilerNewImpl|raw}}(ctx, r) + impl := {{.reconcilerNewImpl|raw}}(ctx, r{{if .hasClass}}, "default"{{end}}) logger.Info("Setting up event handlers.") diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go index 537da77d..9bf3b7cf 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go @@ -19,6 +19,8 @@ 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" @@ -34,6 +36,12 @@ type reconcilerReconcilerGenerator struct { clientsetPkg string listerName string listerPkg string + + reconcilerClass string + hasReconcilerClass bool + + groupGoName string + groupVersion clientgentypes.GroupVersion } var _ generator.Generator = (*reconcilerReconcilerGenerator)(nil) @@ -60,8 +68,11 @@ func (g *reconcilerReconcilerGenerator) GenerateType(c *generator.Context, t *ty klog.V(5).Infof("processing type %v", t) m := map[string]interface{}{ - "type": t, - + "type": t, + "group": namer.IC(g.groupGoName), + "version": namer.IC(g.groupVersion.Version.String()), + "class": g.reconcilerClass, + "hasClass": g.hasReconcilerClass, "controllerImpl": c.Universe.Type(types.Name{ Package: "knative.dev/pkg/controller", Name: "Impl", @@ -185,6 +196,11 @@ type reconcilerImpl struct { // reconciler is the implementation of the business logic of the resource. reconciler Interface + + {{if .hasClass}} + // classValue is the resource annotation[{{ .class }}] instance value this reconciler instance filters on. + classValue string + {{end}} } // Check that our Reconciler implements controller.Reconciler @@ -193,7 +209,7 @@ var _ controller.Reconciler = (*reconcilerImpl)(nil) ` var reconcilerNewReconciler = ` -func NewReconciler(ctx {{.contextContext|raw}}, logger *{{.zapSugaredLogger|raw}}, client {{.clientsetInterface|raw}}, lister {{.resourceLister|raw}}, recorder {{.recordEventRecorder|raw}}, r Interface, options ...{{.controllerOptions|raw}} ) {{.controllerReconciler|raw}} { +func NewReconciler(ctx {{.contextContext|raw}}, logger *{{.zapSugaredLogger|raw}}, client {{.clientsetInterface|raw}}, lister {{.resourceLister|raw}}, recorder {{.recordEventRecorder|raw}}, r Interface{{if .hasClass}}, classValue string{{end}}, options ...{{.controllerOptions|raw}} ) {{.controllerReconciler|raw}} { // Check the options function input. It should be 0 or 1. if len(options) > 1 { logger.Fatalf("up to one options struct is supported, found %d", len(options)) @@ -204,6 +220,7 @@ func NewReconciler(ctx {{.contextContext|raw}}, logger *{{.zapSugaredLogger|raw} Lister: lister, Recorder: recorder, reconciler: r, + {{if .hasClass}}classValue: classValue,{{end}} } for _, opts := range options { @@ -245,6 +262,15 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro } else if err != nil { return err } + {{if .hasClass}} + if classValue, found := original.GetAnnotations()[classAnnotationKey]; !found || classValue != r.classValue { + logger.Debugw("Skip reconciling resource, class annotation value does not match reconciler instance value.", + zap.String("classKey", classAnnotationKey), + zap.String("issue", classValue+"!="+r.classValue)) + return nil + } + {{end}} + // Don't modify the informers copy. resource := original.DeepCopy() @@ -310,7 +336,7 @@ func (r *reconcilerImpl) updateStatus(existing *{{.type|raw}}, desired *{{.type| return {{.reconcilerRetryUpdateConflicts|raw}}(func(attempts int) (err error) { // The first iteration tries to use the injectionInformer's state, subsequent attempts fetch the latest state via API. if attempts > 0 { - existing, err = r.Client.{{.type|versionedClientset}}().{{.type|apiGroup}}(desired.Namespace).Get(desired.Name, {{.metav1GetOptions|raw}}{}) + existing, err = r.Client.{{.group}}{{.version}}().{{.type|apiGroup}}(desired.Namespace).Get(desired.Name, {{.metav1GetOptions|raw}}{}) if err != nil { return err } @@ -322,7 +348,7 @@ func (r *reconcilerImpl) updateStatus(existing *{{.type|raw}}, desired *{{.type| } existing.Status = desired.Status - _, err = r.Client.{{.type|versionedClientset}}().{{.type|apiGroup}}(existing.Namespace).UpdateStatus(existing) + _, err = r.Client.{{.group}}{{.version}}().{{.type|apiGroup}}(existing.Namespace).UpdateStatus(existing) return err }) } @@ -378,7 +404,7 @@ func (r *reconcilerImpl) updateFinalizersFiltered(ctx {{.contextContext|raw}}, r return resource, err } - resource, err = r.Client.{{.type|versionedClientset}}().{{.type|apiGroup}}(resource.Namespace).Patch(resource.Name, types.MergePatchType, patch) + resource, err = r.Client.{{.group}}{{.version}}().{{.type|apiGroup}}(resource.Namespace).Patch(resource.Name, types.MergePatchType, patch) if err != nil { r.Recorder.Eventf(resource, {{.corev1EventTypeWarning|raw}}, "FinalizerUpdateFailed", "Failed to update finalizers for %q: %v", resource.Name, err) diff --git a/vendor/knative.dev/pkg/hack/update-codegen.sh b/vendor/knative.dev/pkg/hack/update-codegen.sh index 75a6e158..631ef1d0 100755 --- a/vendor/knative.dev/pkg/hack/update-codegen.sh +++ b/vendor/knative.dev/pkg/hack/update-codegen.sh @@ -74,3 +74,4 @@ ${GOPATH}/bin/deepcopy-gen --input-dirs \ # Make sure our dependencies are up-to-date ${REPO_ROOT_DIR}/hack/update-deps.sh + diff --git a/vendor/knative.dev/pkg/injection/README.md b/vendor/knative.dev/pkg/injection/README.md index 806d9445..77b0877b 100644 --- a/vendor/knative.dev/pkg/injection/README.md +++ b/vendor/knative.dev/pkg/injection/README.md @@ -352,13 +352,11 @@ The responsibility and consequences of using the generated Future features to be considered: -- Leverage `configStore` and specifically `ctx = r.configStore.ToContext(ctx)` - inside `Reconcile`. -- Resulting changes from `Reconcile` calling `ReconcileKind(ctx, resource)`: - - If `resource.metadata.labels` or `.annotations` are updated, `Reconcile` - will synchronize it back to the API Server. +- Document how we leverage `configStore` and specifically + `ctx = r.configStore.ToContext(ctx)` inside `Reconcile`. - Adjust `+genreconciler` to allow for generated reconcilers to be made without annotating the type struct. +- Add class-based annotation filtering. ### ConfigStore @@ -425,6 +423,35 @@ var _ addressableservicereconciler.Interface = (*Reconciler)(nil) var _ addressableservicereconciler.Finalizer = (*Reconciler)(nil) ``` +#### Annotation based class filters + +Sometimes a reconciler only wants to reconcile a class of resource identified by +a special annotation on the Custom Resource. + +This behavior can be enabled in the generators by adding the annotation class +key to the type struct: + +```go +// +genreconciler:class=example.com/filter.class +``` + +The `genreconciler` generator code will now have the addition of +`classValue string` to `NewImpl` and `NewReconciler` (for tests): + +```go +NewImpl(ctx context.Context, r Interface, classValue string, optionsFns ...controller.OptionsFn) *controller.Impl +``` + +```go +NewReconciler(ctx context.Context, logger *zap.SugaredLogger, client versioned.Interface, lister pubv1alpha1.BarLister, recorder record.EventRecorder, r Interface, classValue string, options ...controller.Options) controller.Reconciler +``` + +`ReconcileKind` and `FinalizeKind` will NOT be called for resources that DO NOT +have the provided `+genreconciler:class=` key annotation. Additionally the +value of the `` annotation on a resource must match the value provided to +`NewImpl` (or `NewReconcile`) for `ReconcileKind` or `FinalizeKind` to be called +for that resource. + #### Stubs To get started, or to use as reference. It is intended to be copied out of the diff --git a/vendor/knative.dev/pkg/logging/testing/util.go b/vendor/knative.dev/pkg/logging/testing/util.go index 3c844aad..f2a8d354 100644 --- a/vendor/knative.dev/pkg/logging/testing/util.go +++ b/vendor/knative.dev/pkg/logging/testing/util.go @@ -18,6 +18,7 @@ package testing import ( "context" + "go.uber.org/zap" "go.uber.org/zap/zaptest" diff --git a/vendor/knative.dev/pkg/test/presubmit-tests.sh b/vendor/knative.dev/pkg/test/presubmit-tests.sh index 03a40737..5bcb6262 100755 --- a/vendor/knative.dev/pkg/test/presubmit-tests.sh +++ b/vendor/knative.dev/pkg/test/presubmit-tests.sh @@ -24,6 +24,10 @@ export DISABLE_MD_LINTING=1 source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/presubmit-tests.sh +# Test the custom code generators. This makes sure we can compile the output +# of the injection generators. +$(dirname $0)/update-test-codegen.sh + # TODO(#17): Write integration tests. # We use the default build, unit and integration test runners. diff --git a/vendor/knative.dev/pkg/test/update-test-codegen.sh b/vendor/knative.dev/pkg/test/update-test-codegen.sh new file mode 100755 index 00000000..47057637 --- /dev/null +++ b/vendor/knative.dev/pkg/test/update-test-codegen.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright 2020 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. + +set -o errexit +set -o nounset +set -o pipefail + +source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/library.sh + +CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 $(dirname $0)/../vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)} +KNATIVE_CODEGEN_PKG=${KNATIVE_CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 $(dirname $0)/../vendor/knative.dev/pkg 2>/dev/null || echo ../pkg)} + +GENCLIENT_PKG=knative.dev/pkg/test/genclient +( + cd ${REPO_ROOT_DIR} + rm -rf ${REPO_ROOT_DIR}/pkg/test/genclient +) + +${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ + ${GENCLIENT_PKG} knative.dev/pkg/apis/test \ + "example:v1alpha1" \ + --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt + +# Knative Injection +${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh "injection" \ + ${GENCLIENT_PKG} knative.dev/pkg/apis/test \ + "example:v1alpha1" \ + --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt + +${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ + ${GENCLIENT_PKG}/pub knative.dev/pkg/apis/test \ + "pub:v1alpha1" \ + --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt + +# Knative Injection +${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh "injection" \ + ${GENCLIENT_PKG}/pub knative.dev/pkg/apis/test \ + "pub:v1alpha1" \ + --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt + + diff --git a/vendor/knative.dev/test-infra/scripts/README.md b/vendor/knative.dev/test-infra/scripts/README.md index cc2cdd10..ca673fb1 100644 --- a/vendor/knative.dev/test-infra/scripts/README.md +++ b/vendor/knative.dev/test-infra/scripts/README.md @@ -1,6 +1,6 @@ # Helper scripts -This directory contains helper scripts used by Prow test jobs, as well and local +This directory contains helper scripts used by Prow test jobs, as well as local development scripts. ## Using the `presubmit-tests.sh` helper script