Merge pull request #52186 from sttts/sttts-codegen-scripts

Automatic merge from submit-queue (batch tested with PRs 53317, 52186). 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: rewrite hack/update-codecs.sh into reusable generate-{internal,}-groups.sh

Generating everything for groups inside of an apiserver (with internal types) becomes:

```shell
generate-internal-groups.sh all "$(dirname ${BASH_SOURCE})/../../.." k8s.io/sample-apiserver/pkg/client k8s.io/sample-apiserver/pkg/apis k8s.io/sample-apiserver/pkg/apis wardle:v1alpha1
```

Generating everything for a CRD (versioned types) becomes:

```shell
generate-groups.sh all "$(dirname ${BASH_SOURCE})/../../.." k8s.io/sample-apiserver/pkg/client k8s.io/sample-apiserver/pkg/apis wardle:v1alpha1
```

This should cover the 90% percent use-case. For the other 10% this can be forked and adapted as needed.

Furthermore, we can put this into a Docker container. Then code-generator consumers can do:

```shell
$ docker run -v $GOPATH:/go k8s.io/code-generator:1.8 generate-group.sh github.com/foo/bar example:v1
```

This is only possibly only the first step towards a `code-generator` binary. For the later deeper generator changes are necessary (e.g. https://github.com/kubernetes/kubernetes/pull/53202) and hence the later is only feasible in 1.9. **This PR here in contrast, we can cherry-pick to 1.8.**

```release-note
Add generate-groups.sh and generate-internal-groups.sh to k8s.io/code-generator to easily run generators against CRD or User API Server types.
```

Fixes https://github.com/kubernetes/kubernetes/issues/48714.
This commit is contained in:
Kubernetes Submit Queue 2017-10-04 10:32:49 -07:00 committed by GitHub
commit 1357cefd97
177 changed files with 2593 additions and 639 deletions

View File

@ -765,8 +765,18 @@ staging/src/k8s.io/metrics/pkg/client/custom_metrics/fake
staging/src/k8s.io/sample-apiserver/pkg/apis/wardle staging/src/k8s.io/sample-apiserver/pkg/apis/wardle
staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1 staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1
staging/src/k8s.io/sample-apiserver/pkg/apiserver staging/src/k8s.io/sample-apiserver/pkg/apiserver
staging/src/k8s.io/sample-apiserver/pkg/client/informers_generated/externalversions/internalinterfaces staging/src/k8s.io/sample-apiserver/pkg/client/clientset/internalversion
staging/src/k8s.io/sample-apiserver/pkg/client/informers_generated/internalversion/internalinterfaces staging/src/k8s.io/sample-apiserver/pkg/client/clientset/internalversion/fake
staging/src/k8s.io/sample-apiserver/pkg/client/clientset/internalversion/scheme
staging/src/k8s.io/sample-apiserver/pkg/client/clientset/internalversion/typed/wardle/internalversion
staging/src/k8s.io/sample-apiserver/pkg/client/clientset/internalversion/typed/wardle/internalversion/fake
staging/src/k8s.io/sample-apiserver/pkg/client/clientset/versioned
staging/src/k8s.io/sample-apiserver/pkg/client/clientset/versioned/fake
staging/src/k8s.io/sample-apiserver/pkg/client/clientset/versioned/scheme
staging/src/k8s.io/sample-apiserver/pkg/client/clientset/versioned/typed/wardle/v1alpha1
staging/src/k8s.io/sample-apiserver/pkg/client/clientset/versioned/typed/wardle/v1alpha1/fake
staging/src/k8s.io/sample-apiserver/pkg/client/informers/externalversions/internalinterfaces
staging/src/k8s.io/sample-apiserver/pkg/client/informers/internalversion/internalinterfaces
staging/src/k8s.io/sample-apiserver/pkg/cmd/server staging/src/k8s.io/sample-apiserver/pkg/cmd/server
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder

View File

@ -26,7 +26,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::verify_go_version kube::golang::verify_go_version
cd "${KUBE_ROOT}" cd "${KUBE_ROOT}"
if git --no-pager grep -E $'^(import |\t)[a-z]+[A-Z_][a-zA-Z]* "[^"]+"$' -- '**/*.go' ':(exclude)vendor/*' ':(exclude)staging/src/k8s.io/client-go/*vendor/*' ':(exclude)staging/src/k8s.io/metrics/*' ':(exclude)pkg/apis/admission/v1alpha1/zz_generated.conversion.go'; then if git --no-pager grep -E $'^(import |\t)[a-z]+[A-Z_][a-zA-Z]* "[^"]+"$' -- '**/*.go' ':(exclude)vendor/*' ':(exclude)staging/src/k8s.io/client-go/*vendor/*' ':(exclude)staging/src/k8s.io/metrics/*' ':(exclude)pkg/apis/admission/v1alpha1/zz_generated.conversion.go' ':(exclude)staging/src/k8s.io/sample-apiserver/pkg/client/informers/*' ':(exclude)staging/src/k8s.io/code-generator/_examples/*informers/*'; then
echo "!!! Some package aliases break go conventions." echo "!!! Some package aliases break go conventions."
echo "To fix these errors, do not use capitalized or underlined characters" echo "To fix these errors, do not use capitalized or underlined characters"
echo "in pkg aliases. Refer to https://blog.golang.org/package-names for more info." echo "in pkg aliases. Refer to https://blog.golang.org/package-names for more info."

View File

@ -15,5 +15,5 @@ limitations under the License.
*/ */
// +k8s:deepcopy-gen=package,register // +k8s:deepcopy-gen=package,register
// +groupName=testgroup.k8s.io // +groupName=example.apiserver.code-generator.k8s.io
package testgroup // import "k8s.io/code-generator/_test/apis/testgroup" package example // import "k8s.io/code-generator/_examples/apiserver/apis/example"

View File

@ -22,17 +22,17 @@ import (
"k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/announced"
"k8s.io/apimachinery/pkg/apimachinery/registered" "k8s.io/apimachinery/pkg/apimachinery/registered"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/code-generator/_test/apis/testgroup" "k8s.io/code-generator/_examples/apiserver/apis/example"
"k8s.io/code-generator/_test/apis/testgroup/v1" "k8s.io/code-generator/_examples/apiserver/apis/example/v1"
) )
// 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) {
if err := announced.NewGroupMetaFactory( if err := announced.NewGroupMetaFactory(
&announced.GroupMetaFactoryArgs{ &announced.GroupMetaFactoryArgs{
GroupName: testgroup.SchemeGroupVersion.Group, GroupName: example.SchemeGroupVersion.Group,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version}, VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version},
AddInternalObjectsToScheme: testgroup.AddToScheme, AddInternalObjectsToScheme: example.AddToScheme,
}, },
announced.VersionToSchemeFunc{ announced.VersionToSchemeFunc{
v1.SchemeGroupVersion.Version: v1.AddToScheme, v1.SchemeGroupVersion.Version: v1.AddToScheme,

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package testgroup package example
import ( import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"

View File

@ -14,13 +14,14 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package testgroup package example
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// +genclient // +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +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 { type TestType struct {
metav1.TypeMeta metav1.TypeMeta
metav1.ObjectMeta metav1.ObjectMeta
@ -29,6 +30,8 @@ type TestType struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +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 { type TestTypeList struct {
metav1.TypeMeta metav1.TypeMeta
metav1.ListMeta metav1.ListMeta

View File

@ -0,0 +1,20 @@
/*
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,register
// +k8s:conversion-gen=k8s.io/code-generator/_examples/apiserver/apis/example
// +groupName=example.apiserver.code-generator.k8s.io
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.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

@ -21,6 +21,7 @@ import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// +genclient // +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +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 { type TestType struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// +optional // +optional
@ -31,6 +32,8 @@ type TestType struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +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 { type TestTypeList struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// +optional // +optional

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"
example "k8s.io/code-generator/_examples/apiserver/apis/example"
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_example_TestType,
Convert_example_TestType_To_v1_TestType,
Convert_v1_TestTypeList_To_example_TestTypeList,
Convert_example_TestTypeList_To_v1_TestTypeList,
Convert_v1_TestTypeStatus_To_example_TestTypeStatus,
Convert_example_TestTypeStatus_To_v1_TestTypeStatus,
)
}
func autoConvert_v1_TestType_To_example_TestType(in *TestType, out *example.TestType, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_v1_TestTypeStatus_To_example_TestTypeStatus(&in.Status, &out.Status, s); err != nil {
return err
}
return nil
}
// Convert_v1_TestType_To_example_TestType is an autogenerated conversion function.
func Convert_v1_TestType_To_example_TestType(in *TestType, out *example.TestType, s conversion.Scope) error {
return autoConvert_v1_TestType_To_example_TestType(in, out, s)
}
func autoConvert_example_TestType_To_v1_TestType(in *example.TestType, out *TestType, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_example_TestTypeStatus_To_v1_TestTypeStatus(&in.Status, &out.Status, s); err != nil {
return err
}
return nil
}
// Convert_example_TestType_To_v1_TestType is an autogenerated conversion function.
func Convert_example_TestType_To_v1_TestType(in *example.TestType, out *TestType, s conversion.Scope) error {
return autoConvert_example_TestType_To_v1_TestType(in, out, s)
}
func autoConvert_v1_TestTypeList_To_example_TestTypeList(in *TestTypeList, out *example.TestTypeList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]example.TestType)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_v1_TestTypeList_To_example_TestTypeList is an autogenerated conversion function.
func Convert_v1_TestTypeList_To_example_TestTypeList(in *TestTypeList, out *example.TestTypeList, s conversion.Scope) error {
return autoConvert_v1_TestTypeList_To_example_TestTypeList(in, out, s)
}
func autoConvert_example_TestTypeList_To_v1_TestTypeList(in *example.TestTypeList, out *TestTypeList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]TestType)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_example_TestTypeList_To_v1_TestTypeList is an autogenerated conversion function.
func Convert_example_TestTypeList_To_v1_TestTypeList(in *example.TestTypeList, out *TestTypeList, s conversion.Scope) error {
return autoConvert_example_TestTypeList_To_v1_TestTypeList(in, out, s)
}
func autoConvert_v1_TestTypeStatus_To_example_TestTypeStatus(in *TestTypeStatus, out *example.TestTypeStatus, s conversion.Scope) error {
out.Blah = in.Blah
return nil
}
// Convert_v1_TestTypeStatus_To_example_TestTypeStatus is an autogenerated conversion function.
func Convert_v1_TestTypeStatus_To_example_TestTypeStatus(in *TestTypeStatus, out *example.TestTypeStatus, s conversion.Scope) error {
return autoConvert_v1_TestTypeStatus_To_example_TestTypeStatus(in, out, s)
}
func autoConvert_example_TestTypeStatus_To_v1_TestTypeStatus(in *example.TestTypeStatus, out *TestTypeStatus, s conversion.Scope) error {
out.Blah = in.Blah
return nil
}
// Convert_example_TestTypeStatus_To_v1_TestTypeStatus is an autogenerated conversion function.
func Convert_example_TestTypeStatus_To_v1_TestTypeStatus(in *example.TestTypeStatus, out *TestTypeStatus, s conversion.Scope) error {
return autoConvert_example_TestTypeStatus_To_v1_TestTypeStatus(in, out, s)
}

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"
example "k8s.io/code-generator/_examples/apiserver/apis/example"
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_example_TestType,
Convert_example_TestType_To_v1_TestType,
Convert_v1_TestTypeList_To_example_TestTypeList,
Convert_example_TestTypeList_To_v1_TestTypeList,
Convert_v1_TestTypeStatus_To_example_TestTypeStatus,
Convert_example_TestTypeStatus_To_v1_TestTypeStatus,
)
}
func autoConvert_v1_TestType_To_example_TestType(in *TestType, out *example.TestType, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_v1_TestTypeStatus_To_example_TestTypeStatus(&in.Status, &out.Status, s); err != nil {
return err
}
return nil
}
// Convert_v1_TestType_To_example_TestType is an autogenerated conversion function.
func Convert_v1_TestType_To_example_TestType(in *TestType, out *example.TestType, s conversion.Scope) error {
return autoConvert_v1_TestType_To_example_TestType(in, out, s)
}
func autoConvert_example_TestType_To_v1_TestType(in *example.TestType, out *TestType, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_example_TestTypeStatus_To_v1_TestTypeStatus(&in.Status, &out.Status, s); err != nil {
return err
}
return nil
}
// Convert_example_TestType_To_v1_TestType is an autogenerated conversion function.
func Convert_example_TestType_To_v1_TestType(in *example.TestType, out *TestType, s conversion.Scope) error {
return autoConvert_example_TestType_To_v1_TestType(in, out, s)
}
func autoConvert_v1_TestTypeList_To_example_TestTypeList(in *TestTypeList, out *example.TestTypeList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]example.TestType)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_v1_TestTypeList_To_example_TestTypeList is an autogenerated conversion function.
func Convert_v1_TestTypeList_To_example_TestTypeList(in *TestTypeList, out *example.TestTypeList, s conversion.Scope) error {
return autoConvert_v1_TestTypeList_To_example_TestTypeList(in, out, s)
}
func autoConvert_example_TestTypeList_To_v1_TestTypeList(in *example.TestTypeList, out *TestTypeList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]TestType)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_example_TestTypeList_To_v1_TestTypeList is an autogenerated conversion function.
func Convert_example_TestTypeList_To_v1_TestTypeList(in *example.TestTypeList, out *TestTypeList, s conversion.Scope) error {
return autoConvert_example_TestTypeList_To_v1_TestTypeList(in, out, s)
}
func autoConvert_v1_TestTypeStatus_To_example_TestTypeStatus(in *TestTypeStatus, out *example.TestTypeStatus, s conversion.Scope) error {
out.Blah = in.Blah
return nil
}
// Convert_v1_TestTypeStatus_To_example_TestTypeStatus is an autogenerated conversion function.
func Convert_v1_TestTypeStatus_To_example_TestTypeStatus(in *TestTypeStatus, out *example.TestTypeStatus, s conversion.Scope) error {
return autoConvert_v1_TestTypeStatus_To_example_TestTypeStatus(in, out, s)
}
func autoConvert_example_TestTypeStatus_To_v1_TestTypeStatus(in *example.TestTypeStatus, out *TestTypeStatus, s conversion.Scope) error {
out.Blah = in.Blah
return nil
}
// Convert_example_TestTypeStatus_To_v1_TestTypeStatus is an autogenerated conversion function.
func Convert_example_TestTypeStatus_To_v1_TestTypeStatus(in *example.TestTypeStatus, out *TestTypeStatus, s conversion.Scope) error {
return autoConvert_example_TestTypeStatus_To_v1_TestTypeStatus(in, out, s)
}

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

@ -18,7 +18,7 @@ limitations under the License.
// This file was autogenerated by deepcopy-gen. Do not edit it manually! // This file was autogenerated by deepcopy-gen. Do not edit it manually!
package testgroup package example
import ( import (
conversion "k8s.io/apimachinery/pkg/conversion" conversion "k8s.io/apimachinery/pkg/conversion"

View File

@ -14,31 +14,31 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package internal package internalversion
import ( import (
glog "github.com/golang/glog" glog "github.com/golang/glog"
discovery "k8s.io/client-go/discovery" discovery "k8s.io/client-go/discovery"
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"
testgroupinternalversion "k8s.io/code-generator/_test/clientset/internal/typed/testgroup/internalversion" exampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion"
) )
type Interface interface { type Interface interface {
Discovery() discovery.DiscoveryInterface Discovery() discovery.DiscoveryInterface
Testgroup() testgroupinternalversion.TestgroupInterface Example() exampleinternalversion.ExampleInterface
} }
// 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
testgroup *testgroupinternalversion.TestgroupClient example *exampleinternalversion.ExampleClient
} }
// Testgroup retrieves the TestgroupClient // Example retrieves the ExampleClient
func (c *Clientset) Testgroup() testgroupinternalversion.TestgroupInterface { func (c *Clientset) Example() exampleinternalversion.ExampleInterface {
return c.testgroup return c.example
} }
// Discovery retrieves the DiscoveryClient // Discovery retrieves the DiscoveryClient
@ -57,7 +57,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
} }
var cs Clientset var cs Clientset
var err error var err error
cs.testgroup, err = testgroupinternalversion.NewForConfig(&configShallowCopy) cs.example, err = exampleinternalversion.NewForConfig(&configShallowCopy)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -74,7 +74,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
// panics if there is an error in the config. // panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *Clientset { func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset var cs Clientset
cs.testgroup = testgroupinternalversion.NewForConfigOrDie(c) cs.example = exampleinternalversion.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs return &cs
@ -83,7 +83,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
// New creates a new Clientset for the given RESTClient. // New creates a new Clientset for the given RESTClient.
func New(c rest.Interface) *Clientset { func New(c rest.Interface) *Clientset {
var cs Clientset var cs Clientset
cs.testgroup = testgroupinternalversion.New(c) cs.example = exampleinternalversion.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs return &cs

View File

@ -17,4 +17,4 @@ limitations under the License.
// This package is generated by client-gen with custom arguments. // This package is generated by client-gen with custom arguments.
// This package has the automatically generated clientset. // This package has the automatically generated clientset.
package internalclientset package internalversion

View File

@ -22,9 +22,9 @@ import (
"k8s.io/client-go/discovery" "k8s.io/client-go/discovery"
fakediscovery "k8s.io/client-go/discovery/fake" fakediscovery "k8s.io/client-go/discovery/fake"
"k8s.io/client-go/testing" "k8s.io/client-go/testing"
clientset "k8s.io/code-generator/_test/clientset/internal" clientset "k8s.io/code-generator/_examples/apiserver/clientset/internalversion"
testgroupinternalversion "k8s.io/code-generator/_test/clientset/internal/typed/testgroup/internalversion" exampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion"
faketestgroupinternalversion "k8s.io/code-generator/_test/clientset/internal/typed/testgroup/internalversion/fake" fakeexampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake"
) )
// NewSimpleClientset returns a clientset that will respond with the provided objects. // NewSimpleClientset returns a clientset that will respond with the provided objects.
@ -60,7 +60,7 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface {
var _ clientset.Interface = &Clientset{} var _ clientset.Interface = &Clientset{}
// Testgroup retrieves the TestgroupClient // Example retrieves the ExampleClient
func (c *Clientset) Testgroup() testgroupinternalversion.TestgroupInterface { func (c *Clientset) Example() exampleinternalversion.ExampleInterface {
return &faketestgroupinternalversion.FakeTestgroup{Fake: &c.Fake} return &fakeexampleinternalversion.FakeExample{Fake: &c.Fake}
} }

View File

@ -0,0 +1,53 @@
/*
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"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
exampleinternalversion "k8s.io/code-generator/_examples/apiserver/apis/example"
)
var scheme = runtime.NewScheme()
var codecs = serializer.NewCodecFactory(scheme)
var parameterCodec = runtime.NewParameterCodec(scheme)
func init() {
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
AddToScheme(scheme)
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
// of clientsets, like in:
//
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kuberentes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
func AddToScheme(scheme *runtime.Scheme) {
exampleinternalversion.AddToScheme(scheme)
}

View File

@ -23,7 +23,7 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
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"
testgroup "k8s.io/code-generator/_test/apis/testgroup/install" example "k8s.io/code-generator/_examples/apiserver/apis/example/install"
os "os" os "os"
) )
@ -41,6 +41,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) {
testgroup.Install(groupFactoryRegistry, registry, scheme) example.Install(groupFactoryRegistry, registry, scheme)
} }

View File

@ -18,25 +18,25 @@ package internalversion
import ( import (
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
"k8s.io/code-generator/_test/clientset/internal/scheme" "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme"
) )
type TestgroupInterface interface { type ExampleInterface interface {
RESTClient() rest.Interface RESTClient() rest.Interface
TestTypesGetter TestTypesGetter
} }
// TestgroupClient is used to interact with features provided by the testgroup.k8s.io group. // ExampleClient is used to interact with features provided by the example.apiserver.code-generator.k8s.io group.
type TestgroupClient struct { type ExampleClient struct {
restClient rest.Interface restClient rest.Interface
} }
func (c *TestgroupClient) TestTypes(namespace string) TestTypeInterface { func (c *ExampleClient) TestTypes(namespace string) TestTypeInterface {
return newTestTypes(c, namespace) return newTestTypes(c, namespace)
} }
// NewForConfig creates a new TestgroupClient for the given config. // NewForConfig creates a new ExampleClient for the given config.
func NewForConfig(c *rest.Config) (*TestgroupClient, error) { func NewForConfig(c *rest.Config) (*ExampleClient, error) {
config := *c config := *c
if err := setConfigDefaults(&config); err != nil { if err := setConfigDefaults(&config); err != nil {
return nil, err return nil, err
@ -45,12 +45,12 @@ func NewForConfig(c *rest.Config) (*TestgroupClient, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &TestgroupClient{client}, nil return &ExampleClient{client}, nil
} }
// NewForConfigOrDie creates a new TestgroupClient for the given config and // NewForConfigOrDie creates a new ExampleClient for the given config and
// panics if there is an error in the config. // panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *TestgroupClient { func NewForConfigOrDie(c *rest.Config) *ExampleClient {
client, err := NewForConfig(c) client, err := NewForConfig(c)
if err != nil { if err != nil {
panic(err) panic(err)
@ -58,13 +58,13 @@ func NewForConfigOrDie(c *rest.Config) *TestgroupClient {
return client return client
} }
// New creates a new TestgroupClient for the given RESTClient. // New creates a new ExampleClient for the given RESTClient.
func New(c rest.Interface) *TestgroupClient { func New(c rest.Interface) *ExampleClient {
return &TestgroupClient{c} return &ExampleClient{c}
} }
func setConfigDefaults(config *rest.Config) error { func setConfigDefaults(config *rest.Config) error {
g, err := scheme.Registry.Group("testgroup.k8s.io") g, err := scheme.Registry.Group("example.apiserver.code-generator.k8s.io")
if err != nil { if err != nil {
return err return err
} }
@ -91,7 +91,7 @@ func setConfigDefaults(config *rest.Config) error {
// RESTClient returns a RESTClient that is used to communicate // RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation. // with API server by this client implementation.
func (c *TestgroupClient) RESTClient() rest.Interface { func (c *ExampleClient) RESTClient() rest.Interface {
if c == nil { if c == nil {
return nil return nil
} }

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/example/internalversion"
)
type FakeExample struct {
*testing.Fake
}
func (c *FakeExample) 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 *FakeExample) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

View File

@ -23,34 +23,34 @@ import (
types "k8s.io/apimachinery/pkg/types" types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch" watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing" testing "k8s.io/client-go/testing"
testgroup "k8s.io/code-generator/_test/apis/testgroup" example "k8s.io/code-generator/_examples/apiserver/apis/example"
) )
// FakeTestTypes implements TestTypeInterface // FakeTestTypes implements TestTypeInterface
type FakeTestTypes struct { type FakeTestTypes struct {
Fake *FakeTestgroup Fake *FakeExample
ns string ns string
} }
var testtypesResource = schema.GroupVersionResource{Group: "testgroup.k8s.io", Version: "", Resource: "testtypes"} var testtypesResource = schema.GroupVersionResource{Group: "example.apiserver.code-generator.k8s.io", Version: "", Resource: "testtypes"}
var testtypesKind = schema.GroupVersionKind{Group: "testgroup.k8s.io", Version: "", Kind: "TestType"} var testtypesKind = schema.GroupVersionKind{Group: "example.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. // 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 *testgroup.TestType, err error) { func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example.TestType, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &testgroup.TestType{}) Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example.TestType{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*testgroup.TestType), err return obj.(*example.TestType), err
} }
// List takes label and field selectors, and returns the list of TestTypes that match those selectors. // List takes label and field selectors, and returns the list of TestTypes that match those selectors.
func (c *FakeTestTypes) List(opts v1.ListOptions) (result *testgroup.TestTypeList, err error) { func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example.TestTypeList, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &testgroup.TestTypeList{}) Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example.TestTypeList{})
if obj == nil { if obj == nil {
return nil, err return nil, err
@ -60,8 +60,8 @@ func (c *FakeTestTypes) List(opts v1.ListOptions) (result *testgroup.TestTypeLis
if label == nil { if label == nil {
label = labels.Everything() label = labels.Everything()
} }
list := &testgroup.TestTypeList{} list := &example.TestTypeList{}
for _, item := range obj.(*testgroup.TestTypeList).Items { for _, item := range obj.(*example.TestTypeList).Items {
if label.Matches(labels.Set(item.Labels)) { if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item) list.Items = append(list.Items, item)
} }
@ -77,43 +77,43 @@ func (c *FakeTestTypes) Watch(opts v1.ListOptions) (watch.Interface, error) {
} }
// 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. // 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 *testgroup.TestType) (result *testgroup.TestType, err error) { func (c *FakeTestTypes) Create(testType *example.TestType) (result *example.TestType, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &testgroup.TestType{}) Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example.TestType{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*testgroup.TestType), err return obj.(*example.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. // 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 *testgroup.TestType) (result *testgroup.TestType, err error) { func (c *FakeTestTypes) Update(testType *example.TestType) (result *example.TestType, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &testgroup.TestType{}) Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example.TestType{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*testgroup.TestType), err return obj.(*example.TestType), err
} }
// UpdateStatus was generated because the type contains a Status member. // UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeTestTypes) UpdateStatus(testType *testgroup.TestType) (*testgroup.TestType, error) { func (c *FakeTestTypes) UpdateStatus(testType *example.TestType) (*example.TestType, error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &testgroup.TestType{}) Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example.TestType{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*testgroup.TestType), err return obj.(*example.TestType), err
} }
// Delete takes name of the testType and deletes it. Returns an error if one occurs. // 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 { func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake. _, err := c.Fake.
Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &testgroup.TestType{}) Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &example.TestType{})
return err return err
} }
@ -122,17 +122,17 @@ func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error {
func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOptions) action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &testgroup.TestTypeList{}) _, err := c.Fake.Invokes(action, &example.TestTypeList{})
return err return err
} }
// Patch applies the patch and returns the patched testType. // Patch applies the patch and returns the patched testType.
func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *testgroup.TestType, err error) { func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example.TestType, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &testgroup.TestType{}) Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example.TestType{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*testgroup.TestType), err return obj.(*example.TestType), err
} }

View File

@ -21,8 +21,8 @@ import (
types "k8s.io/apimachinery/pkg/types" types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch" watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
testgroup "k8s.io/code-generator/_test/apis/testgroup" example "k8s.io/code-generator/_examples/apiserver/apis/example"
scheme "k8s.io/code-generator/_test/clientset/internal/scheme" scheme "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme"
) )
// TestTypesGetter has a method to return a TestTypeInterface. // TestTypesGetter has a method to return a TestTypeInterface.
@ -33,15 +33,15 @@ type TestTypesGetter interface {
// TestTypeInterface has methods to work with TestType resources. // TestTypeInterface has methods to work with TestType resources.
type TestTypeInterface interface { type TestTypeInterface interface {
Create(*testgroup.TestType) (*testgroup.TestType, error) Create(*example.TestType) (*example.TestType, error)
Update(*testgroup.TestType) (*testgroup.TestType, error) Update(*example.TestType) (*example.TestType, error)
UpdateStatus(*testgroup.TestType) (*testgroup.TestType, error) UpdateStatus(*example.TestType) (*example.TestType, error)
Delete(name string, options *v1.DeleteOptions) error Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string, options v1.GetOptions) (*testgroup.TestType, error) Get(name string, options v1.GetOptions) (*example.TestType, error)
List(opts v1.ListOptions) (*testgroup.TestTypeList, error) List(opts v1.ListOptions) (*example.TestTypeList, error)
Watch(opts v1.ListOptions) (watch.Interface, error) Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *testgroup.TestType, err error) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example.TestType, err error)
TestTypeExpansion TestTypeExpansion
} }
@ -52,7 +52,7 @@ type testTypes struct {
} }
// newTestTypes returns a TestTypes // newTestTypes returns a TestTypes
func newTestTypes(c *TestgroupClient, namespace string) *testTypes { func newTestTypes(c *ExampleClient, namespace string) *testTypes {
return &testTypes{ return &testTypes{
client: c.RESTClient(), client: c.RESTClient(),
ns: namespace, ns: namespace,
@ -60,8 +60,8 @@ func newTestTypes(c *TestgroupClient, namespace string) *testTypes {
} }
// 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 *testTypes) Get(name string, options v1.GetOptions) (result *testgroup.TestType, err error) { func (c *testTypes) Get(name string, options v1.GetOptions) (result *example.TestType, err error) {
result = &testgroup.TestType{} result = &example.TestType{}
err = c.client.Get(). err = c.client.Get().
Namespace(c.ns). Namespace(c.ns).
Resource("testtypes"). Resource("testtypes").
@ -73,8 +73,8 @@ func (c *testTypes) Get(name string, options v1.GetOptions) (result *testgroup.T
} }
// List takes label and field selectors, and returns the list of TestTypes that match those selectors. // List takes label and field selectors, and returns the list of TestTypes that match those selectors.
func (c *testTypes) List(opts v1.ListOptions) (result *testgroup.TestTypeList, err error) { func (c *testTypes) List(opts v1.ListOptions) (result *example.TestTypeList, err error) {
result = &testgroup.TestTypeList{} result = &example.TestTypeList{}
err = c.client.Get(). err = c.client.Get().
Namespace(c.ns). Namespace(c.ns).
Resource("testtypes"). Resource("testtypes").
@ -95,8 +95,8 @@ func (c *testTypes) Watch(opts v1.ListOptions) (watch.Interface, error) {
} }
// 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. // 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 *testgroup.TestType) (result *testgroup.TestType, err error) { func (c *testTypes) Create(testType *example.TestType) (result *example.TestType, err error) {
result = &testgroup.TestType{} result = &example.TestType{}
err = c.client.Post(). err = c.client.Post().
Namespace(c.ns). Namespace(c.ns).
Resource("testtypes"). Resource("testtypes").
@ -107,8 +107,8 @@ func (c *testTypes) Create(testType *testgroup.TestType) (result *testgroup.Test
} }
// 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. // 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 *testgroup.TestType) (result *testgroup.TestType, err error) { func (c *testTypes) Update(testType *example.TestType) (result *example.TestType, err error) {
result = &testgroup.TestType{} result = &example.TestType{}
err = c.client.Put(). err = c.client.Put().
Namespace(c.ns). Namespace(c.ns).
Resource("testtypes"). Resource("testtypes").
@ -122,8 +122,8 @@ func (c *testTypes) Update(testType *testgroup.TestType) (result *testgroup.Test
// UpdateStatus was generated because the type contains a Status member. // UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *testTypes) UpdateStatus(testType *testgroup.TestType) (result *testgroup.TestType, err error) { func (c *testTypes) UpdateStatus(testType *example.TestType) (result *example.TestType, err error) {
result = &testgroup.TestType{} result = &example.TestType{}
err = c.client.Put(). err = c.client.Put().
Namespace(c.ns). Namespace(c.ns).
Resource("testtypes"). Resource("testtypes").
@ -158,8 +158,8 @@ func (c *testTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.L
} }
// Patch applies the patch and returns the patched testType. // Patch applies the patch and returns the patched testType.
func (c *testTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *testgroup.TestType, err error) { func (c *testTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example.TestType, err error) {
result = &testgroup.TestType{} result = &example.TestType{}
err = c.client.Patch(pt). err = c.client.Patch(pt).
Namespace(c.ns). Namespace(c.ns).
Resource("testtypes"). Resource("testtypes").

View File

@ -21,32 +21,32 @@ import (
discovery "k8s.io/client-go/discovery" discovery "k8s.io/client-go/discovery"
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"
testgroupv1 "k8s.io/code-generator/_test/clientset/versioned/typed/testgroup/v1" examplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1"
) )
type Interface interface { type Interface interface {
Discovery() discovery.DiscoveryInterface Discovery() discovery.DiscoveryInterface
TestgroupV1() testgroupv1.TestgroupV1Interface ExampleV1() examplev1.ExampleV1Interface
// Deprecated: please explicitly pick a version if possible. // Deprecated: please explicitly pick a version if possible.
Testgroup() testgroupv1.TestgroupV1Interface Example() examplev1.ExampleV1Interface
} }
// 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
testgroupV1 *testgroupv1.TestgroupV1Client exampleV1 *examplev1.ExampleV1Client
} }
// TestgroupV1 retrieves the TestgroupV1Client // ExampleV1 retrieves the ExampleV1Client
func (c *Clientset) TestgroupV1() testgroupv1.TestgroupV1Interface { func (c *Clientset) ExampleV1() examplev1.ExampleV1Interface {
return c.testgroupV1 return c.exampleV1
} }
// Deprecated: Testgroup retrieves the default version of TestgroupClient. // Deprecated: Example retrieves the default version of ExampleClient.
// Please explicitly pick a version. // Please explicitly pick a version.
func (c *Clientset) Testgroup() testgroupv1.TestgroupV1Interface { func (c *Clientset) Example() examplev1.ExampleV1Interface {
return c.testgroupV1 return c.exampleV1
} }
// Discovery retrieves the DiscoveryClient // Discovery retrieves the DiscoveryClient
@ -65,7 +65,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
} }
var cs Clientset var cs Clientset
var err error var err error
cs.testgroupV1, err = testgroupv1.NewForConfig(&configShallowCopy) cs.exampleV1, err = examplev1.NewForConfig(&configShallowCopy)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -82,7 +82,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
// panics if there is an error in the config. // panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *Clientset { func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset var cs Clientset
cs.testgroupV1 = testgroupv1.NewForConfigOrDie(c) cs.exampleV1 = examplev1.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs return &cs
@ -91,7 +91,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
// New creates a new Clientset for the given RESTClient. // New creates a new Clientset for the given RESTClient.
func New(c rest.Interface) *Clientset { func New(c rest.Interface) *Clientset {
var cs Clientset var cs Clientset
cs.testgroupV1 = testgroupv1.New(c) cs.exampleV1 = examplev1.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs return &cs

View File

@ -0,0 +1,71 @@
/*
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 (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/discovery"
fakediscovery "k8s.io/client-go/discovery/fake"
"k8s.io/client-go/testing"
clientset "k8s.io/code-generator/_examples/apiserver/clientset/versioned"
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"
)
// NewSimpleClientset returns a clientset that will respond with the provided objects.
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
// without applying any validations and/or defaults. It shouldn't be considered a replacement
// for a real clientset and is mostly useful in simple unit tests.
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
for _, obj := range objects {
if err := o.Add(obj); err != nil {
panic(err)
}
}
fakePtr := testing.Fake{}
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o))
fakePtr.AddWatchReactor("*", testing.DefaultWatchReactor(watch.NewFake(), nil))
return &Clientset{fakePtr, &fakediscovery.FakeDiscovery{Fake: &fakePtr}}
}
// Clientset implements clientset.Interface. Meant to be embedded into a
// struct to get a default implementation. This makes faking out just the method
// you want to test easier.
type Clientset struct {
testing.Fake
discovery *fakediscovery.FakeDiscovery
}
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return c.discovery
}
var _ clientset.Interface = &Clientset{}
// ExampleV1 retrieves the ExampleV1Client
func (c *Clientset) ExampleV1() examplev1.ExampleV1Interface {
return &fakeexamplev1.FakeExampleV1{Fake: &c.Fake}
}
// Example retrieves the ExampleV1Client
func (c *Clientset) Example() examplev1.ExampleV1Interface {
return &fakeexamplev1.FakeExampleV1{Fake: &c.Fake}
}

View File

@ -21,7 +21,7 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
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"
testgroupinternalversion "k8s.io/code-generator/_test/apis/testgroup" examplev1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1"
) )
var scheme = runtime.NewScheme() var scheme = runtime.NewScheme()
@ -48,6 +48,6 @@ 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 *runtime.Scheme) { func AddToScheme(scheme *runtime.Scheme) {
testgroupinternalversion.AddToScheme(scheme) examplev1.AddToScheme(scheme)
} }

View File

@ -0,0 +1,53 @@
/*
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 scheme
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
examplev1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1"
)
var Scheme = runtime.NewScheme()
var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme)
func init() {
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
AddToScheme(Scheme)
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
// of clientsets, like in:
//
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kuberentes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
func AddToScheme(scheme *runtime.Scheme) {
examplev1.AddToScheme(scheme)
}

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/example/v1"
"k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme"
)
type ExampleV1Interface interface {
RESTClient() rest.Interface
TestTypesGetter
}
// ExampleV1Client is used to interact with features provided by the example.apiserver.code-generator.k8s.io group.
type ExampleV1Client struct {
restClient rest.Interface
}
func (c *ExampleV1Client) TestTypes(namespace string) TestTypeInterface {
return newTestTypes(c, namespace)
}
// NewForConfig creates a new ExampleV1Client for the given config.
func NewForConfig(c *rest.Config) (*ExampleV1Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &ExampleV1Client{client}, nil
}
// NewForConfigOrDie creates a new ExampleV1Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *ExampleV1Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new ExampleV1Client for the given RESTClient.
func New(c rest.Interface) *ExampleV1Client {
return &ExampleV1Client{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 *ExampleV1Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}

View File

@ -19,20 +19,20 @@ package fake
import ( import (
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing" testing "k8s.io/client-go/testing"
internalversion "k8s.io/code-generator/_test/clientset/internal/typed/testgroup/internalversion" v1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1"
) )
type FakeTestgroup struct { type FakeExampleV1 struct {
*testing.Fake *testing.Fake
} }
func (c *FakeTestgroup) TestTypes(namespace string) internalversion.TestTypeInterface { func (c *FakeExampleV1) TestTypes(namespace string) v1.TestTypeInterface {
return &FakeTestTypes{c, namespace} return &FakeTestTypes{c, namespace}
} }
// RESTClient returns a RESTClient that is used to communicate // RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation. // with API server by this client implementation.
func (c *FakeTestgroup) RESTClient() rest.Interface { func (c *FakeExampleV1) RESTClient() rest.Interface {
var ret *rest.RESTClient var ret *rest.RESTClient
return ret 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"
example_v1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1"
)
// FakeTestTypes implements TestTypeInterface
type FakeTestTypes struct {
Fake *FakeExampleV1
ns string
}
var testtypesResource = schema.GroupVersionResource{Group: "example.apiserver.code-generator.k8s.io", Version: "v1", Resource: "testtypes"}
var testtypesKind = schema.GroupVersionKind{Group: "example.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 *example_v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example_v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_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 *example_v1.TestTypeList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example_v1.TestTypeList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &example_v1.TestTypeList{}
for _, item := range obj.(*example_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 *example_v1.TestType) (result *example_v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example_v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_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 *example_v1.TestType) (result *example_v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example_v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_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 *example_v1.TestType) (*example_v1.TestType, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example_v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_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), &example_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, &example_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 *example_v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example_v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.TestType), err
}

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/example/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 *ExampleV1Client, 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,44 @@
/*
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/example/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 {
internalinterfaces.SharedInformerFactory
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory) Interface {
return &group{f}
}
// V1 returns a new v1.Interface.
func (g *group) V1() v1.Interface {
return v1.New(g.SharedInformerFactory)
}

View File

@ -0,0 +1,43 @@
/*
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 {
internalinterfaces.SharedInformerFactory
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory) Interface {
return &version{f}
}
// TestTypes returns a TestTypeInformer.
func (v *version) TestTypes() TestTypeInformer {
return &testTypeInformer{factory: v.SharedInformerFactory}
}

View File

@ -0,0 +1,73 @@
/*
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"
example_v1 "k8s.io/code-generator/_examples/apiserver/apis/example/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/example/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
}
// 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 cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.ExampleV1().TestTypes(namespace).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.ExampleV1().TestTypes(namespace).Watch(options)
},
},
&example_v1.TestType{},
resyncPeriod,
indexers,
)
}
func defaultTestTypeInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewTestTypeInformer(client, meta_v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
}
func (f *testTypeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&example_v1.TestType{}, defaultTestTypeInformer)
}
func (f *testTypeInformer) Lister() v1.TestTypeLister {
return v1.NewTestTypeLister(f.Informer().GetIndexer())
}

View File

@ -0,0 +1,118 @@
/*
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 externalversions
import (
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
versioned "k8s.io/code-generator/_examples/apiserver/clientset/versioned"
example "k8s.io/code-generator/_examples/apiserver/informers/externalversions/example"
internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces"
reflect "reflect"
sync "sync"
time "time"
)
type sharedInformerFactory struct {
client versioned.Interface
lock sync.Mutex
defaultResync time.Duration
informers map[reflect.Type]cache.SharedIndexInformer
// startedInformers is used for tracking which informers have been started.
// This allows Start() to be called multiple times safely.
startedInformers map[reflect.Type]bool
}
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
return &sharedInformerFactory{
client: client,
defaultResync: defaultResync,
informers: make(map[reflect.Type]cache.SharedIndexInformer),
startedInformers: make(map[reflect.Type]bool),
}
}
// Start initializes all requested informers.
func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) {
f.lock.Lock()
defer f.lock.Unlock()
for informerType, informer := range f.informers {
if !f.startedInformers[informerType] {
go informer.Run(stopCh)
f.startedInformers[informerType] = true
}
}
}
// WaitForCacheSync waits for all started informers' cache were synced.
func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool {
informers := func() map[reflect.Type]cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informers := map[reflect.Type]cache.SharedIndexInformer{}
for informerType, informer := range f.informers {
if f.startedInformers[informerType] {
informers[informerType] = informer
}
}
return informers
}()
res := map[reflect.Type]bool{}
for informType, informer := range informers {
res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced)
}
return res
}
// InternalInformerFor returns the SharedIndexInformer for obj using an internal
// client.
func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerType := reflect.TypeOf(obj)
informer, exists := f.informers[informerType]
if exists {
return informer
}
informer = newFunc(f.client, f.defaultResync)
f.informers[informerType] = informer
return informer
}
// SharedInformerFactory provides shared informers for resources in all known
// API group versions.
type SharedInformerFactory interface {
internalinterfaces.SharedInformerFactory
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
Example() example.Interface
}
func (f *sharedInformerFactory) Example() example.Interface {
return example.New(f)
}

View File

@ -0,0 +1,61 @@
/*
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 externalversions
import (
"fmt"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
v1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1"
)
// GenericInformer is type of SharedIndexInformer which will locate and delegate to other
// sharedInformers based on type
type GenericInformer interface {
Informer() cache.SharedIndexInformer
Lister() cache.GenericLister
}
type genericInformer struct {
informer cache.SharedIndexInformer
resource schema.GroupResource
}
// Informer returns the SharedIndexInformer.
func (f *genericInformer) Informer() cache.SharedIndexInformer {
return f.informer
}
// Lister returns the GenericLister.
func (f *genericInformer) Lister() cache.GenericLister {
return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource)
}
// ForResource gives generic access to a shared informer of the matching type
// TODO extend this to unknown resources with a client pool
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource {
// Group=Example, Version=V1
case v1.SchemeGroupVersion.WithResource("testtypes"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Example().V1().TestTypes().Informer()}, nil
}
return nil, fmt.Errorf("no informer found for %v", resource)
}

View File

@ -21,11 +21,11 @@ package internalinterfaces
import ( import (
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache" cache "k8s.io/client-go/tools/cache"
clientset "k8s.io/sample-apiserver/pkg/client/clientset_generated/clientset" versioned "k8s.io/code-generator/_examples/apiserver/clientset/versioned"
time "time" time "time"
) )
type NewInformerFunc func(clientset.Interface, time.Duration) cache.SharedIndexInformer type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle // SharedInformerFactory a small interface to allow for adding an informer without an import cycle
type SharedInformerFactory interface { type SharedInformerFactory interface {

View File

@ -16,11 +16,11 @@ limitations under the License.
// This file was automatically generated by informer-gen // This file was automatically generated by informer-gen
package testgroup package example
import ( import (
internalinterfaces "k8s.io/code-generator/_test/informers/internalversion/internalinterfaces" internalversion "k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/internalversion"
internalversion "k8s.io/code-generator/_test/informers/internalversion/testgroup/internalversion" internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces"
) )
// Interface provides access to each of this group's versions. // Interface provides access to each of this group's versions.

View File

@ -19,7 +19,7 @@ limitations under the License.
package internalversion package internalversion
import ( import (
internalinterfaces "k8s.io/code-generator/_test/informers/internalversion/internalinterfaces" internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces"
) )
// Interface provides access to all the informers in this group version. // Interface provides access to all the informers in this group version.

View File

@ -23,10 +23,10 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch" watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache" cache "k8s.io/client-go/tools/cache"
testgroup "k8s.io/code-generator/_test/apis/testgroup" example "k8s.io/code-generator/_examples/apiserver/apis/example"
internal "k8s.io/code-generator/_test/clientset/internal" clientset_internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion"
internalinterfaces "k8s.io/code-generator/_test/informers/internalversion/internalinterfaces" internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces"
internalversion "k8s.io/code-generator/_test/listers/testgroup/internalversion" internalversion "k8s.io/code-generator/_examples/apiserver/listers/example/internalversion"
time "time" time "time"
) )
@ -44,28 +44,28 @@ type testTypeInformer struct {
// NewTestTypeInformer constructs a new informer for TestType type. // NewTestTypeInformer constructs a new informer for TestType type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent // 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. // one. This reduces memory footprint and number of connections to the server.
func NewTestTypeInformer(client internal.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { func NewTestTypeInformer(client clientset_internalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer( return cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.Testgroup().TestTypes(namespace).List(options) return client.Example().TestTypes(namespace).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.Testgroup().TestTypes(namespace).Watch(options) return client.Example().TestTypes(namespace).Watch(options)
}, },
}, },
&testgroup.TestType{}, &example.TestType{},
resyncPeriod, resyncPeriod,
indexers, indexers,
) )
} }
func defaultTestTypeInformer(client internal.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { func defaultTestTypeInformer(client clientset_internalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewTestTypeInformer(client, v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}) return NewTestTypeInformer(client, v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
} }
func (f *testTypeInformer) Informer() cache.SharedIndexInformer { func (f *testTypeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&testgroup.TestType{}, defaultTestTypeInformer) return f.factory.InformerFor(&example.TestType{}, defaultTestTypeInformer)
} }
func (f *testTypeInformer) Lister() internalversion.TestTypeLister { func (f *testTypeInformer) Lister() internalversion.TestTypeLister {

View File

@ -22,16 +22,16 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
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"
internal "k8s.io/code-generator/_test/clientset/internal" internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion"
internalinterfaces "k8s.io/code-generator/_test/informers/internalversion/internalinterfaces" example "k8s.io/code-generator/_examples/apiserver/informers/internalversion/example"
testgroup "k8s.io/code-generator/_test/informers/internalversion/testgroup" internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces"
reflect "reflect" reflect "reflect"
sync "sync" sync "sync"
time "time" time "time"
) )
type sharedInformerFactory struct { type sharedInformerFactory struct {
client internal.Interface client internalversion.Interface
lock sync.Mutex lock sync.Mutex
defaultResync time.Duration defaultResync time.Duration
@ -42,7 +42,7 @@ type sharedInformerFactory struct {
} }
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory // NewSharedInformerFactory constructs a new instance of sharedInformerFactory
func NewSharedInformerFactory(client internal.Interface, defaultResync time.Duration) SharedInformerFactory { func NewSharedInformerFactory(client internalversion.Interface, defaultResync time.Duration) SharedInformerFactory {
return &sharedInformerFactory{ return &sharedInformerFactory{
client: client, client: client,
defaultResync: defaultResync, defaultResync: defaultResync,
@ -110,9 +110,9 @@ type SharedInformerFactory interface {
ForResource(resource schema.GroupVersionResource) (GenericInformer, error) ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
Testgroup() testgroup.Interface Example() example.Interface
} }
func (f *sharedInformerFactory) Testgroup() testgroup.Interface { func (f *sharedInformerFactory) Example() example.Interface {
return testgroup.New(f) return example.New(f)
} }

View File

@ -22,7 +22,7 @@ import (
"fmt" "fmt"
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"
testgroup "k8s.io/code-generator/_test/apis/testgroup" example "k8s.io/code-generator/_examples/apiserver/apis/example"
) )
// GenericInformer is type of SharedIndexInformer which will locate and delegate to other // GenericInformer is type of SharedIndexInformer which will locate and delegate to other
@ -51,9 +51,9 @@ func (f *genericInformer) Lister() cache.GenericLister {
// TODO extend this to unknown resources with a client pool // TODO extend this to unknown resources with a client pool
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource { switch resource {
// Group=Testgroup, Version=InternalVersion // Group=Example, Version=InternalVersion
case testgroup.SchemeGroupVersion.WithResource("testtypes"): case example.SchemeGroupVersion.WithResource("testtypes"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Testgroup().InternalVersion().TestTypes().Informer()}, nil return &genericInformer{resource: resource.GroupResource(), informer: f.Example().InternalVersion().TestTypes().Informer()}, nil
} }

View File

@ -21,11 +21,11 @@ package internalinterfaces
import ( import (
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache" cache "k8s.io/client-go/tools/cache"
internalclientset "k8s.io/sample-apiserver/pkg/client/clientset_generated/internalclientset" internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion"
time "time" time "time"
) )
type NewInformerFunc func(internalclientset.Interface, time.Duration) cache.SharedIndexInformer type NewInformerFunc func(internalversion.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle // SharedInformerFactory a small interface to allow for adding an informer without an import cycle
type SharedInformerFactory interface { type SharedInformerFactory interface {

View File

@ -22,13 +22,13 @@ import (
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
testgroup "k8s.io/code-generator/_test/apis/testgroup" example "k8s.io/code-generator/_examples/apiserver/apis/example"
) )
// TestTypeLister helps list TestTypes. // TestTypeLister helps list TestTypes.
type TestTypeLister interface { type TestTypeLister interface {
// List lists all TestTypes in the indexer. // List lists all TestTypes in the indexer.
List(selector labels.Selector) (ret []*testgroup.TestType, err error) List(selector labels.Selector) (ret []*example.TestType, err error)
// TestTypes returns an object that can list and get TestTypes. // TestTypes returns an object that can list and get TestTypes.
TestTypes(namespace string) TestTypeNamespaceLister TestTypes(namespace string) TestTypeNamespaceLister
TestTypeListerExpansion TestTypeListerExpansion
@ -45,9 +45,9 @@ func NewTestTypeLister(indexer cache.Indexer) TestTypeLister {
} }
// List lists all TestTypes in the indexer. // List lists all TestTypes in the indexer.
func (s *testTypeLister) List(selector labels.Selector) (ret []*testgroup.TestType, err error) { func (s *testTypeLister) List(selector labels.Selector) (ret []*example.TestType, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) { err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*testgroup.TestType)) ret = append(ret, m.(*example.TestType))
}) })
return ret, err return ret, err
} }
@ -60,9 +60,9 @@ func (s *testTypeLister) TestTypes(namespace string) TestTypeNamespaceLister {
// TestTypeNamespaceLister helps list and get TestTypes. // TestTypeNamespaceLister helps list and get TestTypes.
type TestTypeNamespaceLister interface { type TestTypeNamespaceLister interface {
// List lists all TestTypes in the indexer for a given namespace. // List lists all TestTypes in the indexer for a given namespace.
List(selector labels.Selector) (ret []*testgroup.TestType, err error) List(selector labels.Selector) (ret []*example.TestType, err error)
// Get retrieves the TestType from the indexer for a given namespace and name. // Get retrieves the TestType from the indexer for a given namespace and name.
Get(name string) (*testgroup.TestType, error) Get(name string) (*example.TestType, error)
TestTypeNamespaceListerExpansion TestTypeNamespaceListerExpansion
} }
@ -74,21 +74,21 @@ type testTypeNamespaceLister struct {
} }
// List lists all TestTypes in the indexer for a given namespace. // List lists all TestTypes in the indexer for a given namespace.
func (s testTypeNamespaceLister) List(selector labels.Selector) (ret []*testgroup.TestType, err error) { func (s testTypeNamespaceLister) List(selector labels.Selector) (ret []*example.TestType, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*testgroup.TestType)) ret = append(ret, m.(*example.TestType))
}) })
return ret, err return ret, err
} }
// Get retrieves the TestType from the indexer for a given namespace and name. // Get retrieves the TestType from the indexer for a given namespace and name.
func (s testTypeNamespaceLister) Get(name string) (*testgroup.TestType, error) { func (s testTypeNamespaceLister) Get(name string) (*example.TestType, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if !exists { if !exists {
return nil, errors.NewNotFound(testgroup.Resource("testtype"), name) return nil, errors.NewNotFound(example.Resource("testtype"), name)
} }
return obj.(*testgroup.TestType), nil return obj.(*example.TestType), nil
} }

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/example/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,5 +15,5 @@ limitations under the License.
*/ */
// +k8s:deepcopy-gen=package,register // +k8s:deepcopy-gen=package,register
// +groupName=testgroup.k8s.io // +groupName=example.crd.code-generator.k8s.io
package v1 package v1

View File

@ -22,7 +22,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
) )
var SchemeGroupVersion = schema.GroupVersion{Group: "testgroup.k8s.io", Version: "v1"} var SchemeGroupVersion = schema.GroupVersion{Group: "example.crd.code-generator.k8s.io", Version: "v1"}
var ( var (
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.

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,130 @@
// +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 (
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
reflect "reflect"
)
func init() {
SchemeBuilder.Register(RegisterDeepCopies)
}
// RegisterDeepCopies adds deep-copy functions to the given scheme. Public
// to allow building arbitrary schemes.
//
// Deprecated: deepcopy registration will go away when static deepcopy is fully implemented.
func RegisterDeepCopies(scheme *runtime.Scheme) error {
return scheme.AddGeneratedDeepCopyFuncs(
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*TestType).DeepCopyInto(out.(*TestType))
return nil
}, InType: reflect.TypeOf(&TestType{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*TestTypeList).DeepCopyInto(out.(*TestTypeList))
return nil
}, InType: reflect.TypeOf(&TestTypeList{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*TestTypeStatus).DeepCopyInto(out.(*TestTypeStatus))
return nil
}, InType: reflect.TypeOf(&TestTypeStatus{})},
)
}
// 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,98 @@
/*
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 versioned
import (
glog "github.com/golang/glog"
discovery "k8s.io/client-go/discovery"
rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol"
examplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1"
)
type Interface interface {
Discovery() discovery.DiscoveryInterface
ExampleV1() examplev1.ExampleV1Interface
// Deprecated: please explicitly pick a version if possible.
Example() examplev1.ExampleV1Interface
}
// Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset.
type Clientset struct {
*discovery.DiscoveryClient
exampleV1 *examplev1.ExampleV1Client
}
// ExampleV1 retrieves the ExampleV1Client
func (c *Clientset) ExampleV1() examplev1.ExampleV1Interface {
return c.exampleV1
}
// Deprecated: Example retrieves the default version of ExampleClient.
// Please explicitly pick a version.
func (c *Clientset) Example() examplev1.ExampleV1Interface {
return c.exampleV1
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil {
return nil
}
return c.DiscoveryClient
}
// NewForConfig creates a new Clientset for the given config.
func NewForConfig(c *rest.Config) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
}
var cs Clientset
var err error
cs.exampleV1, err = examplev1.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil {
glog.Errorf("failed to create the DiscoveryClient: %v", err)
return nil, err
}
return &cs, nil
}
// NewForConfigOrDie creates a new Clientset for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset
cs.exampleV1 = examplev1.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs
}
// New creates a new Clientset for the given RESTClient.
func New(c rest.Interface) *Clientset {
var cs Clientset
cs.exampleV1 = examplev1.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs
}

View File

@ -17,4 +17,4 @@ limitations under the License.
// This package is generated by client-gen with custom arguments. // This package is generated by client-gen with custom arguments.
// This package has the automatically generated clientset. // This package has the automatically generated clientset.
package internal package versioned

View File

@ -22,9 +22,9 @@ import (
"k8s.io/client-go/discovery" "k8s.io/client-go/discovery"
fakediscovery "k8s.io/client-go/discovery/fake" fakediscovery "k8s.io/client-go/discovery/fake"
"k8s.io/client-go/testing" "k8s.io/client-go/testing"
clientset "k8s.io/code-generator/_test/clientset/versioned" clientset "k8s.io/code-generator/_examples/crd/clientset/versioned"
testgroupv1 "k8s.io/code-generator/_test/clientset/versioned/typed/testgroup/v1" examplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1"
faketestgroupv1 "k8s.io/code-generator/_test/clientset/versioned/typed/testgroup/v1/fake" fakeexamplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake"
) )
// NewSimpleClientset returns a clientset that will respond with the provided objects. // NewSimpleClientset returns a clientset that will respond with the provided objects.
@ -60,12 +60,12 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface {
var _ clientset.Interface = &Clientset{} var _ clientset.Interface = &Clientset{}
// TestgroupV1 retrieves the TestgroupV1Client // ExampleV1 retrieves the ExampleV1Client
func (c *Clientset) TestgroupV1() testgroupv1.TestgroupV1Interface { func (c *Clientset) ExampleV1() examplev1.ExampleV1Interface {
return &faketestgroupv1.FakeTestgroupV1{Fake: &c.Fake} return &fakeexamplev1.FakeExampleV1{Fake: &c.Fake}
} }
// Testgroup retrieves the TestgroupV1Client // Example retrieves the ExampleV1Client
func (c *Clientset) Testgroup() testgroupv1.TestgroupV1Interface { func (c *Clientset) Example() examplev1.ExampleV1Interface {
return &faketestgroupv1.FakeTestgroupV1{Fake: &c.Fake} return &fakeexamplev1.FakeExampleV1{Fake: &c.Fake}
} }

View File

@ -21,7 +21,7 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
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"
testgroupv1 "k8s.io/code-generator/_test/apis/testgroup/v1" examplev1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
) )
var scheme = runtime.NewScheme() var scheme = runtime.NewScheme()
@ -48,6 +48,6 @@ 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 *runtime.Scheme) { func AddToScheme(scheme *runtime.Scheme) {
testgroupv1.AddToScheme(scheme) examplev1.AddToScheme(scheme)
} }

View File

@ -21,7 +21,7 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
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"
testgroupv1 "k8s.io/code-generator/_test/apis/testgroup/v1" examplev1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
) )
var Scheme = runtime.NewScheme() var Scheme = runtime.NewScheme()
@ -48,6 +48,6 @@ 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 *runtime.Scheme) { func AddToScheme(scheme *runtime.Scheme) {
testgroupv1.AddToScheme(scheme) examplev1.AddToScheme(scheme)
} }

View File

@ -0,0 +1,20 @@
/*
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 is generated by client-gen with custom arguments.
// This package has the automatically generated typed clients.
package v1

View File

@ -19,26 +19,26 @@ package v1
import ( import (
serializer "k8s.io/apimachinery/pkg/runtime/serializer" serializer "k8s.io/apimachinery/pkg/runtime/serializer"
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
v1 "k8s.io/code-generator/_test/apis/testgroup/v1" v1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
"k8s.io/code-generator/_test/clientset/versioned/scheme" "k8s.io/code-generator/_examples/crd/clientset/versioned/scheme"
) )
type TestgroupV1Interface interface { type ExampleV1Interface interface {
RESTClient() rest.Interface RESTClient() rest.Interface
TestTypesGetter TestTypesGetter
} }
// TestgroupV1Client is used to interact with features provided by the testgroup.k8s.io group. // ExampleV1Client is used to interact with features provided by the example.crd.code-generator.k8s.io group.
type TestgroupV1Client struct { type ExampleV1Client struct {
restClient rest.Interface restClient rest.Interface
} }
func (c *TestgroupV1Client) TestTypes(namespace string) TestTypeInterface { func (c *ExampleV1Client) TestTypes(namespace string) TestTypeInterface {
return newTestTypes(c, namespace) return newTestTypes(c, namespace)
} }
// NewForConfig creates a new TestgroupV1Client for the given config. // NewForConfig creates a new ExampleV1Client for the given config.
func NewForConfig(c *rest.Config) (*TestgroupV1Client, error) { func NewForConfig(c *rest.Config) (*ExampleV1Client, error) {
config := *c config := *c
if err := setConfigDefaults(&config); err != nil { if err := setConfigDefaults(&config); err != nil {
return nil, err return nil, err
@ -47,12 +47,12 @@ func NewForConfig(c *rest.Config) (*TestgroupV1Client, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &TestgroupV1Client{client}, nil return &ExampleV1Client{client}, nil
} }
// NewForConfigOrDie creates a new TestgroupV1Client for the given config and // NewForConfigOrDie creates a new ExampleV1Client for the given config and
// panics if there is an error in the config. // panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *TestgroupV1Client { func NewForConfigOrDie(c *rest.Config) *ExampleV1Client {
client, err := NewForConfig(c) client, err := NewForConfig(c)
if err != nil { if err != nil {
panic(err) panic(err)
@ -60,9 +60,9 @@ func NewForConfigOrDie(c *rest.Config) *TestgroupV1Client {
return client return client
} }
// New creates a new TestgroupV1Client for the given RESTClient. // New creates a new ExampleV1Client for the given RESTClient.
func New(c rest.Interface) *TestgroupV1Client { func New(c rest.Interface) *ExampleV1Client {
return &TestgroupV1Client{c} return &ExampleV1Client{c}
} }
func setConfigDefaults(config *rest.Config) error { func setConfigDefaults(config *rest.Config) error {
@ -80,7 +80,7 @@ func setConfigDefaults(config *rest.Config) error {
// RESTClient returns a RESTClient that is used to communicate // RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation. // with API server by this client implementation.
func (c *TestgroupV1Client) RESTClient() rest.Interface { func (c *ExampleV1Client) RESTClient() rest.Interface {
if c == nil { if c == nil {
return nil return nil
} }

View File

@ -19,20 +19,20 @@ package fake
import ( import (
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing" testing "k8s.io/client-go/testing"
v1 "k8s.io/code-generator/_test/clientset/versioned/typed/testgroup/v1" v1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1"
) )
type FakeTestgroupV1 struct { type FakeExampleV1 struct {
*testing.Fake *testing.Fake
} }
func (c *FakeTestgroupV1) TestTypes(namespace string) v1.TestTypeInterface { func (c *FakeExampleV1) TestTypes(namespace string) v1.TestTypeInterface {
return &FakeTestTypes{c, namespace} return &FakeTestTypes{c, namespace}
} }
// RESTClient returns a RESTClient that is used to communicate // RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation. // with API server by this client implementation.
func (c *FakeTestgroupV1) RESTClient() rest.Interface { func (c *FakeExampleV1) RESTClient() rest.Interface {
var ret *rest.RESTClient var ret *rest.RESTClient
return ret return ret
} }

View File

@ -23,34 +23,34 @@ import (
types "k8s.io/apimachinery/pkg/types" types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch" watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing" testing "k8s.io/client-go/testing"
testgroup_v1 "k8s.io/code-generator/_test/apis/testgroup/v1" example_v1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
) )
// FakeTestTypes implements TestTypeInterface // FakeTestTypes implements TestTypeInterface
type FakeTestTypes struct { type FakeTestTypes struct {
Fake *FakeTestgroupV1 Fake *FakeExampleV1
ns string ns string
} }
var testtypesResource = schema.GroupVersionResource{Group: "testgroup.k8s.io", Version: "v1", Resource: "testtypes"} var testtypesResource = schema.GroupVersionResource{Group: "example.crd.code-generator.k8s.io", Version: "v1", Resource: "testtypes"}
var testtypesKind = schema.GroupVersionKind{Group: "testgroup.k8s.io", Version: "v1", Kind: "TestType"} var testtypesKind = schema.GroupVersionKind{Group: "example.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 *testgroup_v1.TestType, err error) { func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example_v1.TestType, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &testgroup_v1.TestType{}) Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example_v1.TestType{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*testgroup_v1.TestType), err return obj.(*example_v1.TestType), err
} }
// List takes label and field selectors, and returns the list of TestTypes that match those selectors. // List takes label and field selectors, and returns the list of TestTypes that match those selectors.
func (c *FakeTestTypes) List(opts v1.ListOptions) (result *testgroup_v1.TestTypeList, err error) { func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example_v1.TestTypeList, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &testgroup_v1.TestTypeList{}) Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example_v1.TestTypeList{})
if obj == nil { if obj == nil {
return nil, err return nil, err
@ -60,8 +60,8 @@ func (c *FakeTestTypes) List(opts v1.ListOptions) (result *testgroup_v1.TestType
if label == nil { if label == nil {
label = labels.Everything() label = labels.Everything()
} }
list := &testgroup_v1.TestTypeList{} list := &example_v1.TestTypeList{}
for _, item := range obj.(*testgroup_v1.TestTypeList).Items { for _, item := range obj.(*example_v1.TestTypeList).Items {
if label.Matches(labels.Set(item.Labels)) { if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item) list.Items = append(list.Items, item)
} }
@ -77,43 +77,43 @@ func (c *FakeTestTypes) Watch(opts v1.ListOptions) (watch.Interface, error) {
} }
// 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. // 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 *testgroup_v1.TestType) (result *testgroup_v1.TestType, err error) { func (c *FakeTestTypes) Create(testType *example_v1.TestType) (result *example_v1.TestType, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &testgroup_v1.TestType{}) Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example_v1.TestType{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*testgroup_v1.TestType), err return obj.(*example_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. // 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 *testgroup_v1.TestType) (result *testgroup_v1.TestType, err error) { func (c *FakeTestTypes) Update(testType *example_v1.TestType) (result *example_v1.TestType, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &testgroup_v1.TestType{}) Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example_v1.TestType{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*testgroup_v1.TestType), err return obj.(*example_v1.TestType), err
} }
// UpdateStatus was generated because the type contains a Status member. // UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeTestTypes) UpdateStatus(testType *testgroup_v1.TestType) (*testgroup_v1.TestType, error) { func (c *FakeTestTypes) UpdateStatus(testType *example_v1.TestType) (*example_v1.TestType, error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &testgroup_v1.TestType{}) Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example_v1.TestType{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*testgroup_v1.TestType), err return obj.(*example_v1.TestType), err
} }
// Delete takes name of the testType and deletes it. Returns an error if one occurs. // 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 { func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake. _, err := c.Fake.
Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &testgroup_v1.TestType{}) Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &example_v1.TestType{})
return err return err
} }
@ -122,17 +122,17 @@ func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error {
func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOptions) action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &testgroup_v1.TestTypeList{}) _, err := c.Fake.Invokes(action, &example_v1.TestTypeList{})
return err return err
} }
// Patch applies the patch and returns the patched testType. // Patch applies the patch and returns the patched testType.
func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *testgroup_v1.TestType, err error) { func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example_v1.TestType, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &testgroup_v1.TestType{}) Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example_v1.TestType{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*testgroup_v1.TestType), err return obj.(*example_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

@ -21,8 +21,8 @@ import (
types "k8s.io/apimachinery/pkg/types" types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch" watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
v1 "k8s.io/code-generator/_test/apis/testgroup/v1" v1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
scheme "k8s.io/code-generator/_test/clientset/versioned/scheme" scheme "k8s.io/code-generator/_examples/crd/clientset/versioned/scheme"
) )
// TestTypesGetter has a method to return a TestTypeInterface. // TestTypesGetter has a method to return a TestTypeInterface.
@ -52,7 +52,7 @@ type testTypes struct {
} }
// newTestTypes returns a TestTypes // newTestTypes returns a TestTypes
func newTestTypes(c *TestgroupV1Client, namespace string) *testTypes { func newTestTypes(c *ExampleV1Client, namespace string) *testTypes {
return &testTypes{ return &testTypes{
client: c.RESTClient(), client: c.RESTClient(),
ns: namespace, ns: namespace,

View File

@ -16,11 +16,11 @@ limitations under the License.
// This file was automatically generated by informer-gen // This file was automatically generated by informer-gen
package testgroup package example
import ( import (
internalinterfaces "k8s.io/code-generator/_test/informers/externalversions/internalinterfaces" v1 "k8s.io/code-generator/_examples/crd/informers/externalversions/example/v1"
v1 "k8s.io/code-generator/_test/informers/externalversions/testgroup/v1" internalinterfaces "k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces"
) )
// Interface provides access to each of this group's versions. // Interface provides access to each of this group's versions.

View File

@ -19,7 +19,7 @@ limitations under the License.
package v1 package v1
import ( import (
internalinterfaces "k8s.io/code-generator/_test/informers/externalversions/internalinterfaces" internalinterfaces "k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces"
) )
// Interface provides access to all the informers in this group version. // Interface provides access to all the informers in this group version.

View File

@ -23,10 +23,10 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch" watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache" cache "k8s.io/client-go/tools/cache"
testgroup_v1 "k8s.io/code-generator/_test/apis/testgroup/v1" example_v1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
versioned "k8s.io/code-generator/_test/clientset/versioned" versioned "k8s.io/code-generator/_examples/crd/clientset/versioned"
internalinterfaces "k8s.io/code-generator/_test/informers/externalversions/internalinterfaces" internalinterfaces "k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces"
v1 "k8s.io/code-generator/_test/listers/testgroup/v1" v1 "k8s.io/code-generator/_examples/crd/listers/example/v1"
time "time" time "time"
) )
@ -48,13 +48,13 @@ func NewTestTypeInformer(client versioned.Interface, namespace string, resyncPer
return cache.NewSharedIndexInformer( return cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) { ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.TestgroupV1().TestTypes(namespace).List(options) return client.ExampleV1().TestTypes(namespace).List(options)
}, },
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.TestgroupV1().TestTypes(namespace).Watch(options) return client.ExampleV1().TestTypes(namespace).Watch(options)
}, },
}, },
&testgroup_v1.TestType{}, &example_v1.TestType{},
resyncPeriod, resyncPeriod,
indexers, indexers,
) )
@ -65,7 +65,7 @@ func defaultTestTypeInformer(client versioned.Interface, resyncPeriod time.Durat
} }
func (f *testTypeInformer) Informer() cache.SharedIndexInformer { func (f *testTypeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&testgroup_v1.TestType{}, defaultTestTypeInformer) return f.factory.InformerFor(&example_v1.TestType{}, defaultTestTypeInformer)
} }
func (f *testTypeInformer) Lister() v1.TestTypeLister { func (f *testTypeInformer) Lister() v1.TestTypeLister {

View File

@ -22,9 +22,9 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
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"
versioned "k8s.io/code-generator/_test/clientset/versioned" versioned "k8s.io/code-generator/_examples/crd/clientset/versioned"
internalinterfaces "k8s.io/code-generator/_test/informers/externalversions/internalinterfaces" example "k8s.io/code-generator/_examples/crd/informers/externalversions/example"
testgroup "k8s.io/code-generator/_test/informers/externalversions/testgroup" internalinterfaces "k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces"
reflect "reflect" reflect "reflect"
sync "sync" sync "sync"
time "time" time "time"
@ -110,9 +110,9 @@ type SharedInformerFactory interface {
ForResource(resource schema.GroupVersionResource) (GenericInformer, error) ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
Testgroup() testgroup.Interface Example() example.Interface
} }
func (f *sharedInformerFactory) Testgroup() testgroup.Interface { func (f *sharedInformerFactory) Example() example.Interface {
return testgroup.New(f) return example.New(f)
} }

View File

@ -22,7 +22,7 @@ import (
"fmt" "fmt"
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/_test/apis/testgroup/v1" v1 "k8s.io/code-generator/_examples/crd/apis/example/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
@ -51,9 +51,9 @@ func (f *genericInformer) Lister() cache.GenericLister {
// TODO extend this to unknown resources with a client pool // TODO extend this to unknown resources with a client pool
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource { switch resource {
// Group=Testgroup, Version=V1 // Group=Example, Version=V1
case v1.SchemeGroupVersion.WithResource("testtypes"): case v1.SchemeGroupVersion.WithResource("testtypes"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Testgroup().V1().TestTypes().Informer()}, nil return &genericInformer{resource: resource.GroupResource(), informer: f.Example().V1().TestTypes().Informer()}, nil
} }

View File

@ -21,11 +21,11 @@ package internalinterfaces
import ( import (
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache" cache "k8s.io/client-go/tools/cache"
internal "k8s.io/code-generator/_test/clientset/internal" versioned "k8s.io/code-generator/_examples/crd/clientset/versioned"
time "time" time "time"
) )
type NewInformerFunc func(internal.Interface, time.Duration) cache.SharedIndexInformer type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle // SharedInformerFactory a small interface to allow for adding an informer without an import cycle
type SharedInformerFactory interface { type SharedInformerFactory interface {

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

@ -22,7 +22,7 @@ import (
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
v1 "k8s.io/code-generator/_test/apis/testgroup/v1" v1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
) )
// TestTypeLister helps list TestTypes. // TestTypeLister helps list TestTypes.

View File

@ -0,0 +1,86 @@
#!/usr/bin/env bash
# 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.
set -o errexit
set -o nounset
set -o pipefail
# generate-groups generates everything for a project with external types only, e.g. a project based
# on CustomResourceDefinitions.
if [ "$#" -le 4 ] || [ "${1}" == "--help" ]; then
cat <<EOF
Usage: $(basename $0) <generators> <output-package> <apis-package> <groups-versions> ...
<generators> the generators comma separated to run (deepcopy,defaulter,client,lister,informer) or "all".
<output-package> the output package name (e.g. github.com/example/project/pkg/generated).
<apis-package> the external types dir (e.g. github.com/example/api or github.com/example/project/pkg/apis).
<groups-versions> the groups and their versions in the format "groupA:v1,v2 groupB:v1 groupC:v2", relative
to <api-package>.
... arbitrary flags passed to all generator binaries.
Examples:
$(basename $0) all github.com/example/project/pkg/client github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1"
$(basename $0) deepcopy,client github.com/example/project/pkg/client github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1"
EOF
exit 0
fi
GENS="$1"
OUTPUT_PKG="$2"
APIS_PKG="$3"
GROUPS_WITH_VERSIONS="$4"
shift 4
go install ./$(dirname "${0}")/cmd/{defaulter-gen,client-gen,lister-gen,informer-gen,deepcopy-gen}
function codegen::join() { local IFS="$1"; shift; echo "$*"; }
# enumerate group versions
FQ_APIS=() # e.g. k8s.io/api/apps/v1
for GVs in ${GROUPS_WITH_VERSIONS}; do
IFS=: read G Vs <<<"${GVs}"
# enumerate versions
for V in ${Vs//,/ }; do
FQ_APIS+=(${APIS_PKG}/${G}/${V})
done
done
if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then
echo "Generating deepcopy funcs"
${GOPATH}/bin/deepcopy-gen --input-dirs $(codegen::join , "${FQ_APIS[@]}") -O zz_generated.deepcopy --bounding-dirs ${APIS_PKG} "$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "client" <<<"${GENS}"; then
echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/clientset"
${GOPATH}/bin/client-gen --clientset-name versioned --input-base "" --input $(codegen::join , "${FQ_APIS[@]}") --clientset-path ${OUTPUT_PKG}/clientset "$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "lister" <<<"${GENS}"; then
echo "Generating listers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/listers"
${GOPATH}/bin/lister-gen --input-dirs $(codegen::join , "${FQ_APIS[@]}") --output-package ${OUTPUT_PKG}/listers "$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "informer" <<<"${GENS}"; then
echo "Generating informers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/informers"
${GOPATH}/bin/informer-gen \
--input-dirs $(codegen::join , "${FQ_APIS[@]}") \
--versioned-clientset-package ${OUTPUT_PKG}/clientset/versioned \
--listers-package ${OUTPUT_PKG}/listers \
--output-package ${OUTPUT_PKG}/informers \
"$@"
fi

View File

@ -0,0 +1,109 @@
#!/usr/bin/env bash
# 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.
set -o errexit
set -o nounset
set -o pipefail
# generate-internal-groups generates everything for a project with internal types, e.g. an
# user-provided API server based on k8s.io/apiserver.
if [ "$#" -le 5 ] || [ "${1}" == "--help" ]; then
cat <<EOF
Usage: $(basename $0) <generators> <output-package> <internal-apis-package> <extensiona-apis-package> <groups-versions> ...
<generators> the generators comma separated to run (deepcopy,defaulter,conversion,client,lister,informer) or "all".
<output-package> the output package name (e.g. github.com/example/project/pkg/generated).
<int-apis-package> the internal types dir (e.g. github.com/example/project/pkg/apis).
<ext-apis-package> the external types dir (e.g. github.com/example/project/pkg/apis or githubcom/example/apis).
<groups-versions> the groups and their versions in the format "groupA:v1,v2 groupB:v1 groupC:v2", relative
to <api-package>.
... arbitrary flags passed to all generator binaries.
Examples:
$(basename $0) all github.com/example/project/pkg/client github.com/example/project/pkg/apis github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1"
$(basename $0) deepcopy,defaulter,conversion github.com/example/project/pkg/client github.com/example/project/pkg/apis github.com/example/project/apis "foo:v1 bar:v1alpha1,v1beta1"
EOF
exit 0
fi
GENS="$1"
OUTPUT_PKG="$2"
INT_APIS_PKG="$3"
EXT_APIS_PKG="$4"
GROUPS_WITH_VERSIONS="$5"
shift 5
go install ./$(dirname "${0}")/cmd/{defaulter-gen,conversion-gen,client-gen,lister-gen,informer-gen,deepcopy-gen}
function codegen::join() { local IFS="$1"; shift; echo "$*"; }
# enumerate group versions
ALL_FQ_APIS=() # e.g. k8s.io/kubernetes/pkg/apis/apps k8s.io/api/apps/v1
INT_FQ_APIS=() # e.g. k8s.io/kubernetes/pkg/apis/apps
EXT_FQ_APIS=() # e.g. k8s.io/api/apps/v1
for GVs in ${GROUPS_WITH_VERSIONS}; do
IFS=: read G Vs <<<"${GVs}"
if [ -n "${INT_APIS_PKG}" ]; then
ALL_FQ_APIS+=("${INT_APIS_PKG}/${G}")
INT_FQ_APIS+=("${INT_APIS_PKG}/${G}")
fi
# enumerate versions
for V in ${Vs//,/ }; do
ALL_FQ_APIS+=("${EXT_APIS_PKG}/${G}/${V}")
EXT_FQ_APIS+=("${EXT_APIS_PKG}/${G}/${V}")
done
done
if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then
echo "Generating deepcopy funcs"
${GOPATH}/bin/deepcopy-gen --input-dirs $(codegen::join , "${ALL_FQ_APIS[@]}") -O zz_generated.deepcopy --bounding-dirs ${INT_APIS_PKG},${EXT_APIS_PKG} "$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "defaulter" <<<"${GENS}"; then
echo "Generating defaulters"
${GOPATH}/bin/defaulter-gen --input-dirs $(codegen::join , "${EXT_FQ_APIS[@]}") -O zz_generated.defaults "$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "conversion" <<<"${GENS}"; then
echo "Generating conversions"
${GOPATH}/bin/conversion-gen --input-dirs $(codegen::join , "${ALL_FQ_APIS[@]}") -O zz_generated.conversion "$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "client" <<<"${GENS}"; then
echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/clientset"
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 "$@"
fi
${GOPATH}/bin/client-gen --clientset-name versioned --input-base "" --input $(codegen::join , "${EXT_FQ_APIS[@]}") --clientset-path ${OUTPUT_PKG}/clientset "$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "lister" <<<"${GENS}"; then
echo "Generating listers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/listers"
${GOPATH}/bin/lister-gen --input-dirs $(codegen::join , "${ALL_FQ_APIS[@]}") --output-package ${OUTPUT_PKG}/listers "$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "informer" <<<"${GENS}"; then
echo "Generating informers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/informers"
${GOPATH}/bin/informer-gen \
--input-dirs $(codegen::join , "${ALL_FQ_APIS[@]}") \
--versioned-clientset-package ${OUTPUT_PKG}/clientset/versioned \
--internal-clientset-package ${OUTPUT_PKG}/clientset/internalversion \
--listers-package ${OUTPUT_PKG}/listers \
--output-package ${OUTPUT_PKG}/informers \
"$@"
fi

View File

@ -18,58 +18,15 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
SCRIPT_PACKAGE=k8s.io/code-generator # generate the code with:
SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/.. # - --output-base because this script should also be able to run inside the vendor dir of
SCRIPT_BASE=${SCRIPT_ROOT}/../.. # k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir
CODEGEN_PKG=${CODEGEN_PKG:-$(ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo "k8s.io/code-generator")} # instead of the $GOPATH directly. For normal projects this can be dropped.
$(dirname ${BASH_SOURCE})/../generate-internal-groups.sh all \
clientgen="${PWD}/client-gen-binary" k8s.io/code-generator/_examples/apiserver k8s.io/code-generator/_examples/apiserver/apis k8s.io/code-generator/_examples/apiserver/apis \
listergen="${PWD}/lister-gen" example:v1 \
informergen="${PWD}/informer-gen" --output-base "$(dirname ${BASH_SOURCE})/../../.."
# Register function to be called on EXIT to remove generated binary. $(dirname ${BASH_SOURCE})/../generate-groups.sh all \
function cleanup { k8s.io/code-generator/_examples/crd k8s.io/code-generator/_examples/crd/apis \
rm -f "${clientgen:-}" example:v1 \
rm -f "${listergen:-}" --output-base "$(dirname ${BASH_SOURCE})/../../.."
rm -f "${informergen:-}"
}
trap cleanup EXIT
function generate_group() {
local GROUP_NAME=$1
local VERSION=$2
local CLIENT_PKG=${SCRIPT_PACKAGE}/_test/clientset
local LISTERS_PKG=${SCRIPT_PACKAGE}/_test/listers
local INFORMERS_PKG=${SCRIPT_PACKAGE}/_test/informers
local APIS_PKG=${SCRIPT_PACKAGE}/_test/apis
local INPUT_APIS=(
${GROUP_NAME}/
${GROUP_NAME}/${VERSION}
)
echo "Building client-gen"
go build -o "${clientgen}" ${CODEGEN_PKG}/cmd/client-gen
echo "generating clientset for group ${GROUP_NAME} and version ${VERSION} at ${SCRIPT_BASE}/${CLIENT_PKG}"
${clientgen} --clientset-name="internal" --input-base ${APIS_PKG} --input ${INPUT_APIS[@]} --clientset-path ${CLIENT_PKG} --output-base=${SCRIPT_BASE}
${clientgen} --clientset-name="versioned" --input-base ${APIS_PKG} --input ${GROUP_NAME}/${VERSION} --clientset-path ${CLIENT_PKG} --output-base=${SCRIPT_BASE}
echo "Building lister-gen"
go build -o "${listergen}" ${CODEGEN_PKG}/cmd/lister-gen
echo "generating listers for group ${GROUP_NAME} and version ${VERSION} at ${SCRIPT_BASE}/${LISTERS_PKG}"
${listergen} --input-dirs ${APIS_PKG}/${GROUP_NAME} --input-dirs ${APIS_PKG}/${GROUP_NAME}/${VERSION} --output-package ${LISTERS_PKG} --output-base ${SCRIPT_BASE}
echo "Building informer-gen"
go build -o "${informergen}" ${CODEGEN_PKG}/cmd/informer-gen
echo "generating informers for group ${GROUP_NAME} and version ${VERSION} at ${SCRIPT_BASE}/${INFORMERS_PKG}"
${informergen} \
--input-dirs ${APIS_PKG}/${GROUP_NAME} --input-dirs ${APIS_PKG}/${GROUP_NAME}/${VERSION} \
--versioned-clientset-package ${CLIENT_PKG}/versioned \
--internal-clientset-package ${CLIENT_PKG}/internal \
--listers-package ${LISTERS_PKG} \
--output-package ${INFORMERS_PKG} \
--output-base ${SCRIPT_BASE}
}
generate_group testgroup v1

View File

@ -21,8 +21,8 @@ set -o pipefail
SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/.. SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/..
SCRIPT_BASE=${SCRIPT_ROOT}/../.. SCRIPT_BASE=${SCRIPT_ROOT}/../..
DIFFROOT="${SCRIPT_ROOT}/_test" DIFFROOT="${SCRIPT_ROOT}/_examples"
TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/_test" TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/_examples"
_tmp="${SCRIPT_ROOT}/_tmp" _tmp="${SCRIPT_ROOT}/_tmp"
cleanup() { cleanup() {

View File

@ -37,12 +37,12 @@ filegroup(
"//staging/src/k8s.io/sample-apiserver/pkg/admission/wardleinitializer:all-srcs", "//staging/src/k8s.io/sample-apiserver/pkg/admission/wardleinitializer:all-srcs",
"//staging/src/k8s.io/sample-apiserver/pkg/apis/wardle:all-srcs", "//staging/src/k8s.io/sample-apiserver/pkg/apis/wardle:all-srcs",
"//staging/src/k8s.io/sample-apiserver/pkg/apiserver:all-srcs", "//staging/src/k8s.io/sample-apiserver/pkg/apiserver:all-srcs",
"//staging/src/k8s.io/sample-apiserver/pkg/client/clientset_generated/clientset:all-srcs", "//staging/src/k8s.io/sample-apiserver/pkg/client/clientset/internalversion:all-srcs",
"//staging/src/k8s.io/sample-apiserver/pkg/client/clientset_generated/internalclientset:all-srcs", "//staging/src/k8s.io/sample-apiserver/pkg/client/clientset/versioned:all-srcs",
"//staging/src/k8s.io/sample-apiserver/pkg/client/informers_generated/externalversions:all-srcs", "//staging/src/k8s.io/sample-apiserver/pkg/client/informers/externalversions:all-srcs",
"//staging/src/k8s.io/sample-apiserver/pkg/client/informers_generated/internalversion:all-srcs", "//staging/src/k8s.io/sample-apiserver/pkg/client/informers/internalversion:all-srcs",
"//staging/src/k8s.io/sample-apiserver/pkg/client/listers_generated/wardle/internalversion:all-srcs", "//staging/src/k8s.io/sample-apiserver/pkg/client/listers/wardle/internalversion:all-srcs",
"//staging/src/k8s.io/sample-apiserver/pkg/client/listers_generated/wardle/v1alpha1:all-srcs", "//staging/src/k8s.io/sample-apiserver/pkg/client/listers/wardle/v1alpha1:all-srcs",
"//staging/src/k8s.io/sample-apiserver/pkg/cmd/server:all-srcs", "//staging/src/k8s.io/sample-apiserver/pkg/cmd/server:all-srcs",
"//staging/src/k8s.io/sample-apiserver/pkg/registry:all-srcs", "//staging/src/k8s.io/sample-apiserver/pkg/registry:all-srcs",
], ],

View File

@ -0,0 +1,16 @@
/*
Copyright YEAR The Kubernetes sample-apiserver 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.
*/

View File

@ -18,58 +18,17 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
SCRIPT_PACKAGE=k8s.io/sample-apiserver SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/.. CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}
SCRIPT_BASE=${SCRIPT_ROOT}/../..
CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo k8s.io/code-generator)}
clientgen="${PWD}/client-gen-binary" # generate the code with:
listergen="${PWD}/lister-gen" # --output-base because this script should also be able to run inside the vendor dir of
informergen="${PWD}/informer-gen" # k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir
# Register function to be called on EXIT to remove generated binary. # instead of the $GOPATH directly. For normal projects this can be dropped.
function cleanup { ${CODEGEN_PKG}/generate-internal-groups.sh all \
rm -f "${clientgen:-}" k8s.io/sample-apiserver/pkg/client k8s.io/sample-apiserver/pkg/apis k8s.io/sample-apiserver/pkg/apis \
rm -f "${listergen:-}" wardle:v1alpha1 \
rm -f "${informergen:-}" --output-base "$(dirname ${BASH_SOURCE})/../../.."
}
trap cleanup EXIT
function generate_group() { # To use your own boilerplate text append:
local GROUP_NAME=$1 # --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt
local VERSION=$2
local CLIENT_PKG=${SCRIPT_PACKAGE}/pkg/client
local LISTERS_PKG=${CLIENT_PKG}/listers_generated
local INFORMERS_PKG=${CLIENT_PKG}/informers_generated
local APIS_PKG=${SCRIPT_PACKAGE}/pkg/apis
local INPUT_APIS=(
${GROUP_NAME}/
${GROUP_NAME}/${VERSION}
)
echo "Building client-gen"
go build -o "${clientgen}" ${CODEGEN_PKG}/cmd/client-gen
echo "generating clientset for group ${GROUP_NAME} and version ${VERSION} at ${SCRIPT_BASE}/${CLIENT_PKG}"
${clientgen} --input-base ${APIS_PKG} --input ${INPUT_APIS[@]} --clientset-path ${CLIENT_PKG}/clientset_generated --output-base=${SCRIPT_BASE}
${clientgen} --clientset-name="clientset" --input-base ${APIS_PKG} --input ${GROUP_NAME}/${VERSION} --clientset-path ${CLIENT_PKG}/clientset_generated --output-base=${SCRIPT_BASE}
echo "Building lister-gen"
go build -o "${listergen}" ${CODEGEN_PKG}/cmd/lister-gen
echo "generating listers for group ${GROUP_NAME} and version ${VERSION} at ${SCRIPT_BASE}/${LISTERS_PKG}"
${listergen} --input-dirs ${APIS_PKG}/${GROUP_NAME} --input-dirs ${APIS_PKG}/${GROUP_NAME}/${VERSION} --output-package ${LISTERS_PKG} --output-base ${SCRIPT_BASE}
echo "Building informer-gen"
go build -o "${informergen}" ${CODEGEN_PKG}/cmd/informer-gen
echo "generating informers for group ${GROUP_NAME} and version ${VERSION} at ${SCRIPT_BASE}/${INFORMERS_PKG}"
${informergen} \
--input-dirs ${APIS_PKG}/${GROUP_NAME} --input-dirs ${APIS_PKG}/${GROUP_NAME}/${VERSION} \
--versioned-clientset-package ${CLIENT_PKG}/clientset_generated/clientset \
--internal-clientset-package ${CLIENT_PKG}/clientset_generated/internalclientset \
--listers-package ${LISTERS_PKG} \
--output-package ${INFORMERS_PKG} \
--output-base ${SCRIPT_BASE}
}
generate_group wardle v1alpha1

View File

@ -16,8 +16,8 @@ go_library(
"//vendor/k8s.io/apiserver/pkg/admission:go_default_library", "//vendor/k8s.io/apiserver/pkg/admission:go_default_library",
"//vendor/k8s.io/sample-apiserver/pkg/admission/wardleinitializer:go_default_library", "//vendor/k8s.io/sample-apiserver/pkg/admission/wardleinitializer:go_default_library",
"//vendor/k8s.io/sample-apiserver/pkg/apis/wardle:go_default_library", "//vendor/k8s.io/sample-apiserver/pkg/apis/wardle:go_default_library",
"//vendor/k8s.io/sample-apiserver/pkg/client/informers_generated/internalversion:go_default_library", "//vendor/k8s.io/sample-apiserver/pkg/client/informers/internalversion:go_default_library",
"//vendor/k8s.io/sample-apiserver/pkg/client/listers_generated/wardle/internalversion:go_default_library", "//vendor/k8s.io/sample-apiserver/pkg/client/listers/wardle/internalversion:go_default_library",
], ],
) )
@ -33,8 +33,8 @@ go_test(
"//vendor/k8s.io/sample-apiserver/pkg/admission/plugin/banflunder:go_default_library", "//vendor/k8s.io/sample-apiserver/pkg/admission/plugin/banflunder:go_default_library",
"//vendor/k8s.io/sample-apiserver/pkg/admission/wardleinitializer:go_default_library", "//vendor/k8s.io/sample-apiserver/pkg/admission/wardleinitializer:go_default_library",
"//vendor/k8s.io/sample-apiserver/pkg/apis/wardle:go_default_library", "//vendor/k8s.io/sample-apiserver/pkg/apis/wardle:go_default_library",
"//vendor/k8s.io/sample-apiserver/pkg/client/clientset_generated/internalclientset/fake:go_default_library", "//vendor/k8s.io/sample-apiserver/pkg/client/clientset/internalversion/fake:go_default_library",
"//vendor/k8s.io/sample-apiserver/pkg/client/informers_generated/internalversion:go_default_library", "//vendor/k8s.io/sample-apiserver/pkg/client/informers/internalversion:go_default_library",
], ],
) )

View File

@ -26,8 +26,8 @@ import (
"k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/admission"
"k8s.io/sample-apiserver/pkg/admission/wardleinitializer" "k8s.io/sample-apiserver/pkg/admission/wardleinitializer"
"k8s.io/sample-apiserver/pkg/apis/wardle" "k8s.io/sample-apiserver/pkg/apis/wardle"
informers "k8s.io/sample-apiserver/pkg/client/informers_generated/internalversion" informers "k8s.io/sample-apiserver/pkg/client/informers/internalversion"
listers "k8s.io/sample-apiserver/pkg/client/listers_generated/wardle/internalversion" listers "k8s.io/sample-apiserver/pkg/client/listers/wardle/internalversion"
) )
// Register registers a plugin // Register registers a plugin

View File

@ -28,8 +28,8 @@ import (
"k8s.io/sample-apiserver/pkg/admission/plugin/banflunder" "k8s.io/sample-apiserver/pkg/admission/plugin/banflunder"
"k8s.io/sample-apiserver/pkg/admission/wardleinitializer" "k8s.io/sample-apiserver/pkg/admission/wardleinitializer"
"k8s.io/sample-apiserver/pkg/apis/wardle" "k8s.io/sample-apiserver/pkg/apis/wardle"
"k8s.io/sample-apiserver/pkg/client/clientset_generated/internalclientset/fake" "k8s.io/sample-apiserver/pkg/client/clientset/internalversion/fake"
informers "k8s.io/sample-apiserver/pkg/client/informers_generated/internalversion" informers "k8s.io/sample-apiserver/pkg/client/informers/internalversion"
) )
// TestBanfluderAdmissionPlugin tests various test cases against // TestBanfluderAdmissionPlugin tests various test cases against

View File

@ -14,7 +14,7 @@ go_library(
], ],
deps = [ deps = [
"//vendor/k8s.io/apiserver/pkg/admission:go_default_library", "//vendor/k8s.io/apiserver/pkg/admission:go_default_library",
"//vendor/k8s.io/sample-apiserver/pkg/client/informers_generated/internalversion:go_default_library", "//vendor/k8s.io/sample-apiserver/pkg/client/informers/internalversion:go_default_library",
], ],
) )
@ -24,8 +24,8 @@ go_test(
deps = [ deps = [
"//vendor/k8s.io/apiserver/pkg/admission:go_default_library", "//vendor/k8s.io/apiserver/pkg/admission:go_default_library",
"//vendor/k8s.io/sample-apiserver/pkg/admission/wardleinitializer:go_default_library", "//vendor/k8s.io/sample-apiserver/pkg/admission/wardleinitializer:go_default_library",
"//vendor/k8s.io/sample-apiserver/pkg/client/clientset_generated/internalclientset/fake:go_default_library", "//vendor/k8s.io/sample-apiserver/pkg/client/clientset/internalversion/fake:go_default_library",
"//vendor/k8s.io/sample-apiserver/pkg/client/informers_generated/internalversion:go_default_library", "//vendor/k8s.io/sample-apiserver/pkg/client/informers/internalversion:go_default_library",
], ],
) )

View File

@ -18,7 +18,7 @@ package wardleinitializer
import ( import (
"k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/admission"
informers "k8s.io/sample-apiserver/pkg/client/informers_generated/internalversion" informers "k8s.io/sample-apiserver/pkg/client/informers/internalversion"
) )
// WantsInternalWardleInformerFactory defines a function which sets InformerFactory for admission plugins that need it // WantsInternalWardleInformerFactory defines a function which sets InformerFactory for admission plugins that need it

View File

@ -18,7 +18,7 @@ package wardleinitializer
import ( import (
"k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/admission"
informers "k8s.io/sample-apiserver/pkg/client/informers_generated/internalversion" informers "k8s.io/sample-apiserver/pkg/client/informers/internalversion"
) )
type pluginInitializer struct { type pluginInitializer struct {

View File

@ -22,8 +22,8 @@ import (
"k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/admission"
"k8s.io/sample-apiserver/pkg/admission/wardleinitializer" "k8s.io/sample-apiserver/pkg/admission/wardleinitializer"
"k8s.io/sample-apiserver/pkg/client/clientset_generated/internalclientset/fake" "k8s.io/sample-apiserver/pkg/client/clientset/internalversion/fake"
informers "k8s.io/sample-apiserver/pkg/client/informers_generated/internalversion" informers "k8s.io/sample-apiserver/pkg/client/informers/internalversion"
) )
// TestWantsInternalWardleInformerFactory ensures that the informer factory is injected // TestWantsInternalWardleInformerFactory ensures that the informer factory is injected

View File

@ -13,6 +13,7 @@ go_library(
"types.go", "types.go",
"zz_generated.conversion.go", "zz_generated.conversion.go",
"zz_generated.deepcopy.go", "zz_generated.deepcopy.go",
"zz_generated.defaults.go",
], ],
deps = [ deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",

View File

@ -15,7 +15,7 @@ limitations under the License.
*/ */
// +k8s:deepcopy-gen=package,register // +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=k8s.io/kubernetes/vendor/k8s.io/sample-apiserver/pkg/apis/wardle // +k8s:conversion-gen=k8s.io/sample-apiserver/pkg/apis/wardle
// Package v1alpha1 is the v1alpha1 version of the API. // Package v1alpha1 is the v1alpha1 version of the API.
// +groupName=wardle.k8s.io // +groupName=wardle.k8s.io

Some files were not shown because too many files have changed in this diff Show More