Merge pull request #55614 from sttts/sttts-codegen-apis-domains

Automatic merge from submit-queue (batch tested with PRs 54436, 53148, 55153, 55614, 55484). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

code-generator: complete PkgName, GroupName, GoName seperation

... in client-gen, informer-gen, lister-gen. Follow-up of https://github.com/kubernetes/kubernetes/pull/54950.

Before this PR, the generated code was broken for internal types and for group package names that were no valid Go identifiers.

This PR completes the separation in the following sense:

- GroupNames are domain-like logical name for the group. Only the first segment is used as default for GoName
- PkgName is the directory name. All packages in client, informer, lister re-use this for packages.
- GoName is the Go identifier (CamelCase) used to reference the group, e.g. in the interface names, in the clientsets etc. Moreover it is used for package import aliases.

Note: this PR **does not** change the generated code in Kubernetes, only the examples in k8s.io/code-generator.

```release-note
Fix code-generators to produce correct code when GroupName, PackageName and/or GoName differ.
```
This commit is contained in:
Kubernetes Submit Queue
2017-11-15 12:58:07 -08:00
committed by GitHub
68 changed files with 2395 additions and 73 deletions

View File

@@ -21,7 +21,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
) )
var SchemeGroupVersion = schema.GroupVersion{Group: "testgroup.k8s.io", Version: runtime.APIVersionInternal} var SchemeGroupVersion = schema.GroupVersion{Group: "example.api.code-generator.k8s.io", Version: runtime.APIVersionInternal}
var ( var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

View File

@@ -0,0 +1,20 @@
/*
Copyright 2015 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// +k8s:deepcopy-gen=package
// +groupName=example.test.apiserver.code-generator.k8s.io
// +groupGoName=SecondExample
package example2 // import "k8s.io/code-generator/_examples/apiserver/apis/example2"

View File

@@ -0,0 +1,43 @@
/*
Copyright 2015 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package install installs the experimental API group, making it available as
// an option to all of the API encoding/decoding machinery.
package install
import (
"k8s.io/apimachinery/pkg/apimachinery/announced"
"k8s.io/apimachinery/pkg/apimachinery/registered"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/code-generator/_examples/apiserver/apis/example2"
"k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
)
// Install registers the API group and adds types to a scheme
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
if err := announced.NewGroupMetaFactory(
&announced.GroupMetaFactoryArgs{
GroupName: example2.SchemeGroupVersion.Group,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version},
AddInternalObjectsToScheme: example2.AddToScheme,
},
announced.VersionToSchemeFunc{
v1.SchemeGroupVersion.Version: v1.AddToScheme,
},
).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil {
panic(err)
}
}

View File

@@ -0,0 +1,45 @@
/*
Copyright 2015 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package example2
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
var SchemeGroupVersion = schema.GroupVersion{Group: "example.test.apiserver.code-generator.k8s.io", Version: runtime.APIVersionInternal}
var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
// Adds the list of known types to the given scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&TestType{},
&TestTypeList{},
)
scheme.AddKnownTypes(SchemeGroupVersion)
return nil
}

View File

@@ -0,0 +1,44 @@
/*
Copyright 2015 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package example2
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// TestType is a top-level type. A client is created for it.
type TestType struct {
metav1.TypeMeta
metav1.ObjectMeta
Status TestTypeStatus
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// TestTypeList is a top-level list type. The client methods for lists are automatically created.
// You are not supposed to create a separated client for this one.
type TestTypeList struct {
metav1.TypeMeta
metav1.ListMeta
Items []TestType
}
type TestTypeStatus struct {
Blah string
}

View File

@@ -0,0 +1,21 @@
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// +k8s:deepcopy-gen=package
// +groupName=example.test.apiserver.code-generator.k8s.io
// +k8s:conversion-gen=k8s.io/code-generator/_examples/apiserver/apis/example2
// +groupGoName=SecondExample
package v1

View File

@@ -0,0 +1,59 @@
/*
Copyright 2015 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
var SchemeGroupVersion = schema.GroupVersion{Group: "example.test.apiserver.code-generator.k8s.io", Version: "v1"}
var (
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
SchemeBuilder runtime.SchemeBuilder
localSchemeBuilder = &SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)
func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addKnownTypes)
}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&TestType{},
&TestTypeList{},
)
scheme.AddKnownTypes(SchemeGroupVersion,
&metav1.Status{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}

View File

@@ -0,0 +1,47 @@
/*
Copyright 2015 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// TestType is a top-level type. A client is created for it.
type TestType struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// +optional
Status TestTypeStatus `json:"status,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// TestTypeList is a top-level list type. The client methods for lists are automatically created.
// You are not supposed to create a separated client for this one.
type TestTypeList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
Items []TestType `json:"items"`
}
type TestTypeStatus struct {
Blah string
}

View File

@@ -0,0 +1,113 @@
// +build !ignore_autogenerated
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by conversion-gen. Do not edit it manually!
package v1
import (
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
example2 "k8s.io/code-generator/_examples/apiserver/apis/example2"
unsafe "unsafe"
)
func init() {
localSchemeBuilder.Register(RegisterConversions)
}
// RegisterConversions adds conversion functions to the given scheme.
// Public to allow building arbitrary schemes.
func RegisterConversions(scheme *runtime.Scheme) error {
return scheme.AddGeneratedConversionFuncs(
Convert_v1_TestType_To_example2_TestType,
Convert_example2_TestType_To_v1_TestType,
Convert_v1_TestTypeList_To_example2_TestTypeList,
Convert_example2_TestTypeList_To_v1_TestTypeList,
Convert_v1_TestTypeStatus_To_example2_TestTypeStatus,
Convert_example2_TestTypeStatus_To_v1_TestTypeStatus,
)
}
func autoConvert_v1_TestType_To_example2_TestType(in *TestType, out *example2.TestType, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_v1_TestTypeStatus_To_example2_TestTypeStatus(&in.Status, &out.Status, s); err != nil {
return err
}
return nil
}
// Convert_v1_TestType_To_example2_TestType is an autogenerated conversion function.
func Convert_v1_TestType_To_example2_TestType(in *TestType, out *example2.TestType, s conversion.Scope) error {
return autoConvert_v1_TestType_To_example2_TestType(in, out, s)
}
func autoConvert_example2_TestType_To_v1_TestType(in *example2.TestType, out *TestType, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_example2_TestTypeStatus_To_v1_TestTypeStatus(&in.Status, &out.Status, s); err != nil {
return err
}
return nil
}
// Convert_example2_TestType_To_v1_TestType is an autogenerated conversion function.
func Convert_example2_TestType_To_v1_TestType(in *example2.TestType, out *TestType, s conversion.Scope) error {
return autoConvert_example2_TestType_To_v1_TestType(in, out, s)
}
func autoConvert_v1_TestTypeList_To_example2_TestTypeList(in *TestTypeList, out *example2.TestTypeList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]example2.TestType)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_v1_TestTypeList_To_example2_TestTypeList is an autogenerated conversion function.
func Convert_v1_TestTypeList_To_example2_TestTypeList(in *TestTypeList, out *example2.TestTypeList, s conversion.Scope) error {
return autoConvert_v1_TestTypeList_To_example2_TestTypeList(in, out, s)
}
func autoConvert_example2_TestTypeList_To_v1_TestTypeList(in *example2.TestTypeList, out *TestTypeList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]TestType)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_example2_TestTypeList_To_v1_TestTypeList is an autogenerated conversion function.
func Convert_example2_TestTypeList_To_v1_TestTypeList(in *example2.TestTypeList, out *TestTypeList, s conversion.Scope) error {
return autoConvert_example2_TestTypeList_To_v1_TestTypeList(in, out, s)
}
func autoConvert_v1_TestTypeStatus_To_example2_TestTypeStatus(in *TestTypeStatus, out *example2.TestTypeStatus, s conversion.Scope) error {
out.Blah = in.Blah
return nil
}
// Convert_v1_TestTypeStatus_To_example2_TestTypeStatus is an autogenerated conversion function.
func Convert_v1_TestTypeStatus_To_example2_TestTypeStatus(in *TestTypeStatus, out *example2.TestTypeStatus, s conversion.Scope) error {
return autoConvert_v1_TestTypeStatus_To_example2_TestTypeStatus(in, out, s)
}
func autoConvert_example2_TestTypeStatus_To_v1_TestTypeStatus(in *example2.TestTypeStatus, out *TestTypeStatus, s conversion.Scope) error {
out.Blah = in.Blah
return nil
}
// Convert_example2_TestTypeStatus_To_v1_TestTypeStatus is an autogenerated conversion function.
func Convert_example2_TestTypeStatus_To_v1_TestTypeStatus(in *example2.TestTypeStatus, out *TestTypeStatus, s conversion.Scope) error {
return autoConvert_example2_TestTypeStatus_To_v1_TestTypeStatus(in, out, s)
}

View File

@@ -0,0 +1,103 @@
// +build !ignore_autogenerated
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package v1
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 *TestType) DeepCopyInto(out *TestType) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Status = in.Status
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestType.
func (in *TestType) DeepCopy() *TestType {
if in == nil {
return nil
}
out := new(TestType)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *TestType) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TestTypeList) DeepCopyInto(out *TestTypeList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]TestType, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeList.
func (in *TestTypeList) DeepCopy() *TestTypeList {
if in == nil {
return nil
}
out := new(TestTypeList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *TestTypeList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TestTypeStatus) DeepCopyInto(out *TestTypeStatus) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeStatus.
func (in *TestTypeStatus) DeepCopy() *TestTypeStatus {
if in == nil {
return nil
}
out := new(TestTypeStatus)
in.DeepCopyInto(out)
return out
}

View File

@@ -0,0 +1,32 @@
// +build !ignore_autogenerated
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by defaulter-gen. Do not edit it manually!
package v1
import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// RegisterDefaults adds defaulters functions to the given scheme.
// Public to allow building arbitrary schemes.
// All generated defaulters are covering - they call all nested defaulters.
func RegisterDefaults(scheme *runtime.Scheme) error {
return nil
}

View File

@@ -0,0 +1,103 @@
// +build !ignore_autogenerated
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package example2
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 *TestType) DeepCopyInto(out *TestType) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Status = in.Status
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestType.
func (in *TestType) DeepCopy() *TestType {
if in == nil {
return nil
}
out := new(TestType)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *TestType) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TestTypeList) DeepCopyInto(out *TestTypeList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]TestType, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeList.
func (in *TestTypeList) DeepCopy() *TestTypeList {
if in == nil {
return nil
}
out := new(TestTypeList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *TestTypeList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TestTypeStatus) DeepCopyInto(out *TestTypeStatus) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeStatus.
func (in *TestTypeStatus) DeepCopy() *TestTypeStatus {
if in == nil {
return nil
}
out := new(TestTypeStatus)
in.DeepCopyInto(out)
return out
}

View File

@@ -22,18 +22,21 @@ import (
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol" flowcontrol "k8s.io/client-go/util/flowcontrol"
exampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion" exampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion"
secondexampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion"
) )
type Interface interface { type Interface interface {
Discovery() discovery.DiscoveryInterface Discovery() discovery.DiscoveryInterface
Example() exampleinternalversion.ExampleInterface Example() exampleinternalversion.ExampleInterface
SecondExample() secondexampleinternalversion.SecondExampleInterface
} }
// Clientset contains the clients for groups. Each group has exactly one // Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset. // version included in a Clientset.
type Clientset struct { type Clientset struct {
*discovery.DiscoveryClient *discovery.DiscoveryClient
example *exampleinternalversion.ExampleClient example *exampleinternalversion.ExampleClient
secondExample *secondexampleinternalversion.SecondExampleClient
} }
// Example retrieves the ExampleClient // Example retrieves the ExampleClient
@@ -41,6 +44,11 @@ func (c *Clientset) Example() exampleinternalversion.ExampleInterface {
return c.example return c.example
} }
// SecondExample retrieves the SecondExampleClient
func (c *Clientset) SecondExample() secondexampleinternalversion.SecondExampleInterface {
return c.secondExample
}
// Discovery retrieves the DiscoveryClient // Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface { func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil { if c == nil {
@@ -61,6 +69,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
cs.secondExample, err = secondexampleinternalversion.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil { if err != nil {
@@ -75,6 +87,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
func NewForConfigOrDie(c *rest.Config) *Clientset { func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset var cs Clientset
cs.example = exampleinternalversion.NewForConfigOrDie(c) cs.example = exampleinternalversion.NewForConfigOrDie(c)
cs.secondExample = secondexampleinternalversion.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs return &cs
@@ -84,6 +97,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
func New(c rest.Interface) *Clientset { func New(c rest.Interface) *Clientset {
var cs Clientset var cs Clientset
cs.example = exampleinternalversion.New(c) cs.example = exampleinternalversion.New(c)
cs.secondExample = secondexampleinternalversion.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs return &cs

View File

@@ -25,6 +25,8 @@ import (
clientset "k8s.io/code-generator/_examples/apiserver/clientset/internalversion" clientset "k8s.io/code-generator/_examples/apiserver/clientset/internalversion"
exampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion" exampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion"
fakeexampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake" fakeexampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake"
secondexampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion"
fakesecondexampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake"
) )
// NewSimpleClientset returns a clientset that will respond with the provided objects. // NewSimpleClientset returns a clientset that will respond with the provided objects.
@@ -64,3 +66,8 @@ var _ clientset.Interface = &Clientset{}
func (c *Clientset) Example() exampleinternalversion.ExampleInterface { func (c *Clientset) Example() exampleinternalversion.ExampleInterface {
return &fakeexampleinternalversion.FakeExample{Fake: &c.Fake} return &fakeexampleinternalversion.FakeExample{Fake: &c.Fake}
} }
// SecondExample retrieves the SecondExampleClient
func (c *Clientset) SecondExample() secondexampleinternalversion.SecondExampleInterface {
return &fakesecondexampleinternalversion.FakeSecondExample{Fake: &c.Fake}
}

View File

@@ -22,6 +22,7 @@ import (
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer" serializer "k8s.io/apimachinery/pkg/runtime/serializer"
exampleinternalversion "k8s.io/code-generator/_examples/apiserver/apis/example" exampleinternalversion "k8s.io/code-generator/_examples/apiserver/apis/example"
secondexampleinternalversion "k8s.io/code-generator/_examples/apiserver/apis/example2"
) )
var scheme = runtime.NewScheme() var scheme = runtime.NewScheme()
@@ -49,5 +50,6 @@ func init() {
// correctly. // correctly.
func AddToScheme(scheme *runtime.Scheme) { func AddToScheme(scheme *runtime.Scheme) {
exampleinternalversion.AddToScheme(scheme) exampleinternalversion.AddToScheme(scheme)
secondexampleinternalversion.AddToScheme(scheme)
} }

View File

@@ -24,6 +24,7 @@ import (
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer" serializer "k8s.io/apimachinery/pkg/runtime/serializer"
example "k8s.io/code-generator/_examples/apiserver/apis/example/install" example "k8s.io/code-generator/_examples/apiserver/apis/example/install"
secondexample "k8s.io/code-generator/_examples/apiserver/apis/example2/install"
os "os" os "os"
) )
@@ -42,5 +43,6 @@ func init() {
// Install registers the API group and adds types to a scheme // Install registers the API group and adds types to a scheme
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
example.Install(groupFactoryRegistry, registry, scheme) example.Install(groupFactoryRegistry, registry, scheme)
secondexample.Install(groupFactoryRegistry, registry, scheme)
} }

View File

@@ -0,0 +1,18 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package has the automatically generated typed clients.
package internalversion

View File

@@ -0,0 +1,99 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package internalversion
import (
rest "k8s.io/client-go/rest"
"k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme"
)
type SecondExampleInterface interface {
RESTClient() rest.Interface
TestTypesGetter
}
// SecondExampleClient is used to interact with features provided by the example.test.apiserver.code-generator.k8s.io group.
type SecondExampleClient struct {
restClient rest.Interface
}
func (c *SecondExampleClient) TestTypes(namespace string) TestTypeInterface {
return newTestTypes(c, namespace)
}
// NewForConfig creates a new SecondExampleClient for the given config.
func NewForConfig(c *rest.Config) (*SecondExampleClient, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &SecondExampleClient{client}, nil
}
// NewForConfigOrDie creates a new SecondExampleClient for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *SecondExampleClient {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new SecondExampleClient for the given RESTClient.
func New(c rest.Interface) *SecondExampleClient {
return &SecondExampleClient{c}
}
func setConfigDefaults(config *rest.Config) error {
g, err := scheme.Registry.Group("example.test.apiserver.code-generator.k8s.io")
if err != nil {
return err
}
config.APIPath = "/apis"
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
if config.GroupVersion == nil || config.GroupVersion.Group != g.GroupVersion.Group {
gv := g.GroupVersion
config.GroupVersion = &gv
}
config.NegotiatedSerializer = scheme.Codecs
if config.QPS == 0 {
config.QPS = 5
}
if config.Burst == 0 {
config.Burst = 10
}
return nil
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *SecondExampleClient) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}

View File

@@ -0,0 +1,18 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package fake has the automatically generated clients.
package fake

View File

@@ -0,0 +1,38 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fake
import (
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion"
)
type FakeSecondExample struct {
*testing.Fake
}
func (c *FakeSecondExample) TestTypes(namespace string) internalversion.TestTypeInterface {
return &FakeTestTypes{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeSecondExample) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

View File

@@ -0,0 +1,138 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fake
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
example2 "k8s.io/code-generator/_examples/apiserver/apis/example2"
)
// FakeTestTypes implements TestTypeInterface
type FakeTestTypes struct {
Fake *FakeSecondExample
ns string
}
var testtypesResource = schema.GroupVersionResource{Group: "example.test.apiserver.code-generator.k8s.io", Version: "", Resource: "testtypes"}
var testtypesKind = schema.GroupVersionKind{Group: "example.test.apiserver.code-generator.k8s.io", Version: "", Kind: "TestType"}
// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any.
func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example2.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example2.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2.TestType), err
}
// List takes label and field selectors, and returns the list of TestTypes that match those selectors.
func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example2.TestTypeList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example2.TestTypeList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &example2.TestTypeList{}
for _, item := range obj.(*example2.TestTypeList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested testTypes.
func (c *FakeTestTypes) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts))
}
// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any.
func (c *FakeTestTypes) Create(testType *example2.TestType) (result *example2.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example2.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2.TestType), err
}
// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any.
func (c *FakeTestTypes) Update(testType *example2.TestType) (result *example2.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example2.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2.TestType), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeTestTypes) UpdateStatus(testType *example2.TestType) (*example2.TestType, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example2.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2.TestType), err
}
// Delete takes name of the testType and deletes it. Returns an error if one occurs.
func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &example2.TestType{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &example2.TestTypeList{})
return err
}
// Patch applies the patch and returns the patched testType.
func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example2.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example2.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2.TestType), err
}

View File

@@ -0,0 +1,19 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package internalversion
type TestTypeExpansion interface{}

View File

@@ -0,0 +1,172 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package internalversion
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
example2 "k8s.io/code-generator/_examples/apiserver/apis/example2"
scheme "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme"
)
// TestTypesGetter has a method to return a TestTypeInterface.
// A group's client should implement this interface.
type TestTypesGetter interface {
TestTypes(namespace string) TestTypeInterface
}
// TestTypeInterface has methods to work with TestType resources.
type TestTypeInterface interface {
Create(*example2.TestType) (*example2.TestType, error)
Update(*example2.TestType) (*example2.TestType, error)
UpdateStatus(*example2.TestType) (*example2.TestType, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string, options v1.GetOptions) (*example2.TestType, error)
List(opts v1.ListOptions) (*example2.TestTypeList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example2.TestType, err error)
TestTypeExpansion
}
// testTypes implements TestTypeInterface
type testTypes struct {
client rest.Interface
ns string
}
// newTestTypes returns a TestTypes
func newTestTypes(c *SecondExampleClient, namespace string) *testTypes {
return &testTypes{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any.
func (c *testTypes) Get(name string, options v1.GetOptions) (result *example2.TestType, err error) {
result = &example2.TestType{}
err = c.client.Get().
Namespace(c.ns).
Resource("testtypes").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of TestTypes that match those selectors.
func (c *testTypes) List(opts v1.ListOptions) (result *example2.TestTypeList, err error) {
result = &example2.TestTypeList{}
err = c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested testTypes.
func (c *testTypes) Watch(opts v1.ListOptions) (watch.Interface, error) {
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Watch()
}
// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any.
func (c *testTypes) Create(testType *example2.TestType) (result *example2.TestType, err error) {
result = &example2.TestType{}
err = c.client.Post().
Namespace(c.ns).
Resource("testtypes").
Body(testType).
Do().
Into(result)
return
}
// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any.
func (c *testTypes) Update(testType *example2.TestType) (result *example2.TestType, err error) {
result = &example2.TestType{}
err = c.client.Put().
Namespace(c.ns).
Resource("testtypes").
Name(testType.Name).
Body(testType).
Do().
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *testTypes) UpdateStatus(testType *example2.TestType) (result *example2.TestType, err error) {
result = &example2.TestType{}
err = c.client.Put().
Namespace(c.ns).
Resource("testtypes").
Name(testType.Name).
SubResource("status").
Body(testType).
Do().
Into(result)
return
}
// Delete takes name of the testType and deletes it. Returns an error if one occurs.
func (c *testTypes) Delete(name string, options *v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *testTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&listOptions, scheme.ParameterCodec).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched testType.
func (c *testTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example2.TestType, err error) {
result = &example2.TestType{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("testtypes").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

View File

@@ -22,6 +22,7 @@ import (
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol" flowcontrol "k8s.io/client-go/util/flowcontrol"
examplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1" examplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1"
secondexamplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1"
) )
type Interface interface { type Interface interface {
@@ -29,13 +30,17 @@ type Interface interface {
ExampleV1() examplev1.ExampleV1Interface ExampleV1() examplev1.ExampleV1Interface
// Deprecated: please explicitly pick a version if possible. // Deprecated: please explicitly pick a version if possible.
Example() examplev1.ExampleV1Interface Example() examplev1.ExampleV1Interface
SecondExampleV1() secondexamplev1.SecondExampleV1Interface
// Deprecated: please explicitly pick a version if possible.
SecondExample() secondexamplev1.SecondExampleV1Interface
} }
// Clientset contains the clients for groups. Each group has exactly one // Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset. // version included in a Clientset.
type Clientset struct { type Clientset struct {
*discovery.DiscoveryClient *discovery.DiscoveryClient
exampleV1 *examplev1.ExampleV1Client exampleV1 *examplev1.ExampleV1Client
secondExampleV1 *secondexamplev1.SecondExampleV1Client
} }
// ExampleV1 retrieves the ExampleV1Client // ExampleV1 retrieves the ExampleV1Client
@@ -49,6 +54,17 @@ func (c *Clientset) Example() examplev1.ExampleV1Interface {
return c.exampleV1 return c.exampleV1
} }
// SecondExampleV1 retrieves the SecondExampleV1Client
func (c *Clientset) SecondExampleV1() secondexamplev1.SecondExampleV1Interface {
return c.secondExampleV1
}
// Deprecated: SecondExample retrieves the default version of SecondExampleClient.
// Please explicitly pick a version.
func (c *Clientset) SecondExample() secondexamplev1.SecondExampleV1Interface {
return c.secondExampleV1
}
// Discovery retrieves the DiscoveryClient // Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface { func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil { if c == nil {
@@ -69,6 +85,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
cs.secondExampleV1, err = secondexamplev1.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil { if err != nil {
@@ -83,6 +103,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
func NewForConfigOrDie(c *rest.Config) *Clientset { func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset var cs Clientset
cs.exampleV1 = examplev1.NewForConfigOrDie(c) cs.exampleV1 = examplev1.NewForConfigOrDie(c)
cs.secondExampleV1 = secondexamplev1.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs return &cs
@@ -92,6 +113,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
func New(c rest.Interface) *Clientset { func New(c rest.Interface) *Clientset {
var cs Clientset var cs Clientset
cs.exampleV1 = examplev1.New(c) cs.exampleV1 = examplev1.New(c)
cs.secondExampleV1 = secondexamplev1.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs return &cs

View File

@@ -25,6 +25,8 @@ import (
clientset "k8s.io/code-generator/_examples/apiserver/clientset/versioned" clientset "k8s.io/code-generator/_examples/apiserver/clientset/versioned"
examplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1" examplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1"
fakeexamplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake" fakeexamplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake"
secondexamplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1"
fakesecondexamplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake"
) )
// NewSimpleClientset returns a clientset that will respond with the provided objects. // NewSimpleClientset returns a clientset that will respond with the provided objects.
@@ -69,3 +71,13 @@ func (c *Clientset) ExampleV1() examplev1.ExampleV1Interface {
func (c *Clientset) Example() examplev1.ExampleV1Interface { func (c *Clientset) Example() examplev1.ExampleV1Interface {
return &fakeexamplev1.FakeExampleV1{Fake: &c.Fake} return &fakeexamplev1.FakeExampleV1{Fake: &c.Fake}
} }
// SecondExampleV1 retrieves the SecondExampleV1Client
func (c *Clientset) SecondExampleV1() secondexamplev1.SecondExampleV1Interface {
return &fakesecondexamplev1.FakeSecondExampleV1{Fake: &c.Fake}
}
// SecondExample retrieves the SecondExampleV1Client
func (c *Clientset) SecondExample() secondexamplev1.SecondExampleV1Interface {
return &fakesecondexamplev1.FakeSecondExampleV1{Fake: &c.Fake}
}

View File

@@ -22,6 +22,7 @@ import (
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer" serializer "k8s.io/apimachinery/pkg/runtime/serializer"
examplev1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1" examplev1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1"
secondexamplev1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
) )
var scheme = runtime.NewScheme() var scheme = runtime.NewScheme()
@@ -49,5 +50,6 @@ func init() {
// correctly. // correctly.
func AddToScheme(scheme *runtime.Scheme) { func AddToScheme(scheme *runtime.Scheme) {
examplev1.AddToScheme(scheme) examplev1.AddToScheme(scheme)
secondexamplev1.AddToScheme(scheme)
} }

View File

@@ -22,6 +22,7 @@ import (
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer" serializer "k8s.io/apimachinery/pkg/runtime/serializer"
examplev1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1" examplev1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1"
secondexamplev1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
) )
var Scheme = runtime.NewScheme() var Scheme = runtime.NewScheme()
@@ -49,5 +50,6 @@ func init() {
// correctly. // correctly.
func AddToScheme(scheme *runtime.Scheme) { func AddToScheme(scheme *runtime.Scheme) {
examplev1.AddToScheme(scheme) examplev1.AddToScheme(scheme)
secondexamplev1.AddToScheme(scheme)
} }

View File

@@ -0,0 +1,18 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package has the automatically generated typed clients.
package v1

View File

@@ -0,0 +1,88 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1
import (
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
rest "k8s.io/client-go/rest"
v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
"k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme"
)
type SecondExampleV1Interface interface {
RESTClient() rest.Interface
TestTypesGetter
}
// SecondExampleV1Client is used to interact with features provided by the example.test.apiserver.code-generator.k8s.io group.
type SecondExampleV1Client struct {
restClient rest.Interface
}
func (c *SecondExampleV1Client) TestTypes(namespace string) TestTypeInterface {
return newTestTypes(c, namespace)
}
// NewForConfig creates a new SecondExampleV1Client for the given config.
func NewForConfig(c *rest.Config) (*SecondExampleV1Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &SecondExampleV1Client{client}, nil
}
// NewForConfigOrDie creates a new SecondExampleV1Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *SecondExampleV1Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new SecondExampleV1Client for the given RESTClient.
func New(c rest.Interface) *SecondExampleV1Client {
return &SecondExampleV1Client{c}
}
func setConfigDefaults(config *rest.Config) error {
gv := v1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
return nil
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *SecondExampleV1Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}

View File

@@ -0,0 +1,18 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package fake has the automatically generated clients.
package fake

View File

@@ -0,0 +1,38 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fake
import (
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
v1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1"
)
type FakeSecondExampleV1 struct {
*testing.Fake
}
func (c *FakeSecondExampleV1) TestTypes(namespace string) v1.TestTypeInterface {
return &FakeTestTypes{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeSecondExampleV1) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

View File

@@ -0,0 +1,138 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fake
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
example2_v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
)
// FakeTestTypes implements TestTypeInterface
type FakeTestTypes struct {
Fake *FakeSecondExampleV1
ns string
}
var testtypesResource = schema.GroupVersionResource{Group: "example.test.apiserver.code-generator.k8s.io", Version: "v1", Resource: "testtypes"}
var testtypesKind = schema.GroupVersionKind{Group: "example.test.apiserver.code-generator.k8s.io", Version: "v1", Kind: "TestType"}
// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any.
func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example2_v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example2_v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
}
// List takes label and field selectors, and returns the list of TestTypes that match those selectors.
func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example2_v1.TestTypeList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example2_v1.TestTypeList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &example2_v1.TestTypeList{}
for _, item := range obj.(*example2_v1.TestTypeList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested testTypes.
func (c *FakeTestTypes) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts))
}
// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any.
func (c *FakeTestTypes) Create(testType *example2_v1.TestType) (result *example2_v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example2_v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
}
// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any.
func (c *FakeTestTypes) Update(testType *example2_v1.TestType) (result *example2_v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example2_v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeTestTypes) UpdateStatus(testType *example2_v1.TestType) (*example2_v1.TestType, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example2_v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
}
// Delete takes name of the testType and deletes it. Returns an error if one occurs.
func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &example2_v1.TestType{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &example2_v1.TestTypeList{})
return err
}
// Patch applies the patch and returns the patched testType.
func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example2_v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example2_v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
}

View File

@@ -0,0 +1,19 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1
type TestTypeExpansion interface{}

View File

@@ -0,0 +1,172 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1
import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
scheme "k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme"
)
// TestTypesGetter has a method to return a TestTypeInterface.
// A group's client should implement this interface.
type TestTypesGetter interface {
TestTypes(namespace string) TestTypeInterface
}
// TestTypeInterface has methods to work with TestType resources.
type TestTypeInterface interface {
Create(*v1.TestType) (*v1.TestType, error)
Update(*v1.TestType) (*v1.TestType, error)
UpdateStatus(*v1.TestType) (*v1.TestType, error)
Delete(name string, options *meta_v1.DeleteOptions) error
DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error
Get(name string, options meta_v1.GetOptions) (*v1.TestType, error)
List(opts meta_v1.ListOptions) (*v1.TestTypeList, error)
Watch(opts meta_v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error)
TestTypeExpansion
}
// testTypes implements TestTypeInterface
type testTypes struct {
client rest.Interface
ns string
}
// newTestTypes returns a TestTypes
func newTestTypes(c *SecondExampleV1Client, namespace string) *testTypes {
return &testTypes{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any.
func (c *testTypes) Get(name string, options meta_v1.GetOptions) (result *v1.TestType, err error) {
result = &v1.TestType{}
err = c.client.Get().
Namespace(c.ns).
Resource("testtypes").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of TestTypes that match those selectors.
func (c *testTypes) List(opts meta_v1.ListOptions) (result *v1.TestTypeList, err error) {
result = &v1.TestTypeList{}
err = c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested testTypes.
func (c *testTypes) Watch(opts meta_v1.ListOptions) (watch.Interface, error) {
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Watch()
}
// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any.
func (c *testTypes) Create(testType *v1.TestType) (result *v1.TestType, err error) {
result = &v1.TestType{}
err = c.client.Post().
Namespace(c.ns).
Resource("testtypes").
Body(testType).
Do().
Into(result)
return
}
// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any.
func (c *testTypes) Update(testType *v1.TestType) (result *v1.TestType, err error) {
result = &v1.TestType{}
err = c.client.Put().
Namespace(c.ns).
Resource("testtypes").
Name(testType.Name).
Body(testType).
Do().
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *testTypes) UpdateStatus(testType *v1.TestType) (result *v1.TestType, err error) {
result = &v1.TestType{}
err = c.client.Put().
Namespace(c.ns).
Resource("testtypes").
Name(testType.Name).
SubResource("status").
Body(testType).
Do().
Into(result)
return
}
// Delete takes name of the testType and deletes it. Returns an error if one occurs.
func (c *testTypes) Delete(name string, options *meta_v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *testTypes) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&listOptions, scheme.ParameterCodec).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched testType.
func (c *testTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error) {
result = &v1.TestType{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("testtypes").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

View File

@@ -0,0 +1,46 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package example
import (
v1 "k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/v1"
internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces"
)
// Interface provides access to each of this group's versions.
type Interface interface {
// V1 provides access to shared informers for resources in V1.
V1() v1.Interface
}
type group struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// V1 returns a new v1.Interface.
func (g *group) V1() v1.Interface {
return v1.New(g.factory, g.namespace, g.tweakListOptions)
}

View File

@@ -0,0 +1,45 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package v1
import (
internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// TestTypes returns a TestTypeInformer.
TestTypes() TestTypeInformer
}
type version struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// TestTypes returns a TestTypeInformer.
func (v *version) TestTypes() TestTypeInformer {
return &testTypeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}

View File

@@ -0,0 +1,88 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package v1
import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
example2_v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
versioned "k8s.io/code-generator/_examples/apiserver/clientset/versioned"
internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces"
v1 "k8s.io/code-generator/_examples/apiserver/listers/example2/v1"
time "time"
)
// TestTypeInformer provides access to a shared informer and lister for
// TestTypes.
type TestTypeInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.TestTypeLister
}
type testTypeInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewTestTypeInformer constructs a new informer for TestType type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredTestTypeInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredTestTypeInformer constructs a new informer for TestType type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.SecondExampleV1().TestTypes(namespace).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.SecondExampleV1().TestTypes(namespace).Watch(options)
},
},
&example2_v1.TestType{},
resyncPeriod,
indexers,
)
}
func (f *testTypeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredTestTypeInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *testTypeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&example2_v1.TestType{}, f.defaultInformer)
}
func (f *testTypeInformer) Lister() v1.TestTypeLister {
return v1.NewTestTypeLister(f.Informer().GetIndexer())
}

View File

@@ -25,6 +25,7 @@ import (
cache "k8s.io/client-go/tools/cache" cache "k8s.io/client-go/tools/cache"
versioned "k8s.io/code-generator/_examples/apiserver/clientset/versioned" versioned "k8s.io/code-generator/_examples/apiserver/clientset/versioned"
example "k8s.io/code-generator/_examples/apiserver/informers/externalversions/example" example "k8s.io/code-generator/_examples/apiserver/informers/externalversions/example"
example2 "k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2"
internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces" internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces"
reflect "reflect" reflect "reflect"
sync "sync" sync "sync"
@@ -123,8 +124,13 @@ type SharedInformerFactory interface {
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
Example() example.Interface Example() example.Interface
SecondExample() example2.Interface
} }
func (f *sharedInformerFactory) Example() example.Interface { func (f *sharedInformerFactory) Example() example.Interface {
return example.New(f, f.namespace, f.tweakListOptions) return example.New(f, f.namespace, f.tweakListOptions)
} }
func (f *sharedInformerFactory) SecondExample() example2.Interface {
return example2.New(f, f.namespace, f.tweakListOptions)
}

View File

@@ -23,6 +23,7 @@ import (
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache" cache "k8s.io/client-go/tools/cache"
v1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1" v1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1"
example2_v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
) )
// GenericInformer is type of SharedIndexInformer which will locate and delegate to other // GenericInformer is type of SharedIndexInformer which will locate and delegate to other
@@ -55,6 +56,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
case v1.SchemeGroupVersion.WithResource("testtypes"): case v1.SchemeGroupVersion.WithResource("testtypes"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Example().V1().TestTypes().Informer()}, nil return &genericInformer{resource: resource.GroupResource(), informer: f.Example().V1().TestTypes().Informer()}, nil
// Group=example.test.apiserver.code-generator.k8s.io, Version=v1
case example2_v1.SchemeGroupVersion.WithResource("testtypes"):
return &genericInformer{resource: resource.GroupResource(), informer: f.SecondExample().V1().TestTypes().Informer()}, nil
} }
return nil, fmt.Errorf("no informer found for %v", resource) return nil, fmt.Errorf("no informer found for %v", resource)

View File

@@ -0,0 +1,46 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package example
import (
internalversion "k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/internalversion"
internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces"
)
// Interface provides access to each of this group's versions.
type Interface interface {
// InternalVersion provides access to shared informers for resources in InternalVersion.
InternalVersion() internalversion.Interface
}
type group struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// InternalVersion returns a new internalversion.Interface.
func (g *group) InternalVersion() internalversion.Interface {
return internalversion.New(g.factory, g.namespace, g.tweakListOptions)
}

View File

@@ -0,0 +1,45 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package internalversion
import (
internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// TestTypes returns a TestTypeInformer.
TestTypes() TestTypeInformer
}
type version struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// TestTypes returns a TestTypeInformer.
func (v *version) TestTypes() TestTypeInformer {
return &testTypeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}

View File

@@ -0,0 +1,88 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package internalversion
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
example2 "k8s.io/code-generator/_examples/apiserver/apis/example2"
clientset_internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion"
internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces"
internalversion "k8s.io/code-generator/_examples/apiserver/listers/example2/internalversion"
time "time"
)
// TestTypeInformer provides access to a shared informer and lister for
// TestTypes.
type TestTypeInformer interface {
Informer() cache.SharedIndexInformer
Lister() internalversion.TestTypeLister
}
type testTypeInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewTestTypeInformer constructs a new informer for TestType type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewTestTypeInformer(client clientset_internalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredTestTypeInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredTestTypeInformer constructs a new informer for TestType type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredTestTypeInformer(client clientset_internalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.SecondExample().TestTypes(namespace).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.SecondExample().TestTypes(namespace).Watch(options)
},
},
&example2.TestType{},
resyncPeriod,
indexers,
)
}
func (f *testTypeInformer) defaultInformer(client clientset_internalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredTestTypeInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *testTypeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&example2.TestType{}, f.defaultInformer)
}
func (f *testTypeInformer) Lister() internalversion.TestTypeLister {
return internalversion.NewTestTypeLister(f.Informer().GetIndexer())
}

View File

@@ -25,6 +25,7 @@ import (
cache "k8s.io/client-go/tools/cache" cache "k8s.io/client-go/tools/cache"
internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion" internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion"
example "k8s.io/code-generator/_examples/apiserver/informers/internalversion/example" example "k8s.io/code-generator/_examples/apiserver/informers/internalversion/example"
example2 "k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2"
internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces" internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces"
reflect "reflect" reflect "reflect"
sync "sync" sync "sync"
@@ -123,8 +124,13 @@ type SharedInformerFactory interface {
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
Example() example.Interface Example() example.Interface
SecondExample() example2.Interface
} }
func (f *sharedInformerFactory) Example() example.Interface { func (f *sharedInformerFactory) Example() example.Interface {
return example.New(f, f.namespace, f.tweakListOptions) return example.New(f, f.namespace, f.tweakListOptions)
} }
func (f *sharedInformerFactory) SecondExample() example2.Interface {
return example2.New(f, f.namespace, f.tweakListOptions)
}

View File

@@ -23,6 +23,7 @@ import (
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache" cache "k8s.io/client-go/tools/cache"
example "k8s.io/code-generator/_examples/apiserver/apis/example" example "k8s.io/code-generator/_examples/apiserver/apis/example"
example2 "k8s.io/code-generator/_examples/apiserver/apis/example2"
) )
// GenericInformer is type of SharedIndexInformer which will locate and delegate to other // GenericInformer is type of SharedIndexInformer which will locate and delegate to other
@@ -55,6 +56,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
case example.SchemeGroupVersion.WithResource("testtypes"): case example.SchemeGroupVersion.WithResource("testtypes"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Example().InternalVersion().TestTypes().Informer()}, nil return &genericInformer{resource: resource.GroupResource(), informer: f.Example().InternalVersion().TestTypes().Informer()}, nil
// Group=example.test.apiserver.code-generator.k8s.io, Version=internalVersion
case example2.SchemeGroupVersion.WithResource("testtypes"):
return &genericInformer{resource: resource.GroupResource(), informer: f.SecondExample().InternalVersion().TestTypes().Informer()}, nil
} }
return nil, fmt.Errorf("no informer found for %v", resource) return nil, fmt.Errorf("no informer found for %v", resource)

View File

@@ -0,0 +1,27 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by lister-gen
package internalversion
// TestTypeListerExpansion allows custom methods to be added to
// TestTypeLister.
type TestTypeListerExpansion interface{}
// TestTypeNamespaceListerExpansion allows custom methods to be added to
// TestTypeNamespaceLister.
type TestTypeNamespaceListerExpansion interface{}

View File

@@ -0,0 +1,94 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by lister-gen
package internalversion
import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
example2 "k8s.io/code-generator/_examples/apiserver/apis/example2"
)
// TestTypeLister helps list TestTypes.
type TestTypeLister interface {
// List lists all TestTypes in the indexer.
List(selector labels.Selector) (ret []*example2.TestType, err error)
// TestTypes returns an object that can list and get TestTypes.
TestTypes(namespace string) TestTypeNamespaceLister
TestTypeListerExpansion
}
// testTypeLister implements the TestTypeLister interface.
type testTypeLister struct {
indexer cache.Indexer
}
// NewTestTypeLister returns a new TestTypeLister.
func NewTestTypeLister(indexer cache.Indexer) TestTypeLister {
return &testTypeLister{indexer: indexer}
}
// List lists all TestTypes in the indexer.
func (s *testTypeLister) List(selector labels.Selector) (ret []*example2.TestType, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*example2.TestType))
})
return ret, err
}
// TestTypes returns an object that can list and get TestTypes.
func (s *testTypeLister) TestTypes(namespace string) TestTypeNamespaceLister {
return testTypeNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// TestTypeNamespaceLister helps list and get TestTypes.
type TestTypeNamespaceLister interface {
// List lists all TestTypes in the indexer for a given namespace.
List(selector labels.Selector) (ret []*example2.TestType, err error)
// Get retrieves the TestType from the indexer for a given namespace and name.
Get(name string) (*example2.TestType, error)
TestTypeNamespaceListerExpansion
}
// testTypeNamespaceLister implements the TestTypeNamespaceLister
// interface.
type testTypeNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all TestTypes in the indexer for a given namespace.
func (s testTypeNamespaceLister) List(selector labels.Selector) (ret []*example2.TestType, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*example2.TestType))
})
return ret, err
}
// Get retrieves the TestType from the indexer for a given namespace and name.
func (s testTypeNamespaceLister) Get(name string) (*example2.TestType, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(example2.Resource("testtype"), name)
}
return obj.(*example2.TestType), nil
}

View File

@@ -0,0 +1,27 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by lister-gen
package v1
// TestTypeListerExpansion allows custom methods to be added to
// TestTypeLister.
type TestTypeListerExpansion interface{}
// TestTypeNamespaceListerExpansion allows custom methods to be added to
// TestTypeNamespaceLister.
type TestTypeNamespaceListerExpansion interface{}

View File

@@ -0,0 +1,94 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by lister-gen
package v1
import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
)
// TestTypeLister helps list TestTypes.
type TestTypeLister interface {
// List lists all TestTypes in the indexer.
List(selector labels.Selector) (ret []*v1.TestType, err error)
// TestTypes returns an object that can list and get TestTypes.
TestTypes(namespace string) TestTypeNamespaceLister
TestTypeListerExpansion
}
// testTypeLister implements the TestTypeLister interface.
type testTypeLister struct {
indexer cache.Indexer
}
// NewTestTypeLister returns a new TestTypeLister.
func NewTestTypeLister(indexer cache.Indexer) TestTypeLister {
return &testTypeLister{indexer: indexer}
}
// List lists all TestTypes in the indexer.
func (s *testTypeLister) List(selector labels.Selector) (ret []*v1.TestType, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1.TestType))
})
return ret, err
}
// TestTypes returns an object that can list and get TestTypes.
func (s *testTypeLister) TestTypes(namespace string) TestTypeNamespaceLister {
return testTypeNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// TestTypeNamespaceLister helps list and get TestTypes.
type TestTypeNamespaceLister interface {
// List lists all TestTypes in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v1.TestType, err error)
// Get retrieves the TestType from the indexer for a given namespace and name.
Get(name string) (*v1.TestType, error)
TestTypeNamespaceListerExpansion
}
// testTypeNamespaceLister implements the TestTypeNamespaceLister
// interface.
type testTypeNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all TestTypes in the indexer for a given namespace.
func (s testTypeNamespaceLister) List(selector labels.Selector) (ret []*v1.TestType, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1.TestType))
})
return ret, err
}
// Get retrieves the TestType from the indexer for a given namespace and name.
func (s testTypeNamespaceLister) Get(name string) (*v1.TestType, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1.Resource("testtype"), name)
}
return obj.(*v1.TestType), nil
}

View File

@@ -15,6 +15,6 @@ limitations under the License.
*/ */
// +k8s:deepcopy-gen=package // +k8s:deepcopy-gen=package
// +groupName=example.test2.crd.code-generator.k8s.io // +groupName=example.test.crd.code-generator.k8s.io
// +groupGoName=SecondExample // +groupGoName=SecondExample
package v1 package v1

View File

@@ -22,7 +22,7 @@ import (
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol" flowcontrol "k8s.io/client-go/util/flowcontrol"
examplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1" examplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1"
example2v1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1" secondexamplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1"
) )
type Interface interface { type Interface interface {
@@ -30,9 +30,9 @@ type Interface interface {
ExampleV1() examplev1.ExampleV1Interface ExampleV1() examplev1.ExampleV1Interface
// Deprecated: please explicitly pick a version if possible. // Deprecated: please explicitly pick a version if possible.
Example() examplev1.ExampleV1Interface Example() examplev1.ExampleV1Interface
SecondExampleV1() example2v1.SecondExampleV1Interface SecondExampleV1() secondexamplev1.SecondExampleV1Interface
// Deprecated: please explicitly pick a version if possible. // Deprecated: please explicitly pick a version if possible.
SecondExample() example2v1.SecondExampleV1Interface SecondExample() secondexamplev1.SecondExampleV1Interface
} }
// Clientset contains the clients for groups. Each group has exactly one // Clientset contains the clients for groups. Each group has exactly one
@@ -40,7 +40,7 @@ type Interface interface {
type Clientset struct { type Clientset struct {
*discovery.DiscoveryClient *discovery.DiscoveryClient
exampleV1 *examplev1.ExampleV1Client exampleV1 *examplev1.ExampleV1Client
secondExampleV1 *example2v1.SecondExampleV1Client secondExampleV1 *secondexamplev1.SecondExampleV1Client
} }
// ExampleV1 retrieves the ExampleV1Client // ExampleV1 retrieves the ExampleV1Client
@@ -55,13 +55,13 @@ func (c *Clientset) Example() examplev1.ExampleV1Interface {
} }
// SecondExampleV1 retrieves the SecondExampleV1Client // SecondExampleV1 retrieves the SecondExampleV1Client
func (c *Clientset) SecondExampleV1() example2v1.SecondExampleV1Interface { func (c *Clientset) SecondExampleV1() secondexamplev1.SecondExampleV1Interface {
return c.secondExampleV1 return c.secondExampleV1
} }
// Deprecated: SecondExample retrieves the default version of SecondExampleClient. // Deprecated: SecondExample retrieves the default version of SecondExampleClient.
// Please explicitly pick a version. // Please explicitly pick a version.
func (c *Clientset) SecondExample() example2v1.SecondExampleV1Interface { func (c *Clientset) SecondExample() secondexamplev1.SecondExampleV1Interface {
return c.secondExampleV1 return c.secondExampleV1
} }
@@ -85,7 +85,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
cs.secondExampleV1, err = example2v1.NewForConfig(&configShallowCopy) cs.secondExampleV1, err = secondexamplev1.NewForConfig(&configShallowCopy)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -103,7 +103,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
func NewForConfigOrDie(c *rest.Config) *Clientset { func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset var cs Clientset
cs.exampleV1 = examplev1.NewForConfigOrDie(c) cs.exampleV1 = examplev1.NewForConfigOrDie(c)
cs.secondExampleV1 = example2v1.NewForConfigOrDie(c) cs.secondExampleV1 = secondexamplev1.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs return &cs
@@ -113,7 +113,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
func New(c rest.Interface) *Clientset { func New(c rest.Interface) *Clientset {
var cs Clientset var cs Clientset
cs.exampleV1 = examplev1.New(c) cs.exampleV1 = examplev1.New(c)
cs.secondExampleV1 = example2v1.New(c) cs.secondExampleV1 = secondexamplev1.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs return &cs

View File

@@ -25,8 +25,8 @@ import (
clientset "k8s.io/code-generator/_examples/crd/clientset/versioned" clientset "k8s.io/code-generator/_examples/crd/clientset/versioned"
examplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1" examplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1"
fakeexamplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake" fakeexamplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake"
example2v1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1" secondexamplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1"
fakeexample2v1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake" fakesecondexamplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake"
) )
// NewSimpleClientset returns a clientset that will respond with the provided objects. // NewSimpleClientset returns a clientset that will respond with the provided objects.
@@ -73,11 +73,11 @@ func (c *Clientset) Example() examplev1.ExampleV1Interface {
} }
// SecondExampleV1 retrieves the SecondExampleV1Client // SecondExampleV1 retrieves the SecondExampleV1Client
func (c *Clientset) SecondExampleV1() example2v1.SecondExampleV1Interface { func (c *Clientset) SecondExampleV1() secondexamplev1.SecondExampleV1Interface {
return &fakeexample2v1.FakeSecondExampleV1{Fake: &c.Fake} return &fakesecondexamplev1.FakeSecondExampleV1{Fake: &c.Fake}
} }
// SecondExample retrieves the SecondExampleV1Client // SecondExample retrieves the SecondExampleV1Client
func (c *Clientset) SecondExample() example2v1.SecondExampleV1Interface { func (c *Clientset) SecondExample() secondexamplev1.SecondExampleV1Interface {
return &fakeexample2v1.FakeSecondExampleV1{Fake: &c.Fake} return &fakesecondexamplev1.FakeSecondExampleV1{Fake: &c.Fake}
} }

View File

@@ -22,7 +22,7 @@ import (
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer" serializer "k8s.io/apimachinery/pkg/runtime/serializer"
examplev1 "k8s.io/code-generator/_examples/crd/apis/example/v1" examplev1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
example2v1 "k8s.io/code-generator/_examples/crd/apis/example2/v1" secondexamplev1 "k8s.io/code-generator/_examples/crd/apis/example2/v1"
) )
var scheme = runtime.NewScheme() var scheme = runtime.NewScheme()
@@ -50,6 +50,6 @@ func init() {
// correctly. // correctly.
func AddToScheme(scheme *runtime.Scheme) { func AddToScheme(scheme *runtime.Scheme) {
examplev1.AddToScheme(scheme) examplev1.AddToScheme(scheme)
example2v1.AddToScheme(scheme) secondexamplev1.AddToScheme(scheme)
} }

View File

@@ -22,7 +22,7 @@ import (
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer" serializer "k8s.io/apimachinery/pkg/runtime/serializer"
examplev1 "k8s.io/code-generator/_examples/crd/apis/example/v1" examplev1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
example2v1 "k8s.io/code-generator/_examples/crd/apis/example2/v1" secondexamplev1 "k8s.io/code-generator/_examples/crd/apis/example2/v1"
) )
var Scheme = runtime.NewScheme() var Scheme = runtime.NewScheme()
@@ -50,6 +50,6 @@ func init() {
// correctly. // correctly.
func AddToScheme(scheme *runtime.Scheme) { func AddToScheme(scheme *runtime.Scheme) {
examplev1.AddToScheme(scheme) examplev1.AddToScheme(scheme)
example2v1.AddToScheme(scheme) secondexamplev1.AddToScheme(scheme)
} }

View File

@@ -28,7 +28,7 @@ type SecondExampleV1Interface interface {
TestTypesGetter TestTypesGetter
} }
// SecondExampleV1Client is used to interact with features provided by the example.test2.crd.code-generator.k8s.io group. // SecondExampleV1Client is used to interact with features provided by the example.test.crd.code-generator.k8s.io group.
type SecondExampleV1Client struct { type SecondExampleV1Client struct {
restClient rest.Interface restClient rest.Interface
} }

View File

@@ -32,9 +32,9 @@ type FakeTestTypes struct {
ns string ns string
} }
var testtypesResource = schema.GroupVersionResource{Group: "example.test2.crd.code-generator.k8s.io", Version: "v1", Resource: "testtypes"} var testtypesResource = schema.GroupVersionResource{Group: "example.test.crd.code-generator.k8s.io", Version: "v1", Resource: "testtypes"}
var testtypesKind = schema.GroupVersionKind{Group: "example.test2.crd.code-generator.k8s.io", Version: "v1", Kind: "TestType"} var testtypesKind = schema.GroupVersionKind{Group: "example.test.crd.code-generator.k8s.io", Version: "v1", Kind: "TestType"}
// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. // Get takes name of the testType, and returns the corresponding testType object, and an error if there is any.
func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example2_v1.TestType, err error) { func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example2_v1.TestType, err error) {

View File

@@ -16,7 +16,7 @@ limitations under the License.
// This file was automatically generated by informer-gen // This file was automatically generated by informer-gen
package example2 package example
import ( import (
v1 "k8s.io/code-generator/_examples/crd/informers/externalversions/example2/v1" v1 "k8s.io/code-generator/_examples/crd/informers/externalversions/example2/v1"

View File

@@ -56,7 +56,7 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
case v1.SchemeGroupVersion.WithResource("testtypes"): case v1.SchemeGroupVersion.WithResource("testtypes"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Example().V1().TestTypes().Informer()}, nil return &genericInformer{resource: resource.GroupResource(), informer: f.Example().V1().TestTypes().Informer()}, nil
// Group=example.test2.crd.code-generator.k8s.io, Version=v1 // Group=example.test.crd.code-generator.k8s.io, Version=v1
case example2_v1.SchemeGroupVersion.WithResource("testtypes"): case example2_v1.SchemeGroupVersion.WithResource("testtypes"):
return &genericInformer{resource: resource.GroupResource(), informer: f.SecondExample().V1().TestTypes().Informer()}, nil return &genericInformer{resource: resource.GroupResource(), informer: f.SecondExample().V1().TestTypes().Informer()}, nil

View File

@@ -199,7 +199,7 @@ func packageForClientset(customArgs *clientgenargs.CustomArgs, clientsetPackage
} }
} }
func packageForScheme(customArgs *clientgenargs.CustomArgs, clientsetPackage string, srcTreePath string, boilerplate []byte) generator.Package { func packageForScheme(customArgs *clientgenargs.CustomArgs, clientsetPackage string, srcTreePath string, groupGoNames map[clientgentypes.GroupVersion]string, boilerplate []byte) generator.Package {
schemePackage := filepath.Join(clientsetPackage, "scheme") schemePackage := filepath.Join(clientsetPackage, "scheme")
// create runtime.Registry for internal client because it has to know about group versions // create runtime.Registry for internal client because it has to know about group versions
@@ -236,6 +236,7 @@ NextGroup:
OutputPackage: schemePackage, OutputPackage: schemePackage,
OutputPath: filepath.Join(srcTreePath, schemePackage), OutputPath: filepath.Join(srcTreePath, schemePackage),
Groups: customArgs.Groups, Groups: customArgs.Groups,
GroupGoNames: groupGoNames,
ImportTracker: generator.NewImportTracker(), ImportTracker: generator.NewImportTracker(),
CreateRegistry: internalClient, CreateRegistry: internalClient,
}, },
@@ -274,7 +275,7 @@ func applyGroupOverrides(universe types.Universe, customArgs *clientgenargs.Cust
if newGV, ok := changes[gv]; ok { if newGV, ok := changes[gv]; ok {
// There's an override, so use it. // There's an override, so use it.
newGVS := clientgentypes.GroupVersions{ newGVS := clientgentypes.GroupVersions{
PackageName: gv.Group.NonEmpty(), PackageName: gvs.PackageName,
Group: newGV.Group, Group: newGV.Group,
Versions: gvs.Versions, Versions: gvs.Versions,
} }
@@ -360,7 +361,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
clientsetPackage := filepath.Join(customArgs.ClientsetOutputPath, customArgs.ClientsetName) clientsetPackage := filepath.Join(customArgs.ClientsetOutputPath, customArgs.ClientsetName)
packageList = append(packageList, packageForClientset(customArgs, clientsetPackage, groupGoNames, boilerplate)) packageList = append(packageList, packageForClientset(customArgs, clientsetPackage, groupGoNames, boilerplate))
packageList = append(packageList, packageForScheme(customArgs, clientsetPackage, arguments.OutputBase, boilerplate)) packageList = append(packageList, packageForScheme(customArgs, clientsetPackage, arguments.OutputBase, groupGoNames, boilerplate))
if customArgs.FakeClient { if customArgs.FakeClient {
packageList = append(packageList, fake.PackageForClientset(customArgs, clientsetPackage, groupGoNames, boilerplate)) packageList = append(packageList, fake.PackageForClientset(customArgs, clientsetPackage, groupGoNames, boilerplate))
} }

View File

@@ -119,6 +119,7 @@ func PackageForClientset(customArgs *clientgenargs.CustomArgs, fakeClientsetPack
InputPackages: customArgs.GroupVersionToInputPath, InputPackages: customArgs.GroupVersionToInputPath,
OutputPackage: fakeClientsetPackage, OutputPackage: fakeClientsetPackage,
Groups: customArgs.Groups, Groups: customArgs.Groups,
GroupGoNames: groupGoNames,
ImportTracker: generator.NewImportTracker(), ImportTracker: generator.NewImportTracker(),
PrivateScheme: true, PrivateScheme: true,
}, },

View File

@@ -63,8 +63,9 @@ func (g *genClientset) Imports(c *generator.Context) (imports []string) {
groupClientPackage := filepath.Join(g.fakeClientsetPackage, "typed", group.PackageName, version.NonEmpty()) groupClientPackage := filepath.Join(g.fakeClientsetPackage, "typed", group.PackageName, version.NonEmpty())
fakeGroupClientPackage := filepath.Join(groupClientPackage, "fake") fakeGroupClientPackage := filepath.Join(groupClientPackage, "fake")
imports = append(imports, strings.ToLower(fmt.Sprintf("%s%s \"%s\"", group.PackageName, version.NonEmpty(), groupClientPackage))) groupAlias := strings.ToLower(g.groupGoNames[clientgentypes.GroupVersion{group.Group, version}])
imports = append(imports, strings.ToLower(fmt.Sprintf("fake%s%s \"%s\"", group.PackageName, version.NonEmpty(), fakeGroupClientPackage))) imports = append(imports, strings.ToLower(fmt.Sprintf("%s%s \"%s\"", groupAlias, version.NonEmpty(), groupClientPackage)))
imports = append(imports, strings.ToLower(fmt.Sprintf("fake%s%s \"%s\"", groupAlias, version.NonEmpty(), fakeGroupClientPackage)))
} }
} }
// the package that has the clientset Interface // the package that has the clientset Interface
@@ -93,11 +94,11 @@ func (g *genClientset) GenerateType(c *generator.Context, t *types.Type, w io.Wr
for _, group := range allGroups { for _, group := range allGroups {
m := map[string]interface{}{ m := map[string]interface{}{
"group": group.Group, "group": group.Group,
"version": group.Version, "version": group.Version,
"PackageName": group.PackageName, "PackageAlias": group.PackageAlias,
"GroupGoName": group.GroupGoName, "GroupGoName": group.GroupGoName,
"Version": namer.IC(group.Version.String()), "Version": namer.IC(group.Version.String()),
} }
sw.Do(clientsetInterfaceImplTemplate, m) sw.Do(clientsetInterfaceImplTemplate, m)
@@ -150,14 +151,14 @@ var _ clientset.Interface = &Clientset{}
var clientsetInterfaceImplTemplate = ` var clientsetInterfaceImplTemplate = `
// $.GroupGoName$$.Version$ retrieves the $.GroupGoName$$.Version$Client // $.GroupGoName$$.Version$ retrieves the $.GroupGoName$$.Version$Client
func (c *Clientset) $.GroupGoName$$.Version$() $.PackageName$.$.GroupGoName$$.Version$Interface { func (c *Clientset) $.GroupGoName$$.Version$() $.PackageAlias$.$.GroupGoName$$.Version$Interface {
return &fake$.PackageName$.Fake$.GroupGoName$$.Version${Fake: &c.Fake} return &fake$.PackageAlias$.Fake$.GroupGoName$$.Version${Fake: &c.Fake}
} }
` `
var clientsetInterfaceDefaultVersionImpl = ` var clientsetInterfaceDefaultVersionImpl = `
// $.GroupGoName$ retrieves the $.GroupGoName$$.Version$Client // $.GroupGoName$ retrieves the $.GroupGoName$$.Version$Client
func (c *Clientset) $.GroupGoName$() $.PackageName$.$.GroupGoName$$.Version$Interface { func (c *Clientset) $.GroupGoName$() $.PackageAlias$.$.GroupGoName$$.Version$Interface {
return &fake$.PackageName$.Fake$.GroupGoName$$.Version${Fake: &c.Fake} return &fake$.PackageAlias$.Fake$.GroupGoName$$.Version${Fake: &c.Fake}
} }
` `

View File

@@ -59,7 +59,8 @@ func (g *genClientset) Imports(c *generator.Context) (imports []string) {
for _, group := range g.groups { for _, group := range g.groups {
for _, version := range group.Versions { for _, version := range group.Versions {
typedClientPath := filepath.Join(g.clientsetPackage, "typed", group.PackageName, version.NonEmpty()) typedClientPath := filepath.Join(g.clientsetPackage, "typed", group.PackageName, version.NonEmpty())
imports = append(imports, strings.ToLower(fmt.Sprintf("%s%s \"%s\"", group.PackageName, version.NonEmpty(), typedClientPath))) groupAlias := strings.ToLower(g.groupGoNames[clientgentypes.GroupVersion{group.Group, version}])
imports = append(imports, strings.ToLower(fmt.Sprintf("%s%s \"%s\"", groupAlias, version.NonEmpty(), typedClientPath)))
} }
} }
return return
@@ -104,9 +105,9 @@ func (g *genClientset) GenerateType(c *generator.Context, t *types.Type, w io.Wr
var clientsetInterface = ` var clientsetInterface = `
type Interface interface { type Interface interface {
Discovery() $.DiscoveryInterface|raw$ Discovery() $.DiscoveryInterface|raw$
$range .allGroups$$.GroupGoName$$.Version$() $.PackageName$.$.GroupGoName$$.Version$Interface $range .allGroups$$.GroupGoName$$.Version$() $.PackageAlias$.$.GroupGoName$$.Version$Interface
$if .IsDefaultVersion$// Deprecated: please explicitly pick a version if possible. $if .IsDefaultVersion$// Deprecated: please explicitly pick a version if possible.
$.GroupGoName$() $.PackageName$.$.GroupGoName$$.Version$Interface $.GroupGoName$() $.PackageAlias$.$.GroupGoName$$.Version$Interface
$end$$end$ $end$$end$
} }
` `
@@ -116,14 +117,14 @@ var clientsetTemplate = `
// version included in a Clientset. // version included in a Clientset.
type Clientset struct { type Clientset struct {
*$.DiscoveryClient|raw$ *$.DiscoveryClient|raw$
$range .allGroups$$.LowerCaseGroupGoName$$.Version$ *$.PackageName$.$.GroupGoName$$.Version$Client $range .allGroups$$.LowerCaseGroupGoName$$.Version$ *$.PackageAlias$.$.GroupGoName$$.Version$Client
$end$ $end$
} }
` `
var clientsetInterfaceImplTemplate = ` var clientsetInterfaceImplTemplate = `
// $.GroupGoName$$.Version$ retrieves the $.GroupGoName$$.Version$Client // $.GroupGoName$$.Version$ retrieves the $.GroupGoName$$.Version$Client
func (c *Clientset) $.GroupGoName$$.Version$() $.PackageName$.$.GroupGoName$$.Version$Interface { func (c *Clientset) $.GroupGoName$$.Version$() $.PackageAlias$.$.GroupGoName$$.Version$Interface {
return c.$.LowerCaseGroupGoName$$.Version$ return c.$.LowerCaseGroupGoName$$.Version$
} }
` `
@@ -131,7 +132,7 @@ func (c *Clientset) $.GroupGoName$$.Version$() $.PackageName$.$.GroupGoName$$.Ve
var clientsetInterfaceDefaultVersionImpl = ` var clientsetInterfaceDefaultVersionImpl = `
// Deprecated: $.GroupGoName$ retrieves the default version of $.GroupGoName$Client. // Deprecated: $.GroupGoName$ retrieves the default version of $.GroupGoName$Client.
// Please explicitly pick a version. // Please explicitly pick a version.
func (c *Clientset) $.GroupGoName$() $.PackageName$.$.GroupGoName$$.Version$Interface { func (c *Clientset) $.GroupGoName$() $.PackageAlias$.$.GroupGoName$$.Version$Interface {
return c.$.LowerCaseGroupGoName$$.Version$ return c.$.LowerCaseGroupGoName$$.Version$
} }
` `
@@ -155,7 +156,7 @@ func NewForConfig(c *$.Config|raw$) (*Clientset, error) {
} }
var cs Clientset var cs Clientset
var err error var err error
$range .allGroups$ cs.$.LowerCaseGroupGoName$$.Version$, err =$.PackageName$.NewForConfig(&configShallowCopy) $range .allGroups$ cs.$.LowerCaseGroupGoName$$.Version$, err =$.PackageAlias$.NewForConfig(&configShallowCopy)
if err!=nil { if err!=nil {
return nil, err return nil, err
} }
@@ -174,7 +175,7 @@ var newClientsetForConfigOrDieTemplate = `
// panics if there is an error in the config. // panics if there is an error in the config.
func NewForConfigOrDie(c *$.Config|raw$) *Clientset { func NewForConfigOrDie(c *$.Config|raw$) *Clientset {
var cs Clientset var cs Clientset
$range .allGroups$ cs.$.LowerCaseGroupGoName$$.Version$ =$.PackageName$.NewForConfigOrDie(c) $range .allGroups$ cs.$.LowerCaseGroupGoName$$.Version$ =$.PackageAlias$.NewForConfigOrDie(c)
$end$ $end$
cs.DiscoveryClient = $.NewDiscoveryClientForConfigOrDie|raw$(c) cs.DiscoveryClient = $.NewDiscoveryClientForConfigOrDie|raw$(c)
return &cs return &cs
@@ -185,7 +186,7 @@ var newClientsetForRESTClientTemplate = `
// New creates a new Clientset for the given RESTClient. // New creates a new Clientset for the given RESTClient.
func New(c $.RESTClientInterface|raw$) *Clientset { func New(c $.RESTClientInterface|raw$) *Clientset {
var cs Clientset var cs Clientset
$range .allGroups$ cs.$.LowerCaseGroupGoName$$.Version$ =$.PackageName$.New(c) $range .allGroups$ cs.$.LowerCaseGroupGoName$$.Version$ =$.PackageAlias$.New(c)
$end$ $end$
cs.DiscoveryClient = $.NewDiscoveryClient|raw$(c) cs.DiscoveryClient = $.NewDiscoveryClient|raw$(c)
return &cs return &cs

View File

@@ -35,6 +35,7 @@ type GenScheme struct {
generator.DefaultGen generator.DefaultGen
OutputPackage string OutputPackage string
Groups []clientgentypes.GroupVersions Groups []clientgentypes.GroupVersions
GroupGoNames map[clientgentypes.GroupVersion]string
InputPackages map[clientgentypes.GroupVersion]string InputPackages map[clientgentypes.GroupVersion]string
OutputPath string OutputPath string
ImportTracker namer.ImportTracker ImportTracker namer.ImportTracker
@@ -61,16 +62,17 @@ func (g *GenScheme) Imports(c *generator.Context) (imports []string) {
for _, group := range g.Groups { for _, group := range g.Groups {
for _, version := range group.Versions { for _, version := range group.Versions {
packagePath := g.InputPackages[clientgentypes.GroupVersion{Group: group.Group, Version: version}] packagePath := g.InputPackages[clientgentypes.GroupVersion{Group: group.Group, Version: version}]
groupAlias := strings.ToLower(g.GroupGoNames[clientgentypes.GroupVersion{group.Group, version}])
if g.CreateRegistry { if g.CreateRegistry {
// import the install package for internal clientsets instead of the type package with register.go // import the install package for internal clientsets instead of the type package with register.go
if version != "" { if version != "" {
packagePath = filepath.Dir(packagePath) packagePath = filepath.Dir(packagePath)
} }
packagePath = filepath.Join(packagePath, "install") packagePath = filepath.Join(packagePath, "install")
imports = append(imports, strings.ToLower(fmt.Sprintf("%s \"%s\"", group.PackageName, path.Vendorless(packagePath)))) imports = append(imports, strings.ToLower(fmt.Sprintf("%s \"%s\"", groupAlias, path.Vendorless(packagePath))))
break break
} else { } else {
imports = append(imports, strings.ToLower(fmt.Sprintf("%s%s \"%s\"", group.PackageName, version.NonEmpty(), path.Vendorless(packagePath)))) imports = append(imports, strings.ToLower(fmt.Sprintf("%s%s \"%s\"", groupAlias, version.NonEmpty(), path.Vendorless(packagePath))))
} }
} }
} }
@@ -80,8 +82,8 @@ func (g *GenScheme) Imports(c *generator.Context) (imports []string) {
func (g *GenScheme) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error { func (g *GenScheme) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error {
sw := generator.NewSnippetWriter(w, c, "$", "$") sw := generator.NewSnippetWriter(w, c, "$", "$")
allGroupVersions := clientgentypes.ToGroupVersionPackages(g.Groups, nil) allGroupVersions := clientgentypes.ToGroupVersionPackages(g.Groups, g.GroupGoNames)
allInstallGroups := clientgentypes.ToGroupInstallPackages(g.Groups) allInstallGroups := clientgentypes.ToGroupInstallPackages(g.Groups, g.GroupGoNames)
m := map[string]interface{}{ m := map[string]interface{}{
"allGroupVersions": allGroupVersions, "allGroupVersions": allGroupVersions,
@@ -147,7 +149,7 @@ func init() {
// Install registers the API group and adds types to a scheme // Install registers the API group and adds types to a scheme
func Install(groupFactoryRegistry $.announcedAPIGroupFactoryRegistry|raw$, registry *$.registeredAPIRegistrationManager|raw$, scheme *$.runtimeScheme|raw$) { func Install(groupFactoryRegistry $.announcedAPIGroupFactoryRegistry|raw$, registry *$.registeredAPIRegistrationManager|raw$, scheme *$.runtimeScheme|raw$) {
$range .allInstallGroups$ $.InstallPackageName$.Install(groupFactoryRegistry, registry, scheme) $range .allInstallGroups$ $.InstallPackageAlias$.Install(groupFactoryRegistry, registry, scheme)
$end$ $end$
$if .customRegister$ExtraInstall(groupFactoryRegistry, registry, scheme)$end$ $if .customRegister$ExtraInstall(groupFactoryRegistry, registry, scheme)$end$
} }
@@ -176,7 +178,7 @@ func init() {
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly. // correctly.
func AddToScheme(scheme *$.runtimeScheme|raw$) { func AddToScheme(scheme *$.runtimeScheme|raw$) {
$range .allGroupVersions$ $.PackageName$.AddToScheme(scheme) $range .allGroupVersions$ $.PackageAlias$.AddToScheme(scheme)
$end$ $end$
$if .customRegister$ExtraAddToScheme(scheme)$end$ $if .customRegister$ExtraAddToScheme(scheme)$end$
} }

View File

@@ -94,7 +94,7 @@ func ToGroupVersionPackages(groups []GroupVersions, groupGoNames map[GroupVersio
groupVersionPackages = append(groupVersionPackages, GroupVersionPackage{ groupVersionPackages = append(groupVersionPackages, GroupVersionPackage{
Group: Group(namer.IC(group.Group.NonEmpty())), Group: Group(namer.IC(group.Group.NonEmpty())),
Version: Version(namer.IC(version.String())), Version: Version(namer.IC(version.String())),
PackageName: strings.ToLower(group.PackageName + version.NonEmpty()), PackageAlias: strings.ToLower(groupGoName + version.NonEmpty()),
IsDefaultVersion: version == defaultVersion && version != "", IsDefaultVersion: version == defaultVersion && version != "",
GroupGoName: groupGoName, GroupGoName: groupGoName,
LowerCaseGroupGoName: namer.IL(groupGoName), LowerCaseGroupGoName: namer.IL(groupGoName),
@@ -104,12 +104,14 @@ func ToGroupVersionPackages(groups []GroupVersions, groupGoNames map[GroupVersio
return groupVersionPackages return groupVersionPackages
} }
func ToGroupInstallPackages(groups []GroupVersions) []GroupInstallPackage { func ToGroupInstallPackages(groups []GroupVersions, groupGoNames map[GroupVersion]string) []GroupInstallPackage {
var groupInstallPackages []GroupInstallPackage var groupInstallPackages []GroupInstallPackage
for _, group := range groups { for _, group := range groups {
defaultVersion := defaultVersion(group.Versions)
groupGoName := groupGoNames[GroupVersion{Group: group.Group, Version: defaultVersion}]
groupInstallPackages = append(groupInstallPackages, GroupInstallPackage{ groupInstallPackages = append(groupInstallPackages, GroupInstallPackage{
Group: Group(namer.IC(group.Group.NonEmpty())), Group: Group(namer.IC(group.Group.NonEmpty())),
InstallPackageName: group.PackageName, InstallPackageAlias: strings.ToLower(groupGoName),
}) })
} }
return groupInstallPackages return groupInstallPackages

View File

@@ -61,12 +61,12 @@ type GroupVersionPackage struct {
// If a user calls a group client without specifying the version (e.g., // If a user calls a group client without specifying the version (e.g.,
// c.Core(), instead of c.CoreV1()), the default version will be returned. // c.Core(), instead of c.CoreV1()), the default version will be returned.
IsDefaultVersion bool IsDefaultVersion bool
PackageName string PackageAlias string
GroupGoName string GroupGoName string
LowerCaseGroupGoName string LowerCaseGroupGoName string
} }
type GroupInstallPackage struct { type GroupInstallPackage struct {
Group Group Group Group
InstallPackageName string InstallPackageAlias string
} }

View File

@@ -195,7 +195,8 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
groupVersionsEntry, ok := targetGroupVersions[groupPkgName] groupVersionsEntry, ok := targetGroupVersions[groupPkgName]
if !ok { if !ok {
groupVersionsEntry = clientgentypes.GroupVersions{ groupVersionsEntry = clientgentypes.GroupVersions{
Group: gv.Group, PackageName: groupPkgName,
Group: gv.Group,
} }
} }
groupVersionsEntry.Versions = append(groupVersionsEntry.Versions, gv.Version) groupVersionsEntry.Versions = append(groupVersionsEntry.Versions, gv.Version)
@@ -214,16 +215,16 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
if len(externalGroupVersions) != 0 { if len(externalGroupVersions) != 0 {
packageList = append(packageList, factoryInterfacePackage(externalVersionPackagePath, boilerplate, customArgs.VersionedClientSetPackage)) packageList = append(packageList, factoryInterfacePackage(externalVersionPackagePath, boilerplate, customArgs.VersionedClientSetPackage))
packageList = append(packageList, factoryPackage(externalVersionPackagePath, boilerplate, groupGoNames, externalGroupVersions, customArgs.VersionedClientSetPackage, typesForGroupVersion)) packageList = append(packageList, factoryPackage(externalVersionPackagePath, boilerplate, groupGoNames, externalGroupVersions, customArgs.VersionedClientSetPackage, typesForGroupVersion))
for groupPkgName, groupVersionsEntry := range externalGroupVersions { for _, gvs := range externalGroupVersions {
packageList = append(packageList, groupPackage(externalVersionPackagePath, groupPkgName, groupVersionsEntry, boilerplate)) packageList = append(packageList, groupPackage(externalVersionPackagePath, gvs, boilerplate))
} }
} }
if len(internalGroupVersions) != 0 { if len(internalGroupVersions) != 0 {
packageList = append(packageList, factoryInterfacePackage(internalVersionPackagePath, boilerplate, customArgs.InternalClientSetPackage)) packageList = append(packageList, factoryInterfacePackage(internalVersionPackagePath, boilerplate, customArgs.InternalClientSetPackage))
packageList = append(packageList, factoryPackage(internalVersionPackagePath, boilerplate, groupGoNames, internalGroupVersions, customArgs.InternalClientSetPackage, typesForGroupVersion)) packageList = append(packageList, factoryPackage(internalVersionPackagePath, boilerplate, groupGoNames, internalGroupVersions, customArgs.InternalClientSetPackage, typesForGroupVersion))
for groupPkgName, groupVersionsEntry := range internalGroupVersions { for _, gvs := range internalGroupVersions {
packageList = append(packageList, groupPackage(internalVersionPackagePath, groupPkgName, groupVersionsEntry, boilerplate)) packageList = append(packageList, groupPackage(internalVersionPackagePath, gvs, boilerplate))
} }
} }
@@ -286,8 +287,9 @@ func factoryInterfacePackage(basePackage string, boilerplate []byte, clientSetPa
} }
} }
func groupPackage(basePackage string, groupPkgName string, groupVersions clientgentypes.GroupVersions, boilerplate []byte) generator.Package { func groupPackage(basePackage string, groupVersions clientgentypes.GroupVersions, boilerplate []byte) generator.Package {
packagePath := filepath.Join(basePackage, groupPkgName) packagePath := filepath.Join(basePackage, groupVersions.PackageName)
groupPkgName := strings.Split(string(groupVersions.Group), ".")[0]
return &generator.DefaultPackage{ return &generator.DefaultPackage{
PackageName: groupPkgName, PackageName: groupPkgName,

View File

@@ -87,7 +87,7 @@ fi
if [ "${GENS}" = "all" ] || grep -qw "client" <<<"${GENS}"; then if [ "${GENS}" = "all" ] || grep -qw "client" <<<"${GENS}"; then
echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/clientset" echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/clientset"
if [ -n "${INT_APIS_PKG}" ]; then if [ -n "${INT_APIS_PKG}" ]; then
${GOPATH}/bin/client-gen --clientset-name internalversion --input-base "" --input $(codegen::join "/," "${INT_FQ_APIS[@]}")/ --clientset-path ${OUTPUT_PKG}/clientset "$@" ${GOPATH}/bin/client-gen --clientset-name internalversion --input-base "" --input $(codegen::join , $(printf '%s/ ' "${INT_FQ_APIS[@]}")) --clientset-path ${OUTPUT_PKG}/clientset "$@"
fi fi
${GOPATH}/bin/client-gen --clientset-name versioned --input-base "" --input $(codegen::join , "${EXT_FQ_APIS[@]}") --clientset-path ${OUTPUT_PKG}/clientset "$@" ${GOPATH}/bin/client-gen --clientset-name versioned --input-base "" --input $(codegen::join , "${EXT_FQ_APIS[@]}") --clientset-path ${OUTPUT_PKG}/clientset "$@"
fi fi

View File

@@ -24,7 +24,7 @@ set -o pipefail
# instead of the $GOPATH directly. For normal projects this can be dropped. # instead of the $GOPATH directly. For normal projects this can be dropped.
$(dirname ${BASH_SOURCE})/../generate-internal-groups.sh all \ $(dirname ${BASH_SOURCE})/../generate-internal-groups.sh all \
k8s.io/code-generator/_examples/apiserver k8s.io/code-generator/_examples/apiserver/apis k8s.io/code-generator/_examples/apiserver/apis \ k8s.io/code-generator/_examples/apiserver k8s.io/code-generator/_examples/apiserver/apis k8s.io/code-generator/_examples/apiserver/apis \
example:v1 \ "example:v1 example2:v1" \
--output-base "$(dirname ${BASH_SOURCE})/../../.." --output-base "$(dirname ${BASH_SOURCE})/../../.."
$(dirname ${BASH_SOURCE})/../generate-groups.sh all \ $(dirname ${BASH_SOURCE})/../generate-groups.sh all \
k8s.io/code-generator/_examples/crd k8s.io/code-generator/_examples/crd/apis \ k8s.io/code-generator/_examples/crd k8s.io/code-generator/_examples/crd/apis \

View File

@@ -47,3 +47,7 @@ else
echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh" echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh"
exit 1 exit 1
fi fi
# smoke test
echo "Smoke testing _example by compiling..."
go build ${SCRIPT_ROOT}/_example/...