mirror of https://github.com/knative/caching.git
Auto-update dependencies (#208)
Produced via: `dep ensure -update knative.dev/test-infra knative.dev/pkg` /assign n3wscott /cc n3wscott
This commit is contained in:
parent
1f067018c4
commit
c75efc13dc
|
@ -966,7 +966,7 @@
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:6e2169542b76688fe02763aee6b53dedc9d71acb8608705393c4230ffae94e68"
|
digest = "1:4d466bcd929b5ae71fddc9153076b396c5d05479f03b2ae6318c3433578205dc"
|
||||||
name = "knative.dev/pkg"
|
name = "knative.dev/pkg"
|
||||||
packages = [
|
packages = [
|
||||||
"apis",
|
"apis",
|
||||||
|
@ -986,18 +986,18 @@
|
||||||
"reconciler",
|
"reconciler",
|
||||||
]
|
]
|
||||||
pruneopts = "T"
|
pruneopts = "T"
|
||||||
revision = "1cc7b7152937735a29c9d6fdaf3b244684aa850e"
|
revision = "5d8a01d12cc825688b14117af294139fee2270eb"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:691951c6805590983ccea7c6dbca360bcb58af5f4d60f75af9499903bb3039e9"
|
digest = "1:043997c1e0120a3c74c981acf40438f54db2753a756e8896fc67fd9edb9ccea9"
|
||||||
name = "knative.dev/test-infra"
|
name = "knative.dev/test-infra"
|
||||||
packages = [
|
packages = [
|
||||||
"scripts",
|
"scripts",
|
||||||
"tools/dep-collector",
|
"tools/dep-collector",
|
||||||
]
|
]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "9a261621df10478b791e5a320481766b38b43471"
|
revision = "fb304f6a7ac965fb3eb5cb16d5e0301ca60e3247"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"
|
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"
|
||||||
|
|
|
@ -12,3 +12,6 @@ bazel-*
|
||||||
|
|
||||||
# Emacs files
|
# Emacs files
|
||||||
*~
|
*~
|
||||||
|
|
||||||
|
# Generated Test Code
|
||||||
|
test/genclient
|
||||||
|
|
|
@ -1442,6 +1442,7 @@
|
||||||
"k8s.io/apimachinery/pkg/version",
|
"k8s.io/apimachinery/pkg/version",
|
||||||
"k8s.io/apimachinery/pkg/watch",
|
"k8s.io/apimachinery/pkg/watch",
|
||||||
"k8s.io/client-go/discovery",
|
"k8s.io/client-go/discovery",
|
||||||
|
"k8s.io/client-go/discovery/fake",
|
||||||
"k8s.io/client-go/dynamic",
|
"k8s.io/client-go/dynamic",
|
||||||
"k8s.io/client-go/dynamic/fake",
|
"k8s.io/client-go/dynamic/fake",
|
||||||
"k8s.io/client-go/informers",
|
"k8s.io/client-go/informers",
|
||||||
|
@ -1469,6 +1470,7 @@
|
||||||
"k8s.io/client-go/tools/clientcmd",
|
"k8s.io/client-go/tools/clientcmd",
|
||||||
"k8s.io/client-go/tools/metrics",
|
"k8s.io/client-go/tools/metrics",
|
||||||
"k8s.io/client-go/tools/record",
|
"k8s.io/client-go/tools/record",
|
||||||
|
"k8s.io/client-go/util/flowcontrol",
|
||||||
"k8s.io/client-go/util/retry",
|
"k8s.io/client-go/util/retry",
|
||||||
"k8s.io/client-go/util/workqueue",
|
"k8s.io/client-go/util/workqueue",
|
||||||
"k8s.io/code-generator/cmd/client-gen",
|
"k8s.io/code-generator/cmd/client-gen",
|
||||||
|
|
|
@ -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"
|
||||||
|
)
|
|
@ -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
|
|
@ -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
|
||||||
|
}
|
|
@ -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
|
||||||
|
}
|
119
vendor/knative.dev/pkg/apis/test/example/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
119
vendor/knative.dev/pkg/apis/test/example/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
|
@ -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
|
||||||
|
}
|
|
@ -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"
|
||||||
|
)
|
|
@ -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
|
||||||
|
}
|
|
@ -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
|
|
@ -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
|
||||||
|
}
|
119
vendor/knative.dev/pkg/apis/test/pub/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
119
vendor/knative.dev/pkg/apis/test/pub/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
|
@ -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
|
||||||
|
}
|
|
@ -165,13 +165,31 @@ func MustParseClientGenTags(lines []string) Tags {
|
||||||
}
|
}
|
||||||
|
|
||||||
values := types.ExtractCommentTags("+", lines)
|
values := types.ExtractCommentTags("+", lines)
|
||||||
// log.Printf("GOT values %v", values)
|
|
||||||
_, ret.GenerateDuck = values["genduck"]
|
_, 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
|
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
|
// isInternal returns true if the tags for a member do not contain a json tag
|
||||||
func isInternal(m types.Member) bool {
|
func isInternal(m types.Member) bool {
|
||||||
return !strings.Contains(m.Tags, "json")
|
return !strings.Contains(m.Tags, "json")
|
||||||
|
@ -387,6 +405,8 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp
|
||||||
// Fix for golang iterator bug.
|
// Fix for golang iterator bug.
|
||||||
t := t
|
t := t
|
||||||
|
|
||||||
|
reconcilerClass, hasReconcilerClass := extractReconcilerClassTag(t)
|
||||||
|
|
||||||
packagePath := filepath.Join(packagePath, strings.ToLower(t.Name.Name))
|
packagePath := filepath.Join(packagePath, strings.ToLower(t.Name.Name))
|
||||||
|
|
||||||
clientPackagePath := filepath.Join(basePackage, "client")
|
clientPackagePath := filepath.Join(basePackage, "client")
|
||||||
|
@ -412,6 +432,8 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp
|
||||||
clientPkg: clientPackagePath,
|
clientPkg: clientPackagePath,
|
||||||
informerPackagePath: informerPackagePath,
|
informerPackagePath: informerPackagePath,
|
||||||
schemePkg: filepath.Join(customArgs.VersionedClientSetPackage, "scheme"),
|
schemePkg: filepath.Join(customArgs.VersionedClientSetPackage, "scheme"),
|
||||||
|
reconcilerClass: reconcilerClass,
|
||||||
|
hasReconcilerClass: hasReconcilerClass,
|
||||||
})
|
})
|
||||||
|
|
||||||
return generators
|
return generators
|
||||||
|
@ -438,6 +460,8 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp
|
||||||
outputPackage: filepath.Join(packagePath, "stub"),
|
outputPackage: filepath.Join(packagePath, "stub"),
|
||||||
imports: generator.NewImportTracker(),
|
imports: generator.NewImportTracker(),
|
||||||
informerPackagePath: informerPackagePath,
|
informerPackagePath: informerPackagePath,
|
||||||
|
reconcilerClass: reconcilerClass,
|
||||||
|
hasReconcilerClass: hasReconcilerClass,
|
||||||
})
|
})
|
||||||
|
|
||||||
return generators
|
return generators
|
||||||
|
@ -465,6 +489,10 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp
|
||||||
clientsetPkg: customArgs.VersionedClientSetPackage,
|
clientsetPkg: customArgs.VersionedClientSetPackage,
|
||||||
listerName: t.Name.Name + "Lister",
|
listerName: t.Name.Name + "Lister",
|
||||||
listerPkg: listerPackagePath,
|
listerPkg: listerPackagePath,
|
||||||
|
groupGoName: groupGoName,
|
||||||
|
groupVersion: gv,
|
||||||
|
reconcilerClass: reconcilerClass,
|
||||||
|
hasReconcilerClass: hasReconcilerClass,
|
||||||
})
|
})
|
||||||
|
|
||||||
return generators
|
return generators
|
||||||
|
|
|
@ -37,6 +37,9 @@ type reconcilerControllerGenerator struct {
|
||||||
clientPkg string
|
clientPkg string
|
||||||
schemePkg string
|
schemePkg string
|
||||||
informerPackagePath string
|
informerPackagePath string
|
||||||
|
|
||||||
|
reconcilerClass string
|
||||||
|
hasReconcilerClass bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ generator.Generator = (*reconcilerControllerGenerator)(nil)
|
var _ generator.Generator = (*reconcilerControllerGenerator)(nil)
|
||||||
|
@ -65,6 +68,8 @@ func (g *reconcilerControllerGenerator) GenerateType(c *generator.Context, t *ty
|
||||||
m := map[string]interface{}{
|
m := map[string]interface{}{
|
||||||
"type": t,
|
"type": t,
|
||||||
"group": g.groupName,
|
"group": g.groupName,
|
||||||
|
"class": g.reconcilerClass,
|
||||||
|
"hasClass": g.hasReconcilerClass,
|
||||||
"controllerImpl": c.Universe.Type(types.Name{
|
"controllerImpl": c.Universe.Type(types.Name{
|
||||||
Package: "knative.dev/pkg/controller",
|
Package: "knative.dev/pkg/controller",
|
||||||
Name: "Impl",
|
Name: "Impl",
|
||||||
|
@ -149,13 +154,14 @@ const (
|
||||||
defaultControllerAgentName = "{{.type|lowercaseSingular}}-controller"
|
defaultControllerAgentName = "{{.type|lowercaseSingular}}-controller"
|
||||||
defaultFinalizerName = "{{.type|allLowercasePlural}}.{{.group}}"
|
defaultFinalizerName = "{{.type|allLowercasePlural}}.{{.group}}"
|
||||||
defaultQueueName = "{{.type|allLowercasePlural}}"
|
defaultQueueName = "{{.type|allLowercasePlural}}"
|
||||||
|
{{if .hasClass}}classAnnotationKey = "{{ .class }}"{{end}}
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewImpl returns a {{.controllerImpl|raw}} that handles queuing and feeding work from
|
// NewImpl returns a {{.controllerImpl|raw}} that handles queuing and feeding work from
|
||||||
// the queue through an implementation of {{.controllerReconciler|raw}}, delegating to
|
// the queue through an implementation of {{.controllerReconciler|raw}}, delegating to
|
||||||
// the provided Interface and optional Finalizer methods. OptionsFn is used to return
|
// the provided Interface and optional Finalizer methods. OptionsFn is used to return
|
||||||
// {{.controllerOptions|raw}} to be used but the internal reconciler.
|
// {{.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)
|
logger := {{.loggingFromContext|raw}}(ctx)
|
||||||
|
|
||||||
// Check the options function input. It should be 0 or 1.
|
// 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(),
|
Lister: {{.type|lowercaseSingular}}Informer.Lister(),
|
||||||
Recorder: recorder,
|
Recorder: recorder,
|
||||||
reconciler: r,
|
reconciler: r,
|
||||||
|
{{if .hasClass}}classValue: classValue,{{end}}
|
||||||
}
|
}
|
||||||
impl := {{.controllerNewImpl|raw}}(rec, logger, defaultQueueName)
|
impl := {{.controllerNewImpl|raw}}(rec, logger, defaultQueueName)
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,8 @@ type reconcilerControllerStubGenerator struct {
|
||||||
|
|
||||||
reconcilerPkg string
|
reconcilerPkg string
|
||||||
informerPackagePath string
|
informerPackagePath string
|
||||||
|
reconcilerClass string
|
||||||
|
hasReconcilerClass bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ generator.Generator = (*reconcilerControllerStubGenerator)(nil)
|
var _ generator.Generator = (*reconcilerControllerStubGenerator)(nil)
|
||||||
|
@ -62,6 +64,8 @@ func (g *reconcilerControllerStubGenerator) GenerateType(c *generator.Context, t
|
||||||
|
|
||||||
m := map[string]interface{}{
|
m := map[string]interface{}{
|
||||||
"type": t,
|
"type": t,
|
||||||
|
"class": g.reconcilerClass,
|
||||||
|
"hasClass": g.hasReconcilerClass,
|
||||||
"informerGet": c.Universe.Function(types.Name{
|
"informerGet": c.Universe.Function(types.Name{
|
||||||
Package: g.informerPackagePath,
|
Package: g.informerPackagePath,
|
||||||
Name: "Get",
|
Name: "Get",
|
||||||
|
@ -103,9 +107,10 @@ func NewController(
|
||||||
{{.type|lowercaseSingular}}Informer := {{.informerGet|raw}}(ctx)
|
{{.type|lowercaseSingular}}Informer := {{.informerGet|raw}}(ctx)
|
||||||
|
|
||||||
// TODO: setup additional informers here.
|
// TODO: setup additional informers here.
|
||||||
|
{{if .hasClass}}// TODO: pass in the expected value for the class annotation filter.{{end}}
|
||||||
|
|
||||||
r := &Reconciler{}
|
r := &Reconciler{}
|
||||||
impl := {{.reconcilerNewImpl|raw}}(ctx, r)
|
impl := {{.reconcilerNewImpl|raw}}(ctx, r{{if .hasClass}}, "default"{{end}})
|
||||||
|
|
||||||
logger.Info("Setting up event handlers.")
|
logger.Info("Setting up event handlers.")
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ package generators
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
clientgentypes "k8s.io/code-generator/cmd/client-gen/types"
|
||||||
|
|
||||||
"k8s.io/gengo/generator"
|
"k8s.io/gengo/generator"
|
||||||
"k8s.io/gengo/namer"
|
"k8s.io/gengo/namer"
|
||||||
"k8s.io/gengo/types"
|
"k8s.io/gengo/types"
|
||||||
|
@ -34,6 +36,12 @@ type reconcilerReconcilerGenerator struct {
|
||||||
clientsetPkg string
|
clientsetPkg string
|
||||||
listerName string
|
listerName string
|
||||||
listerPkg string
|
listerPkg string
|
||||||
|
|
||||||
|
reconcilerClass string
|
||||||
|
hasReconcilerClass bool
|
||||||
|
|
||||||
|
groupGoName string
|
||||||
|
groupVersion clientgentypes.GroupVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ generator.Generator = (*reconcilerReconcilerGenerator)(nil)
|
var _ generator.Generator = (*reconcilerReconcilerGenerator)(nil)
|
||||||
|
@ -61,7 +69,10 @@ func (g *reconcilerReconcilerGenerator) GenerateType(c *generator.Context, t *ty
|
||||||
|
|
||||||
m := map[string]interface{}{
|
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{
|
"controllerImpl": c.Universe.Type(types.Name{
|
||||||
Package: "knative.dev/pkg/controller",
|
Package: "knative.dev/pkg/controller",
|
||||||
Name: "Impl",
|
Name: "Impl",
|
||||||
|
@ -185,6 +196,11 @@ type reconcilerImpl struct {
|
||||||
|
|
||||||
// reconciler is the implementation of the business logic of the resource.
|
// reconciler is the implementation of the business logic of the resource.
|
||||||
reconciler Interface
|
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
|
// Check that our Reconciler implements controller.Reconciler
|
||||||
|
@ -193,7 +209,7 @@ var _ controller.Reconciler = (*reconcilerImpl)(nil)
|
||||||
`
|
`
|
||||||
|
|
||||||
var reconcilerNewReconciler = `
|
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.
|
// Check the options function input. It should be 0 or 1.
|
||||||
if len(options) > 1 {
|
if len(options) > 1 {
|
||||||
logger.Fatalf("up to one options struct is supported, found %d", len(options))
|
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,
|
Lister: lister,
|
||||||
Recorder: recorder,
|
Recorder: recorder,
|
||||||
reconciler: r,
|
reconciler: r,
|
||||||
|
{{if .hasClass}}classValue: classValue,{{end}}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, opts := range options {
|
for _, opts := range options {
|
||||||
|
@ -245,6 +262,15 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return err
|
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.
|
// Don't modify the informers copy.
|
||||||
resource := original.DeepCopy()
|
resource := original.DeepCopy()
|
||||||
|
|
||||||
|
@ -310,7 +336,7 @@ func (r *reconcilerImpl) updateStatus(existing *{{.type|raw}}, desired *{{.type|
|
||||||
return {{.reconcilerRetryUpdateConflicts|raw}}(func(attempts int) (err error) {
|
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.
|
// The first iteration tries to use the injectionInformer's state, subsequent attempts fetch the latest state via API.
|
||||||
if attempts > 0 {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -322,7 +348,7 @@ func (r *reconcilerImpl) updateStatus(existing *{{.type|raw}}, desired *{{.type|
|
||||||
}
|
}
|
||||||
|
|
||||||
existing.Status = desired.Status
|
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
|
return err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -378,7 +404,7 @@ func (r *reconcilerImpl) updateFinalizersFiltered(ctx {{.contextContext|raw}}, r
|
||||||
return resource, err
|
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 {
|
if err != nil {
|
||||||
r.Recorder.Eventf(resource, {{.corev1EventTypeWarning|raw}}, "FinalizerUpdateFailed",
|
r.Recorder.Eventf(resource, {{.corev1EventTypeWarning|raw}}, "FinalizerUpdateFailed",
|
||||||
"Failed to update finalizers for %q: %v", resource.Name, err)
|
"Failed to update finalizers for %q: %v", resource.Name, err)
|
||||||
|
|
|
@ -74,3 +74,4 @@ ${GOPATH}/bin/deepcopy-gen --input-dirs \
|
||||||
|
|
||||||
# Make sure our dependencies are up-to-date
|
# Make sure our dependencies are up-to-date
|
||||||
${REPO_ROOT_DIR}/hack/update-deps.sh
|
${REPO_ROOT_DIR}/hack/update-deps.sh
|
||||||
|
|
||||||
|
|
|
@ -352,13 +352,11 @@ The responsibility and consequences of using the generated
|
||||||
|
|
||||||
Future features to be considered:
|
Future features to be considered:
|
||||||
|
|
||||||
- Leverage `configStore` and specifically `ctx = r.configStore.ToContext(ctx)`
|
- Document how we leverage `configStore` and specifically
|
||||||
inside `Reconcile`.
|
`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.
|
|
||||||
- Adjust `+genreconciler` to allow for generated reconcilers to be made without
|
- Adjust `+genreconciler` to allow for generated reconcilers to be made without
|
||||||
annotating the type struct.
|
annotating the type struct.
|
||||||
|
- Add class-based annotation filtering.
|
||||||
|
|
||||||
### ConfigStore
|
### ConfigStore
|
||||||
|
|
||||||
|
@ -425,6 +423,35 @@ var _ addressableservicereconciler.Interface = (*Reconciler)(nil)
|
||||||
var _ addressableservicereconciler.Finalizer = (*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>` key annotation. Additionally the
|
||||||
|
value of the `<key>` annotation on a resource must match the value provided to
|
||||||
|
`NewImpl` (or `NewReconcile`) for `ReconcileKind` or `FinalizeKind` to be called
|
||||||
|
for that resource.
|
||||||
|
|
||||||
#### Stubs
|
#### Stubs
|
||||||
|
|
||||||
To get started, or to use as reference. It is intended to be copied out of the
|
To get started, or to use as reference. It is intended to be copied out of the
|
||||||
|
|
|
@ -18,6 +18,7 @@ package testing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zaptest"
|
"go.uber.org/zap/zaptest"
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,10 @@ export DISABLE_MD_LINTING=1
|
||||||
|
|
||||||
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/presubmit-tests.sh
|
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.
|
# TODO(#17): Write integration tests.
|
||||||
|
|
||||||
# We use the default build, unit and integration test runners.
|
# We use the default build, unit and integration test runners.
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Helper scripts
|
# 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.
|
development scripts.
|
||||||
|
|
||||||
## Using the `presubmit-tests.sh` helper script
|
## Using the `presubmit-tests.sh` helper script
|
||||||
|
|
Loading…
Reference in New Issue