mirror of https://github.com/knative/pkg.git
[Genreconciler] Fix group names when client groups differ than their directory name. (#1097)
* looking at annotations for group overrides. * checkpoint. * checkpoint * I think it is correct. * ok * trim down the files. * simulate tekton * working test out of checkin * remove test client * update docs * and test. * lint * it ok * update codegen
This commit is contained in:
parent
945b556708
commit
72f3cd2bbc
|
|
@ -12,3 +12,6 @@ bazel-*
|
|||
|
||||
# Emacs files
|
||||
*~
|
||||
|
||||
# Generated Test Code
|
||||
test/genclient
|
||||
|
|
|
|||
|
|
@ -1443,6 +1443,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",
|
||||
|
|
@ -1470,6 +1471,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",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
// +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
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -465,6 +465,8 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp
|
|||
clientsetPkg: customArgs.VersionedClientSetPackage,
|
||||
listerName: t.Name.Name + "Lister",
|
||||
listerPkg: listerPackagePath,
|
||||
groupGoName: groupGoName,
|
||||
groupVersion: gv,
|
||||
})
|
||||
|
||||
return generators
|
||||
|
|
|
|||
|
|
@ -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,9 @@ type reconcilerReconcilerGenerator struct {
|
|||
clientsetPkg string
|
||||
listerName string
|
||||
listerPkg string
|
||||
|
||||
groupGoName string
|
||||
groupVersion clientgentypes.GroupVersion
|
||||
}
|
||||
|
||||
var _ generator.Generator = (*reconcilerReconcilerGenerator)(nil)
|
||||
|
|
@ -60,8 +65,9 @@ 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()),
|
||||
"controllerImpl": c.Universe.Type(types.Name{
|
||||
Package: "knative.dev/pkg/controller",
|
||||
Name: "Impl",
|
||||
|
|
@ -310,7 +316,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 +328,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 +384,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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue