1
0
Fork 0

chore: update docker and k8s

This commit is contained in:
Ludovic Fernandez 2019-08-05 18:24:03 +02:00 committed by Traefiker Bot
parent 2b5c7f9e91
commit c2d440a914
1283 changed files with 67741 additions and 27918 deletions

View file

@ -1,2 +1,2 @@
Sorry, we do not accept changes directly against this repository. Please see
Sorry, we do not accept changes directly against this repository. Please see
CONTRIBUTING.md for information on where and how to contribute instead.

View file

@ -2,6 +2,6 @@
Do not open pull requests directly against this repository, they will be ignored. Instead, please open pull requests against [kubernetes/kubernetes](https://git.k8s.io/kubernetes/). Please follow the same [contributing guide](https://git.k8s.io/kubernetes/CONTRIBUTING.md) you would follow for any other pull request made to kubernetes/kubernetes.
This repository is published from [kubernetes/kubernetes/staging/src/k8s.io/code-generator](https://git.k8s.io/kubernetes/staging/src/k8s.io/code-generator) by the [kubernetes publishing-bot](https://git.k8s.io/publishing-bot).
This repository is published from [kubernetes/kubernetes/staging/src/k8s.io/code-generator](https://git.k8s.io/kubernetes/staging/src/k8s.io/code-generator) by the [kubernetes publishing-bot](https://git.k8s.io/publishing-bot).
Please see [Staging Directory and Publishing](https://git.k8s.io/community/contributors/devel/staging.md) for more information
Please see [Staging Directory and Publishing](https://git.k8s.io/community/contributors/devel/sig-architecture/staging.md) for more information

View file

@ -1,3 +1,5 @@
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- lavalamp
- wojtek-t
@ -6,3 +8,6 @@ reviewers:
- lavalamp
- wojtek-t
- sttts
labels:
- sig/api-machinery
- area/code-generation

View file

@ -1,6 +1,6 @@
# code-generator
Golang code-generators used to implement [Kubernetes-style API types](https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md).
Golang code-generators used to implement [Kubernetes-style API types](https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md).
## Purpose

View file

@ -1,10 +1,10 @@
# Defined below are the security contacts for this repo.
#
# They are the contact point for the Product Security Team to reach out
# They are the contact point for the Product Security Committee to reach out
# to for triaging and handling of incoming issues.
#
# The below names agree to abide by the
# [Embargo Policy](https://github.com/kubernetes/sig-release/blob/master/security-release-process-documentation/security-release-process.md#embargo-policy)
# [Embargo Policy](https://git.k8s.io/security/private-distributors-list.md#embargo-policy)
# and will be removed and replaced if they violate that agreement.
#
# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE

View file

@ -14,19 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package generators
import (
"k8s.io/gengo/types"
)
// extractTag gets the comment-tags for the key. If the tag did not exist, it
// returns the empty string.
func extractTag(key string, lines []string) string {
val, present := types.ExtractCommentTags("+", lines)[key]
if !present || len(val) < 1 {
return ""
}
return val[0]
}
// +k8s:deepcopy-gen=package
// +k8s:defaulter-gen=TypeMeta
// +groupName=example.crd.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.crd.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 the given scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&TestType{},
&TestTypeList{},
)
scheme.AddKnownTypes(SchemeGroupVersion,
&metav1.Status{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}

View file

@ -0,0 +1,74 @@
/*
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
}
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ClusterTestTypeList struct {
metav1.TypeMeta
metav1.ListMeta
Items []ClusterTestType
}
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +genclient:method=GetScale,verb=get,subresource=scale,result=k8s.io/kubernetes/pkg/apis/autoscaling.Scale
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=k8s.io/kubernetes/pkg/apis/autoscaling.Scale,result=k8s.io/kubernetes/pkg/apis/autoscaling.Scale
type ClusterTestType struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// +optional
Status ClusterTestTypeStatus `json:"status,omitempty"`
}
type ClusterTestTypeStatus struct {
Blah string
}

View file

@ -0,0 +1,177 @@
// +build !ignore_autogenerated
/*
Copyright 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.
*/
// Code generated by deepcopy-gen. DO NOT EDIT.
package v1
import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterTestType) DeepCopyInto(out *ClusterTestType) {
*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 ClusterTestType.
func (in *ClusterTestType) DeepCopy() *ClusterTestType {
if in == nil {
return nil
}
out := new(ClusterTestType)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ClusterTestType) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterTestTypeList) DeepCopyInto(out *ClusterTestTypeList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ClusterTestType, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterTestTypeList.
func (in *ClusterTestTypeList) DeepCopy() *ClusterTestTypeList {
if in == nil {
return nil
}
out := new(ClusterTestTypeList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ClusterTestTypeList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterTestTypeStatus) DeepCopyInto(out *ClusterTestTypeStatus) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterTestTypeStatus.
func (in *ClusterTestTypeStatus) DeepCopy() *ClusterTestTypeStatus {
if in == nil {
return nil
}
out := new(ClusterTestTypeStatus)
in.DeepCopyInto(out)
return out
}
// 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
}
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
in.ListMeta.DeepCopyInto(&out.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
}
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

@ -1,5 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2016 The Kubernetes Authors.
Copyright 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.
@ -14,20 +16,17 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package generators
// Code generated by defaulter-gen. DO NOT EDIT.
package v1
import (
"github.com/golang/glog"
"k8s.io/gengo/types"
runtime "k8s.io/apimachinery/pkg/runtime"
)
// extractBoolTagOrDie gets the comment-tags for the key and asserts that, if
// it exists, the value is boolean. If the tag did not exist, it returns
// false.
func extractBoolTagOrDie(key string, lines []string) bool {
val, err := types.ExtractSingleBoolCommentTag("+", key, false, lines)
if err != nil {
glog.Fatal(err)
}
return val
// RegisterDefaults adds defaulters functions to the given scheme.
// Public to allow building arbitrary schemes.
// All generated defaulters are covering - they call all nested defaulters.
func RegisterDefaults(scheme *runtime.Scheme) error {
return nil
}

View file

@ -0,0 +1,90 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
package versioned
import (
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/MixedCase/clientset/versioned/typed/example/v1"
)
type Interface interface {
Discovery() discovery.DiscoveryInterface
ExampleV1() 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
}
// 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 {
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

@ -0,0 +1,20 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated clientset.
package versioned

View file

@ -0,0 +1,82 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
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/MixedCase/clientset/versioned"
examplev1 "k8s.io/code-generator/_examples/MixedCase/clientset/versioned/typed/example/v1"
fakeexamplev1 "k8s.io/code-generator/_examples/MixedCase/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)
}
}
cs := &Clientset{tracker: o}
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
cs.AddReactor("*", "*", testing.ObjectReaction(o))
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
gvr := action.GetResource()
ns := action.GetNamespace()
watch, err := o.Watch(gvr, ns)
if err != nil {
return false, nil, err
}
return true, watch, nil
})
return cs
}
// 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
tracker testing.ObjectTracker
}
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return c.discovery
}
func (c *Clientset) Tracker() testing.ObjectTracker {
return c.tracker
}
var _ clientset.Interface = &Clientset{}
// ExampleV1 retrieves the ExampleV1Client
func (c *Clientset) ExampleV1() examplev1.ExampleV1Interface {
return &fakeexamplev1.FakeExampleV1{Fake: &c.Fake}
}

View file

@ -0,0 +1,20 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated fake clientset.
package fake

View file

@ -0,0 +1,56 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
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"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
examplev1 "k8s.io/code-generator/_examples/MixedCase/apis/example/v1"
)
var scheme = runtime.NewScheme()
var codecs = serializer.NewCodecFactory(scheme)
var parameterCodec = runtime.NewParameterCodec(scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
examplev1.AddToScheme,
}
// 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/kubernetes/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.
var AddToScheme = localSchemeBuilder.AddToScheme
func init() {
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
utilruntime.Must(AddToScheme(scheme))
}

View file

@ -0,0 +1,20 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package contains the scheme of the automatically generated clientset.
package scheme

View file

@ -0,0 +1,56 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
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"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
examplev1 "k8s.io/code-generator/_examples/MixedCase/apis/example/v1"
)
var Scheme = runtime.NewScheme()
var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
examplev1.AddToScheme,
}
// 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/kubernetes/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.
var AddToScheme = localSchemeBuilder.AddToScheme
func init() {
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
utilruntime.Must(AddToScheme(Scheme))
}

View file

@ -0,0 +1,210 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1
import (
"time"
metav1 "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/MixedCase/apis/example/v1"
scheme "k8s.io/code-generator/_examples/MixedCase/clientset/versioned/scheme"
autoscaling "k8s.io/kubernetes/pkg/apis/autoscaling"
)
// ClusterTestTypesGetter has a method to return a ClusterTestTypeInterface.
// A group's client should implement this interface.
type ClusterTestTypesGetter interface {
ClusterTestTypes() ClusterTestTypeInterface
}
// ClusterTestTypeInterface has methods to work with ClusterTestType resources.
type ClusterTestTypeInterface interface {
Create(*v1.ClusterTestType) (*v1.ClusterTestType, error)
Update(*v1.ClusterTestType) (*v1.ClusterTestType, error)
UpdateStatus(*v1.ClusterTestType) (*v1.ClusterTestType, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error
Get(name string, options metav1.GetOptions) (*v1.ClusterTestType, error)
List(opts metav1.ListOptions) (*v1.ClusterTestTypeList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ClusterTestType, err error)
GetScale(clusterTestTypeName string, options metav1.GetOptions) (*autoscaling.Scale, error)
UpdateScale(clusterTestTypeName string, scale *autoscaling.Scale) (*autoscaling.Scale, error)
ClusterTestTypeExpansion
}
// clusterTestTypes implements ClusterTestTypeInterface
type clusterTestTypes struct {
client rest.Interface
}
// newClusterTestTypes returns a ClusterTestTypes
func newClusterTestTypes(c *ExampleV1Client) *clusterTestTypes {
return &clusterTestTypes{
client: c.RESTClient(),
}
}
// Get takes name of the clusterTestType, and returns the corresponding clusterTestType object, and an error if there is any.
func (c *clusterTestTypes) Get(name string, options metav1.GetOptions) (result *v1.ClusterTestType, err error) {
result = &v1.ClusterTestType{}
err = c.client.Get().
Resource("clustertesttypes").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of ClusterTestTypes that match those selectors.
func (c *clusterTestTypes) List(opts metav1.ListOptions) (result *v1.ClusterTestTypeList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1.ClusterTestTypeList{}
err = c.client.Get().
Resource("clustertesttypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested clusterTestTypes.
func (c *clusterTestTypes) Watch(opts metav1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Resource("clustertesttypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
// Create takes the representation of a clusterTestType and creates it. Returns the server's representation of the clusterTestType, and an error, if there is any.
func (c *clusterTestTypes) Create(clusterTestType *v1.ClusterTestType) (result *v1.ClusterTestType, err error) {
result = &v1.ClusterTestType{}
err = c.client.Post().
Resource("clustertesttypes").
Body(clusterTestType).
Do().
Into(result)
return
}
// Update takes the representation of a clusterTestType and updates it. Returns the server's representation of the clusterTestType, and an error, if there is any.
func (c *clusterTestTypes) Update(clusterTestType *v1.ClusterTestType) (result *v1.ClusterTestType, err error) {
result = &v1.ClusterTestType{}
err = c.client.Put().
Resource("clustertesttypes").
Name(clusterTestType.Name).
Body(clusterTestType).
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 *clusterTestTypes) UpdateStatus(clusterTestType *v1.ClusterTestType) (result *v1.ClusterTestType, err error) {
result = &v1.ClusterTestType{}
err = c.client.Put().
Resource("clustertesttypes").
Name(clusterTestType.Name).
SubResource("status").
Body(clusterTestType).
Do().
Into(result)
return
}
// Delete takes name of the clusterTestType and deletes it. Returns an error if one occurs.
func (c *clusterTestTypes) Delete(name string, options *metav1.DeleteOptions) error {
return c.client.Delete().
Resource("clustertesttypes").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *clusterTestTypes) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Resource("clustertesttypes").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched clusterTestType.
func (c *clusterTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ClusterTestType, err error) {
result = &v1.ClusterTestType{}
err = c.client.Patch(pt).
Resource("clustertesttypes").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}
// GetScale takes name of the clusterTestType, and returns the corresponding autoscaling.Scale object, and an error if there is any.
func (c *clusterTestTypes) GetScale(clusterTestTypeName string, options metav1.GetOptions) (result *autoscaling.Scale, err error) {
result = &autoscaling.Scale{}
err = c.client.Get().
Resource("clustertesttypes").
Name(clusterTestTypeName).
SubResource("scale").
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// UpdateScale takes the top resource name and the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
func (c *clusterTestTypes) UpdateScale(clusterTestTypeName string, scale *autoscaling.Scale) (result *autoscaling.Scale, err error) {
result = &autoscaling.Scale{}
err = c.client.Put().
Resource("clustertesttypes").
Name(clusterTestTypeName).
SubResource("scale").
Body(scale).
Do().
Into(result)
return
}

View file

@ -0,0 +1,20 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated typed clients.
package v1

View file

@ -0,0 +1,94 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1
import (
rest "k8s.io/client-go/rest"
v1 "k8s.io/code-generator/_examples/MixedCase/apis/example/v1"
"k8s.io/code-generator/_examples/MixedCase/clientset/versioned/scheme"
)
type ExampleV1Interface interface {
RESTClient() rest.Interface
ClusterTestTypesGetter
TestTypesGetter
}
// ExampleV1Client is used to interact with features provided by the example.crd.code-generator.k8s.io group.
type ExampleV1Client struct {
restClient rest.Interface
}
func (c *ExampleV1Client) ClusterTestTypes() ClusterTestTypeInterface {
return newClusterTestTypes(c)
}
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 = scheme.Codecs.WithoutConversion()
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

@ -0,0 +1,20 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
// Package fake has the automatically generated clients.
package fake

View file

@ -0,0 +1,152 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
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"
examplev1 "k8s.io/code-generator/_examples/MixedCase/apis/example/v1"
autoscaling "k8s.io/kubernetes/pkg/apis/autoscaling"
)
// FakeClusterTestTypes implements ClusterTestTypeInterface
type FakeClusterTestTypes struct {
Fake *FakeExampleV1
}
var clustertesttypesResource = schema.GroupVersionResource{Group: "example.crd.code-generator.k8s.io", Version: "v1", Resource: "clustertesttypes"}
var clustertesttypesKind = schema.GroupVersionKind{Group: "example.crd.code-generator.k8s.io", Version: "v1", Kind: "ClusterTestType"}
// Get takes name of the clusterTestType, and returns the corresponding clusterTestType object, and an error if there is any.
func (c *FakeClusterTestTypes) Get(name string, options v1.GetOptions) (result *examplev1.ClusterTestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(clustertesttypesResource, name), &examplev1.ClusterTestType{})
if obj == nil {
return nil, err
}
return obj.(*examplev1.ClusterTestType), err
}
// List takes label and field selectors, and returns the list of ClusterTestTypes that match those selectors.
func (c *FakeClusterTestTypes) List(opts v1.ListOptions) (result *examplev1.ClusterTestTypeList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(clustertesttypesResource, clustertesttypesKind, opts), &examplev1.ClusterTestTypeList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &examplev1.ClusterTestTypeList{ListMeta: obj.(*examplev1.ClusterTestTypeList).ListMeta}
for _, item := range obj.(*examplev1.ClusterTestTypeList).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 clusterTestTypes.
func (c *FakeClusterTestTypes) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(clustertesttypesResource, opts))
}
// Create takes the representation of a clusterTestType and creates it. Returns the server's representation of the clusterTestType, and an error, if there is any.
func (c *FakeClusterTestTypes) Create(clusterTestType *examplev1.ClusterTestType) (result *examplev1.ClusterTestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(clustertesttypesResource, clusterTestType), &examplev1.ClusterTestType{})
if obj == nil {
return nil, err
}
return obj.(*examplev1.ClusterTestType), err
}
// Update takes the representation of a clusterTestType and updates it. Returns the server's representation of the clusterTestType, and an error, if there is any.
func (c *FakeClusterTestTypes) Update(clusterTestType *examplev1.ClusterTestType) (result *examplev1.ClusterTestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(clustertesttypesResource, clusterTestType), &examplev1.ClusterTestType{})
if obj == nil {
return nil, err
}
return obj.(*examplev1.ClusterTestType), 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 *FakeClusterTestTypes) UpdateStatus(clusterTestType *examplev1.ClusterTestType) (*examplev1.ClusterTestType, error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateSubresourceAction(clustertesttypesResource, "status", clusterTestType), &examplev1.ClusterTestType{})
if obj == nil {
return nil, err
}
return obj.(*examplev1.ClusterTestType), err
}
// Delete takes name of the clusterTestType and deletes it. Returns an error if one occurs.
func (c *FakeClusterTestTypes) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteAction(clustertesttypesResource, name), &examplev1.ClusterTestType{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeClusterTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(clustertesttypesResource, listOptions)
_, err := c.Fake.Invokes(action, &examplev1.ClusterTestTypeList{})
return err
}
// Patch applies the patch and returns the patched clusterTestType.
func (c *FakeClusterTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *examplev1.ClusterTestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(clustertesttypesResource, name, pt, data, subresources...), &examplev1.ClusterTestType{})
if obj == nil {
return nil, err
}
return obj.(*examplev1.ClusterTestType), err
}
// GetScale takes name of the clusterTestType, and returns the corresponding scale object, and an error if there is any.
func (c *FakeClusterTestTypes) GetScale(clusterTestTypeName string, options v1.GetOptions) (result *autoscaling.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetSubresourceAction(clustertesttypesResource, "scale", clusterTestTypeName), &autoscaling.Scale{})
if obj == nil {
return nil, err
}
return obj.(*autoscaling.Scale), err
}
// UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
func (c *FakeClusterTestTypes) UpdateScale(clusterTestTypeName string, scale *autoscaling.Scale) (result *autoscaling.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateSubresourceAction(clustertesttypesResource, "scale", scale), &autoscaling.Scale{})
if obj == nil {
return nil, err
}
return obj.(*autoscaling.Scale), err
}

View file

@ -0,0 +1,44 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
v1 "k8s.io/code-generator/_examples/MixedCase/clientset/versioned/typed/example/v1"
)
type FakeExampleV1 struct {
*testing.Fake
}
func (c *FakeExampleV1) ClusterTestTypes() v1.ClusterTestTypeInterface {
return &FakeClusterTestTypes{c}
}
func (c *FakeExampleV1) TestTypes(namespace string) v1.TestTypeInterface {
return &FakeTestTypes{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeExampleV1) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

View file

@ -0,0 +1,140 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
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"
examplev1 "k8s.io/code-generator/_examples/MixedCase/apis/example/v1"
)
// FakeTestTypes implements TestTypeInterface
type FakeTestTypes struct {
Fake *FakeExampleV1
ns string
}
var testtypesResource = schema.GroupVersionResource{Group: "example.crd.code-generator.k8s.io", Version: "v1", Resource: "testtypes"}
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.
func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *examplev1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*examplev1.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 *examplev1.TestTypeList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &examplev1.TestTypeList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &examplev1.TestTypeList{ListMeta: obj.(*examplev1.TestTypeList).ListMeta}
for _, item := range obj.(*examplev1.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 *examplev1.TestType) (result *examplev1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*examplev1.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 *examplev1.TestType) (result *examplev1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*examplev1.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 *examplev1.TestType) (*examplev1.TestType, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*examplev1.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), &examplev1.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, &examplev1.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 *examplev1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*examplev1.TestType), err
}

View file

@ -1,5 +1,5 @@
/*
Copyright 2016 The Kubernetes Authors.
Copyright 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.
@ -14,20 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package generators
// Code generated by client-gen. DO NOT EDIT.
import (
"github.com/golang/glog"
"k8s.io/gengo/types"
)
package v1
// extractBoolTagOrDie gets the comment-tags for the key and asserts that, if
// it exists, the value is boolean. If the tag did not exist, it returns
// false.
func extractBoolTagOrDie(key string, lines []string) bool {
val, err := types.ExtractSingleBoolCommentTag("+", key, false, lines)
if err != nil {
glog.Fatal(err)
}
return val
}
type ClusterTestTypeExpansion interface{}
type TestTypeExpansion interface{}

View file

@ -0,0 +1,191 @@
/*
Copyright 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.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1
import (
"time"
metav1 "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/MixedCase/apis/example/v1"
scheme "k8s.io/code-generator/_examples/MixedCase/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 *metav1.DeleteOptions) error
DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error
Get(name string, options metav1.GetOptions) (*v1.TestType, error)
List(opts metav1.ListOptions) (*v1.TestTypeList, error)
Watch(opts metav1.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 metav1.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 metav1.ListOptions) (result *v1.TestTypeList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1.TestTypeList{}
err = c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested testTypes.
func (c *testTypes) Watch(opts metav1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
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 *metav1.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 *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched testType.
func (c *testTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error) {
result = &v1.TestType{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("testtypes").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

View file

@ -0,0 +1,46 @@
/*
Copyright 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.
*/
// Code generated by informer-gen. DO NOT EDIT.
package example
import (
v1 "k8s.io/code-generator/_examples/MixedCase/informers/externalversions/example/v1"
internalinterfaces "k8s.io/code-generator/_examples/MixedCase/informers/externalversions/internalinterfaces"
)
// Interface provides access to each of this group's versions.
type Interface interface {
// V1 provides access to shared informers for resources in V1.
V1() v1.Interface
}
type group struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// V1 returns a new v1.Interface.
func (g *group) V1() v1.Interface {
return v1.New(g.factory, g.namespace, g.tweakListOptions)
}

View file

@ -0,0 +1,88 @@
/*
Copyright 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.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1
import (
time "time"
metav1 "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"
examplev1 "k8s.io/code-generator/_examples/MixedCase/apis/example/v1"
versioned "k8s.io/code-generator/_examples/MixedCase/clientset/versioned"
internalinterfaces "k8s.io/code-generator/_examples/MixedCase/informers/externalversions/internalinterfaces"
v1 "k8s.io/code-generator/_examples/MixedCase/listers/example/v1"
)
// ClusterTestTypeInformer provides access to a shared informer and lister for
// ClusterTestTypes.
type ClusterTestTypeInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.ClusterTestTypeLister
}
type clusterTestTypeInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// NewClusterTestTypeInformer constructs a new informer for ClusterTestType 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 NewClusterTestTypeInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredClusterTestTypeInformer(client, resyncPeriod, indexers, nil)
}
// NewFilteredClusterTestTypeInformer constructs a new informer for ClusterTestType 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 NewFilteredClusterTestTypeInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ExampleV1().ClusterTestTypes().List(options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ExampleV1().ClusterTestTypes().Watch(options)
},
},
&examplev1.ClusterTestType{},
resyncPeriod,
indexers,
)
}
func (f *clusterTestTypeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredClusterTestTypeInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *clusterTestTypeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&examplev1.ClusterTestType{}, f.defaultInformer)
}
func (f *clusterTestTypeInformer) Lister() v1.ClusterTestTypeLister {
return v1.NewClusterTestTypeLister(f.Informer().GetIndexer())
}

View file

@ -0,0 +1,52 @@
/*
Copyright 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.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1
import (
internalinterfaces "k8s.io/code-generator/_examples/MixedCase/informers/externalversions/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// ClusterTestTypes returns a ClusterTestTypeInformer.
ClusterTestTypes() ClusterTestTypeInformer
// TestTypes returns a TestTypeInformer.
TestTypes() TestTypeInformer
}
type version struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// ClusterTestTypes returns a ClusterTestTypeInformer.
func (v *version) ClusterTestTypes() ClusterTestTypeInformer {
return &clusterTestTypeInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
}
// TestTypes returns a TestTypeInformer.
func (v *version) TestTypes() TestTypeInformer {
return &testTypeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}

View file

@ -0,0 +1,89 @@
/*
Copyright 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.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1
import (
time "time"
metav1 "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"
examplev1 "k8s.io/code-generator/_examples/MixedCase/apis/example/v1"
versioned "k8s.io/code-generator/_examples/MixedCase/clientset/versioned"
internalinterfaces "k8s.io/code-generator/_examples/MixedCase/informers/externalversions/internalinterfaces"
v1 "k8s.io/code-generator/_examples/MixedCase/listers/example/v1"
)
// TestTypeInformer provides access to a shared informer and lister for
// TestTypes.
type TestTypeInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.TestTypeLister
}
type testTypeInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewTestTypeInformer constructs a new informer for TestType type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredTestTypeInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredTestTypeInformer constructs a new informer for TestType type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ExampleV1().TestTypes(namespace).List(options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ExampleV1().TestTypes(namespace).Watch(options)
},
},
&examplev1.TestType{},
resyncPeriod,
indexers,
)
}
func (f *testTypeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredTestTypeInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *testTypeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&examplev1.TestType{}, f.defaultInformer)
}
func (f *testTypeInformer) Lister() v1.TestTypeLister {
return v1.NewTestTypeLister(f.Informer().GetIndexer())
}

View file

@ -0,0 +1,180 @@
/*
Copyright 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.
*/
// Code generated by informer-gen. DO NOT EDIT.
package externalversions
import (
reflect "reflect"
sync "sync"
time "time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
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/MixedCase/clientset/versioned"
example "k8s.io/code-generator/_examples/MixedCase/informers/externalversions/example"
internalinterfaces "k8s.io/code-generator/_examples/MixedCase/informers/externalversions/internalinterfaces"
)
// SharedInformerOption defines the functional option type for SharedInformerFactory.
type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory
type sharedInformerFactory struct {
client versioned.Interface
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
lock sync.Mutex
defaultResync time.Duration
customResync map[reflect.Type]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
}
// WithCustomResyncConfig sets a custom resync period for the specified informer types.
func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
for k, v := range resyncConfig {
factory.customResync[reflect.TypeOf(k)] = v
}
return factory
}
}
// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory.
func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.tweakListOptions = tweakListOptions
return factory
}
}
// WithNamespace limits the SharedInformerFactory to the specified namespace.
func WithNamespace(namespace string) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.namespace = namespace
return factory
}
}
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces.
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync)
}
// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory.
// Listers obtained via this SharedInformerFactory will be subject to the same filters
// as specified here.
// Deprecated: Please use NewSharedInformerFactoryWithOptions instead
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions))
}
// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options.
func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory {
factory := &sharedInformerFactory{
client: client,
namespace: v1.NamespaceAll,
defaultResync: defaultResync,
informers: make(map[reflect.Type]cache.SharedIndexInformer),
startedInformers: make(map[reflect.Type]bool),
customResync: make(map[reflect.Type]time.Duration),
}
// Apply all options
for _, opt := range options {
factory = opt(factory)
}
return factory
}
// 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
}
resyncPeriod, exists := f.customResync[informerType]
if !exists {
resyncPeriod = f.defaultResync
}
informer = newFunc(f.client, resyncPeriod)
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, f.namespace, f.tweakListOptions)
}

View file

@ -0,0 +1,64 @@
/*
Copyright 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.
*/
// Code generated by informer-gen. DO NOT EDIT.
package externalversions
import (
"fmt"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
v1 "k8s.io/code-generator/_examples/MixedCase/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.crd.code-generator.k8s.io, Version=v1
case v1.SchemeGroupVersion.WithResource("clustertesttypes"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Example().V1().ClusterTestTypes().Informer()}, nil
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

@ -0,0 +1,40 @@
/*
Copyright 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.
*/
// Code generated by informer-gen. DO NOT EDIT.
package internalinterfaces
import (
time "time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache"
versioned "k8s.io/code-generator/_examples/MixedCase/clientset/versioned"
)
// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer.
type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
type SharedInformerFactory interface {
Start(stopCh <-chan struct{})
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
}
// TweakListOptionsFunc is a function that transforms a v1.ListOptions.
type TweakListOptionsFunc func(*v1.ListOptions)

View file

@ -0,0 +1,65 @@
/*
Copyright 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.
*/
// Code generated by lister-gen. DO NOT EDIT.
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/MixedCase/apis/example/v1"
)
// ClusterTestTypeLister helps list ClusterTestTypes.
type ClusterTestTypeLister interface {
// List lists all ClusterTestTypes in the indexer.
List(selector labels.Selector) (ret []*v1.ClusterTestType, err error)
// Get retrieves the ClusterTestType from the index for a given name.
Get(name string) (*v1.ClusterTestType, error)
ClusterTestTypeListerExpansion
}
// clusterTestTypeLister implements the ClusterTestTypeLister interface.
type clusterTestTypeLister struct {
indexer cache.Indexer
}
// NewClusterTestTypeLister returns a new ClusterTestTypeLister.
func NewClusterTestTypeLister(indexer cache.Indexer) ClusterTestTypeLister {
return &clusterTestTypeLister{indexer: indexer}
}
// List lists all ClusterTestTypes in the indexer.
func (s *clusterTestTypeLister) List(selector labels.Selector) (ret []*v1.ClusterTestType, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1.ClusterTestType))
})
return ret, err
}
// Get retrieves the ClusterTestType from the index for a given name.
func (s *clusterTestTypeLister) Get(name string) (*v1.ClusterTestType, error) {
obj, exists, err := s.indexer.GetByKey(name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1.Resource("clustertesttype"), name)
}
return obj.(*v1.ClusterTestType), nil
}

View file

@ -0,0 +1,31 @@
/*
Copyright 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.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v1
// ClusterTestTypeListerExpansion allows custom methods to be added to
// ClusterTestTypeLister.
type ClusterTestTypeListerExpansion interface{}
// TestTypeListerExpansion allows custom methods to be added to
// TestTypeLister.
type TestTypeListerExpansion interface{}
// TestTypeNamespaceListerExpansion allows custom methods to be added to
// TestTypeNamespaceLister.
type TestTypeNamespaceListerExpansion interface{}

View file

@ -0,0 +1,94 @@
/*
Copyright 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.
*/
// Code generated by lister-gen. DO NOT EDIT.
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/MixedCase/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

@ -16,4 +16,5 @@ limitations under the License.
// +k8s:deepcopy-gen=package
// +groupName=example.apiserver.code-generator.k8s.io
package example // import "k8s.io/code-generator/_examples/apiserver/apis/example"

View file

@ -18,4 +18,5 @@ limitations under the License.
// +k8s:defaulter-gen=TypeMeta
// +k8s:conversion-gen=k8s.io/code-generator/_examples/apiserver/apis/example
// +groupName=example.apiserver.code-generator.k8s.io
package v1

View file

@ -34,15 +34,38 @@ func init() {
// 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 RegisterConversions(s *runtime.Scheme) error {
if err := s.AddGeneratedConversionFunc((*TestType)(nil), (*example.TestType)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1_TestType_To_example_TestType(a.(*TestType), b.(*example.TestType), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*example.TestType)(nil), (*TestType)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_example_TestType_To_v1_TestType(a.(*example.TestType), b.(*TestType), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*TestTypeList)(nil), (*example.TestTypeList)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1_TestTypeList_To_example_TestTypeList(a.(*TestTypeList), b.(*example.TestTypeList), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*example.TestTypeList)(nil), (*TestTypeList)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_example_TestTypeList_To_v1_TestTypeList(a.(*example.TestTypeList), b.(*TestTypeList), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*TestTypeStatus)(nil), (*example.TestTypeStatus)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1_TestTypeStatus_To_example_TestTypeStatus(a.(*TestTypeStatus), b.(*example.TestTypeStatus), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*example.TestTypeStatus)(nil), (*TestTypeStatus)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_example_TestTypeStatus_To_v1_TestTypeStatus(a.(*example.TestTypeStatus), b.(*TestTypeStatus), scope)
}); err != nil {
return err
}
return nil
}
func autoConvert_v1_TestType_To_example_TestType(in *TestType, out *example.TestType, s conversion.Scope) error {

View file

@ -55,7 +55,7 @@ func (in *TestType) DeepCopyObject() runtime.Object {
func (in *TestTypeList) DeepCopyInto(out *TestTypeList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]TestType, len(*in))

View file

@ -55,7 +55,7 @@ func (in *TestType) DeepCopyObject() runtime.Object {
func (in *TestTypeList) DeepCopyInto(out *TestTypeList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]TestType, len(*in))

View file

@ -17,4 +17,5 @@ limitations under the License.
// +k8s:deepcopy-gen=package
// +groupName=example.test.apiserver.code-generator.k8s.io
// +groupGoName=SecondExample
package example2 // import "k8s.io/code-generator/_examples/apiserver/apis/example2"

View file

@ -19,4 +19,5 @@ limitations under the License.
// +groupName=example.test.apiserver.code-generator.k8s.io
// +k8s:conversion-gen=k8s.io/code-generator/_examples/apiserver/apis/example2
// +groupGoName=SecondExample
package v1

View file

@ -34,15 +34,38 @@ func init() {
// RegisterConversions adds conversion functions to the given scheme.
// Public to allow building arbitrary schemes.
func RegisterConversions(scheme *runtime.Scheme) error {
return scheme.AddGeneratedConversionFuncs(
Convert_v1_TestType_To_example2_TestType,
Convert_example2_TestType_To_v1_TestType,
Convert_v1_TestTypeList_To_example2_TestTypeList,
Convert_example2_TestTypeList_To_v1_TestTypeList,
Convert_v1_TestTypeStatus_To_example2_TestTypeStatus,
Convert_example2_TestTypeStatus_To_v1_TestTypeStatus,
)
func RegisterConversions(s *runtime.Scheme) error {
if err := s.AddGeneratedConversionFunc((*TestType)(nil), (*example2.TestType)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1_TestType_To_example2_TestType(a.(*TestType), b.(*example2.TestType), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*example2.TestType)(nil), (*TestType)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_example2_TestType_To_v1_TestType(a.(*example2.TestType), b.(*TestType), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*TestTypeList)(nil), (*example2.TestTypeList)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1_TestTypeList_To_example2_TestTypeList(a.(*TestTypeList), b.(*example2.TestTypeList), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*example2.TestTypeList)(nil), (*TestTypeList)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_example2_TestTypeList_To_v1_TestTypeList(a.(*example2.TestTypeList), b.(*TestTypeList), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*TestTypeStatus)(nil), (*example2.TestTypeStatus)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1_TestTypeStatus_To_example2_TestTypeStatus(a.(*TestTypeStatus), b.(*example2.TestTypeStatus), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*example2.TestTypeStatus)(nil), (*TestTypeStatus)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_example2_TestTypeStatus_To_v1_TestTypeStatus(a.(*example2.TestTypeStatus), b.(*TestTypeStatus), scope)
}); err != nil {
return err
}
return nil
}
func autoConvert_v1_TestType_To_example2_TestType(in *TestType, out *example2.TestType, s conversion.Scope) error {

View file

@ -55,7 +55,7 @@ func (in *TestType) DeepCopyObject() runtime.Object {
func (in *TestTypeList) DeepCopyInto(out *TestTypeList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]TestType, len(*in))

View file

@ -55,7 +55,7 @@ func (in *TestType) DeepCopyObject() runtime.Object {
func (in *TestTypeList) DeepCopyInto(out *TestTypeList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]TestType, len(*in))

View file

@ -43,7 +43,7 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
}
}
cs := &Clientset{}
cs := &Clientset{tracker: o}
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
cs.AddReactor("*", "*", testing.ObjectReaction(o))
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
@ -65,12 +65,17 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
type Clientset struct {
testing.Fake
discovery *fakediscovery.FakeDiscovery
tracker testing.ObjectTracker
}
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return c.discovery
}
func (c *Clientset) Tracker() testing.ObjectTracker {
return c.tracker
}
var _ clientset.Interface = &Clientset{}
// Example retrieves the ExampleClient

View file

@ -23,6 +23,7 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
exampleinternalversion "k8s.io/code-generator/_examples/apiserver/apis/example"
secondexampleinternalversion "k8s.io/code-generator/_examples/apiserver/apis/example2"
)
@ -30,10 +31,9 @@ import (
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)
var localSchemeBuilder = runtime.SchemeBuilder{
exampleinternalversion.AddToScheme,
secondexampleinternalversion.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
@ -46,11 +46,13 @@ func init() {
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
func AddToScheme(scheme *runtime.Scheme) {
exampleinternalversion.AddToScheme(scheme)
secondexampleinternalversion.AddToScheme(scheme)
var AddToScheme = localSchemeBuilder.AddToScheme
func init() {
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
utilruntime.Must(AddToScheme(scheme))
}

View file

@ -131,7 +131,7 @@ func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions
// Patch applies the patch and returns the patched testType.
func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example.TestType{})
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &example.TestType{})
if obj == nil {
return nil, err

View file

@ -19,6 +19,8 @@ limitations under the License.
package internalversion
import (
"time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
@ -76,11 +78,16 @@ func (c *testTypes) Get(name string, options v1.GetOptions) (result *example.Tes
// List takes label and field selectors, and returns the list of TestTypes that match those selectors.
func (c *testTypes) List(opts v1.ListOptions) (result *example.TestTypeList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &example.TestTypeList{}
err = c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
@ -88,11 +95,16 @@ func (c *testTypes) List(opts v1.ListOptions) (result *example.TestTypeList, err
// Watch returns a watch.Interface that watches the requested testTypes.
func (c *testTypes) Watch(opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
@ -150,10 +162,15 @@ func (c *testTypes) Delete(name string, options *v1.DeleteOptions) error {
// DeleteCollection deletes a collection of objects.
func (c *testTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()

View file

@ -131,7 +131,7 @@ func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions
// Patch applies the patch and returns the patched testType.
func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example2.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example2.TestType{})
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &example2.TestType{})
if obj == nil {
return nil, err

View file

@ -19,6 +19,8 @@ limitations under the License.
package internalversion
import (
"time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
@ -76,11 +78,16 @@ func (c *testTypes) Get(name string, options v1.GetOptions) (result *example2.Te
// List takes label and field selectors, and returns the list of TestTypes that match those selectors.
func (c *testTypes) List(opts v1.ListOptions) (result *example2.TestTypeList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &example2.TestTypeList{}
err = c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
@ -88,11 +95,16 @@ func (c *testTypes) List(opts v1.ListOptions) (result *example2.TestTypeList, er
// Watch returns a watch.Interface that watches the requested testTypes.
func (c *testTypes) Watch(opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
@ -150,10 +162,15 @@ func (c *testTypes) Delete(name string, options *v1.DeleteOptions) error {
// DeleteCollection deletes a collection of objects.
func (c *testTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()

View file

@ -29,11 +29,7 @@ import (
type Interface interface {
Discovery() discovery.DiscoveryInterface
ExampleV1() examplev1.ExampleV1Interface
// Deprecated: please explicitly pick a version if possible.
Example() examplev1.ExampleV1Interface
SecondExampleV1() secondexamplev1.SecondExampleV1Interface
// Deprecated: please explicitly pick a version if possible.
SecondExample() secondexamplev1.SecondExampleV1Interface
}
// Clientset contains the clients for groups. Each group has exactly one
@ -49,23 +45,11 @@ 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
}
// SecondExampleV1 retrieves the SecondExampleV1Client
func (c *Clientset) SecondExampleV1() secondexamplev1.SecondExampleV1Interface {
return c.secondExampleV1
}
// Deprecated: SecondExample retrieves the default version of SecondExampleClient.
// Please explicitly pick a version.
func (c *Clientset) SecondExample() secondexamplev1.SecondExampleV1Interface {
return c.secondExampleV1
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil {

View file

@ -43,7 +43,7 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
}
}
cs := &Clientset{}
cs := &Clientset{tracker: o}
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
cs.AddReactor("*", "*", testing.ObjectReaction(o))
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
@ -65,12 +65,17 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
type Clientset struct {
testing.Fake
discovery *fakediscovery.FakeDiscovery
tracker testing.ObjectTracker
}
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return c.discovery
}
func (c *Clientset) Tracker() testing.ObjectTracker {
return c.tracker
}
var _ clientset.Interface = &Clientset{}
// ExampleV1 retrieves the ExampleV1Client
@ -78,17 +83,7 @@ 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}
}
// SecondExampleV1 retrieves the SecondExampleV1Client
func (c *Clientset) SecondExampleV1() secondexamplev1.SecondExampleV1Interface {
return &fakesecondexamplev1.FakeSecondExampleV1{Fake: &c.Fake}
}
// SecondExample retrieves the SecondExampleV1Client
func (c *Clientset) SecondExample() secondexamplev1.SecondExampleV1Interface {
return &fakesecondexamplev1.FakeSecondExampleV1{Fake: &c.Fake}
}

View file

@ -23,6 +23,7 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
examplev1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1"
secondexamplev1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
)
@ -30,10 +31,9 @@ import (
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)
var localSchemeBuilder = runtime.SchemeBuilder{
examplev1.AddToScheme,
secondexamplev1.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
@ -46,11 +46,13 @@ func init() {
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
func AddToScheme(scheme *runtime.Scheme) {
examplev1.AddToScheme(scheme)
secondexamplev1.AddToScheme(scheme)
var AddToScheme = localSchemeBuilder.AddToScheme
func init() {
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
utilruntime.Must(AddToScheme(scheme))
}

View file

@ -23,6 +23,7 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
examplev1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1"
secondexamplev1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
)
@ -30,10 +31,9 @@ import (
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)
var localSchemeBuilder = runtime.SchemeBuilder{
examplev1.AddToScheme,
secondexamplev1.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
@ -46,11 +46,13 @@ func init() {
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
func AddToScheme(scheme *runtime.Scheme) {
examplev1.AddToScheme(scheme)
secondexamplev1.AddToScheme(scheme)
var AddToScheme = localSchemeBuilder.AddToScheme
func init() {
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
utilruntime.Must(AddToScheme(Scheme))
}

View file

@ -19,7 +19,6 @@ 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"
@ -71,7 +70,7 @@ func setConfigDefaults(config *rest.Config) error {
gv := v1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()

View file

@ -25,7 +25,7 @@ import (
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"
examplev1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1"
)
// FakeTestTypes implements TestTypeInterface
@ -39,20 +39,20 @@ var testtypesResource = schema.GroupVersionResource{Group: "example.apiserver.co
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) {
func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *examplev1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example_v1.TestType{})
Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.TestType), err
return obj.(*examplev1.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) {
func (c *FakeTestTypes) List(opts v1.ListOptions) (result *examplev1.TestTypeList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example_v1.TestTypeList{})
Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &examplev1.TestTypeList{})
if obj == nil {
return nil, err
@ -62,8 +62,8 @@ func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example_v1.TestTypeLi
if label == nil {
label = labels.Everything()
}
list := &example_v1.TestTypeList{ListMeta: obj.(*example_v1.TestTypeList).ListMeta}
for _, item := range obj.(*example_v1.TestTypeList).Items {
list := &examplev1.TestTypeList{ListMeta: obj.(*examplev1.TestTypeList).ListMeta}
for _, item := range obj.(*examplev1.TestTypeList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
@ -79,43 +79,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.
func (c *FakeTestTypes) Create(testType *example_v1.TestType) (result *example_v1.TestType, err error) {
func (c *FakeTestTypes) Create(testType *examplev1.TestType) (result *examplev1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example_v1.TestType{})
Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.TestType), err
return obj.(*examplev1.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) {
func (c *FakeTestTypes) Update(testType *examplev1.TestType) (result *examplev1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example_v1.TestType{})
Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.TestType), err
return obj.(*examplev1.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) {
func (c *FakeTestTypes) UpdateStatus(testType *examplev1.TestType) (*examplev1.TestType, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example_v1.TestType{})
Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.TestType), err
return obj.(*examplev1.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{})
Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &examplev1.TestType{})
return err
}
@ -124,17 +124,17 @@ func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error {
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{})
_, err := c.Fake.Invokes(action, &examplev1.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) {
func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *examplev1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example_v1.TestType{})
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.TestType), err
return obj.(*examplev1.TestType), err
}

View file

@ -19,7 +19,9 @@ limitations under the License.
package v1
import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"time"
metav1 "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"
@ -38,11 +40,11 @@ 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)
Delete(name string, options *metav1.DeleteOptions) error
DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error
Get(name string, options metav1.GetOptions) (*v1.TestType, error)
List(opts metav1.ListOptions) (*v1.TestTypeList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error)
TestTypeExpansion
}
@ -62,7 +64,7 @@ func newTestTypes(c *ExampleV1Client, namespace string) *testTypes {
}
// 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) {
func (c *testTypes) Get(name string, options metav1.GetOptions) (result *v1.TestType, err error) {
result = &v1.TestType{}
err = c.client.Get().
Namespace(c.ns).
@ -75,24 +77,34 @@ func (c *testTypes) Get(name string, options meta_v1.GetOptions) (result *v1.Tes
}
// 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) {
func (c *testTypes) List(opts metav1.ListOptions) (result *v1.TestTypeList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1.TestTypeList{}
err = c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
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) {
func (c *testTypes) Watch(opts metav1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
@ -138,7 +150,7 @@ func (c *testTypes) UpdateStatus(testType *v1.TestType) (result *v1.TestType, er
}
// 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 {
func (c *testTypes) Delete(name string, options *metav1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
@ -149,11 +161,16 @@ func (c *testTypes) Delete(name string, options *meta_v1.DeleteOptions) error {
}
// DeleteCollection deletes a collection of objects.
func (c *testTypes) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error {
func (c *testTypes) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()

View file

@ -19,7 +19,6 @@ limitations under the License.
package v1
import (
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
rest "k8s.io/client-go/rest"
v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
"k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme"
@ -71,7 +70,7 @@ func setConfigDefaults(config *rest.Config) error {
gv := v1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()

View file

@ -25,7 +25,7 @@ import (
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
example2_v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
example2v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
)
// FakeTestTypes implements TestTypeInterface
@ -39,20 +39,20 @@ var testtypesResource = schema.GroupVersionResource{Group: "example.test.apiserv
var testtypesKind = schema.GroupVersionKind{Group: "example.test.apiserver.code-generator.k8s.io", Version: "v1", Kind: "TestType"}
// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any.
func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example2_v1.TestType, err error) {
func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example2v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example2_v1.TestType{})
Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example2v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
return obj.(*example2v1.TestType), err
}
// List takes label and field selectors, and returns the list of TestTypes that match those selectors.
func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example2_v1.TestTypeList, err error) {
func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example2v1.TestTypeList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example2_v1.TestTypeList{})
Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example2v1.TestTypeList{})
if obj == nil {
return nil, err
@ -62,8 +62,8 @@ func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example2_v1.TestTypeL
if label == nil {
label = labels.Everything()
}
list := &example2_v1.TestTypeList{ListMeta: obj.(*example2_v1.TestTypeList).ListMeta}
for _, item := range obj.(*example2_v1.TestTypeList).Items {
list := &example2v1.TestTypeList{ListMeta: obj.(*example2v1.TestTypeList).ListMeta}
for _, item := range obj.(*example2v1.TestTypeList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
@ -79,43 +79,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.
func (c *FakeTestTypes) Create(testType *example2_v1.TestType) (result *example2_v1.TestType, err error) {
func (c *FakeTestTypes) Create(testType *example2v1.TestType) (result *example2v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example2_v1.TestType{})
Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example2v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
return obj.(*example2v1.TestType), err
}
// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any.
func (c *FakeTestTypes) Update(testType *example2_v1.TestType) (result *example2_v1.TestType, err error) {
func (c *FakeTestTypes) Update(testType *example2v1.TestType) (result *example2v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example2_v1.TestType{})
Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example2v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
return obj.(*example2v1.TestType), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeTestTypes) UpdateStatus(testType *example2_v1.TestType) (*example2_v1.TestType, error) {
func (c *FakeTestTypes) UpdateStatus(testType *example2v1.TestType) (*example2v1.TestType, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example2_v1.TestType{})
Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example2v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
return obj.(*example2v1.TestType), err
}
// Delete takes name of the testType and deletes it. Returns an error if one occurs.
func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &example2_v1.TestType{})
Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &example2v1.TestType{})
return err
}
@ -124,17 +124,17 @@ func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error {
func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &example2_v1.TestTypeList{})
_, err := c.Fake.Invokes(action, &example2v1.TestTypeList{})
return err
}
// Patch applies the patch and returns the patched testType.
func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example2_v1.TestType, err error) {
func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example2v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example2_v1.TestType{})
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &example2v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
return obj.(*example2v1.TestType), err
}

View file

@ -19,7 +19,9 @@ limitations under the License.
package v1
import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"time"
metav1 "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"
@ -38,11 +40,11 @@ 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)
Delete(name string, options *metav1.DeleteOptions) error
DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error
Get(name string, options metav1.GetOptions) (*v1.TestType, error)
List(opts metav1.ListOptions) (*v1.TestTypeList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error)
TestTypeExpansion
}
@ -62,7 +64,7 @@ func newTestTypes(c *SecondExampleV1Client, namespace string) *testTypes {
}
// 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) {
func (c *testTypes) Get(name string, options metav1.GetOptions) (result *v1.TestType, err error) {
result = &v1.TestType{}
err = c.client.Get().
Namespace(c.ns).
@ -75,24 +77,34 @@ func (c *testTypes) Get(name string, options meta_v1.GetOptions) (result *v1.Tes
}
// 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) {
func (c *testTypes) List(opts metav1.ListOptions) (result *v1.TestTypeList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1.TestTypeList{}
err = c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
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) {
func (c *testTypes) Watch(opts metav1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
@ -138,7 +150,7 @@ func (c *testTypes) UpdateStatus(testType *v1.TestType) (result *v1.TestType, er
}
// 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 {
func (c *testTypes) Delete(name string, options *metav1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
@ -149,11 +161,16 @@ func (c *testTypes) Delete(name string, options *meta_v1.DeleteOptions) error {
}
// DeleteCollection deletes a collection of objects.
func (c *testTypes) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error {
func (c *testTypes) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()

View file

@ -21,11 +21,11 @@ package v1
import (
time "time"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "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"
examplev1 "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"
@ -57,20 +57,20 @@ func NewTestTypeInformer(client versioned.Interface, namespace string, resyncPer
func NewFilteredTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ExampleV1().TestTypes(namespace).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ExampleV1().TestTypes(namespace).Watch(options)
},
},
&example_v1.TestType{},
&examplev1.TestType{},
resyncPeriod,
indexers,
)
@ -81,7 +81,7 @@ func (f *testTypeInformer) defaultInformer(client versioned.Interface, resyncPer
}
func (f *testTypeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&example_v1.TestType{}, f.defaultInformer)
return f.factory.InformerFor(&examplev1.TestType{}, f.defaultInformer)
}
func (f *testTypeInformer) Lister() v1.TestTypeLister {

View file

@ -21,11 +21,11 @@ package v1
import (
time "time"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
example2_v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
example2v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1"
versioned "k8s.io/code-generator/_examples/apiserver/clientset/versioned"
internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces"
v1 "k8s.io/code-generator/_examples/apiserver/listers/example2/v1"
@ -57,20 +57,20 @@ func NewTestTypeInformer(client versioned.Interface, namespace string, resyncPer
func NewFilteredTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.SecondExampleV1().TestTypes(namespace).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.SecondExampleV1().TestTypes(namespace).Watch(options)
},
},
&example2_v1.TestType{},
&example2v1.TestType{},
resyncPeriod,
indexers,
)
@ -81,7 +81,7 @@ func (f *testTypeInformer) defaultInformer(client versioned.Interface, resyncPer
}
func (f *testTypeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&example2_v1.TestType{}, f.defaultInformer)
return f.factory.InformerFor(&example2v1.TestType{}, f.defaultInformer)
}
func (f *testTypeInformer) Lister() v1.TestTypeLister {

View file

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

View file

@ -27,6 +27,7 @@ import (
versioned "k8s.io/code-generator/_examples/apiserver/clientset/versioned"
)
// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer.
type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
@ -35,4 +36,5 @@ type SharedInformerFactory interface {
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
}
// TweakListOptionsFunc is a function that transforms a v1.ListOptions.
type TweakListOptionsFunc func(*v1.ListOptions)

View file

@ -26,7 +26,7 @@ import (
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
example "k8s.io/code-generator/_examples/apiserver/apis/example"
clientset_internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion"
clientsetinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion"
internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces"
internalversion "k8s.io/code-generator/_examples/apiserver/listers/example/internalversion"
)
@ -47,14 +47,14 @@ type testTypeInformer struct {
// NewTestTypeInformer constructs a new informer for TestType type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewTestTypeInformer(client clientset_internalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
func NewTestTypeInformer(client clientsetinternalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredTestTypeInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredTestTypeInformer constructs a new informer for TestType type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredTestTypeInformer(client clientset_internalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
func NewFilteredTestTypeInformer(client clientsetinternalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
@ -76,7 +76,7 @@ func NewFilteredTestTypeInformer(client clientset_internalversion.Interface, nam
)
}
func (f *testTypeInformer) defaultInformer(client clientset_internalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
func (f *testTypeInformer) defaultInformer(client clientsetinternalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredTestTypeInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}

View file

@ -26,7 +26,7 @@ import (
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
example2 "k8s.io/code-generator/_examples/apiserver/apis/example2"
clientset_internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion"
clientsetinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion"
internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces"
internalversion "k8s.io/code-generator/_examples/apiserver/listers/example2/internalversion"
)
@ -47,14 +47,14 @@ type testTypeInformer struct {
// NewTestTypeInformer constructs a new informer for TestType type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewTestTypeInformer(client clientset_internalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
func NewTestTypeInformer(client clientsetinternalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredTestTypeInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredTestTypeInformer constructs a new informer for TestType type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredTestTypeInformer(client clientset_internalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
func NewFilteredTestTypeInformer(client clientsetinternalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
@ -76,7 +76,7 @@ func NewFilteredTestTypeInformer(client clientset_internalversion.Interface, nam
)
}
func (f *testTypeInformer) defaultInformer(client clientset_internalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
func (f *testTypeInformer) defaultInformer(client clientsetinternalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredTestTypeInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}

View file

@ -27,6 +27,7 @@ import (
internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion"
)
// NewInformerFunc takes internalversion.Interface and time.Duration to return a SharedIndexInformer.
type NewInformerFunc func(internalversion.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
@ -35,4 +36,5 @@ type SharedInformerFactory interface {
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
}
// TweakListOptionsFunc is a function that transforms a v1.ListOptions.
type TweakListOptionsFunc func(*v1.ListOptions)

View file

@ -17,4 +17,5 @@ limitations under the License.
// +k8s:deepcopy-gen=package
// +k8s:defaulter-gen=TypeMeta
// +groupName=example.crd.code-generator.k8s.io
package v1

View file

@ -55,7 +55,7 @@ func (in *ClusterTestType) DeepCopyObject() runtime.Object {
func (in *ClusterTestTypeList) DeepCopyInto(out *ClusterTestTypeList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ClusterTestType, len(*in))
@ -131,7 +131,7 @@ func (in *TestType) DeepCopyObject() runtime.Object {
func (in *TestTypeList) DeepCopyInto(out *TestTypeList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]TestType, len(*in))

View file

@ -18,4 +18,5 @@ limitations under the License.
// +k8s:defaulter-gen=TypeMeta
// +groupName=example.test.crd.code-generator.k8s.io
// +groupGoName=SecondExample
package v1

View file

@ -55,7 +55,7 @@ func (in *TestType) DeepCopyObject() runtime.Object {
func (in *TestTypeList) DeepCopyInto(out *TestTypeList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]TestType, len(*in))

View file

@ -29,11 +29,7 @@ import (
type Interface interface {
Discovery() discovery.DiscoveryInterface
ExampleV1() examplev1.ExampleV1Interface
// Deprecated: please explicitly pick a version if possible.
Example() examplev1.ExampleV1Interface
SecondExampleV1() secondexamplev1.SecondExampleV1Interface
// Deprecated: please explicitly pick a version if possible.
SecondExample() secondexamplev1.SecondExampleV1Interface
}
// Clientset contains the clients for groups. Each group has exactly one
@ -49,23 +45,11 @@ 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
}
// SecondExampleV1 retrieves the SecondExampleV1Client
func (c *Clientset) SecondExampleV1() secondexamplev1.SecondExampleV1Interface {
return c.secondExampleV1
}
// Deprecated: SecondExample retrieves the default version of SecondExampleClient.
// Please explicitly pick a version.
func (c *Clientset) SecondExample() secondexamplev1.SecondExampleV1Interface {
return c.secondExampleV1
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil {

View file

@ -43,7 +43,7 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
}
}
cs := &Clientset{}
cs := &Clientset{tracker: o}
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
cs.AddReactor("*", "*", testing.ObjectReaction(o))
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
@ -65,12 +65,17 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
type Clientset struct {
testing.Fake
discovery *fakediscovery.FakeDiscovery
tracker testing.ObjectTracker
}
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return c.discovery
}
func (c *Clientset) Tracker() testing.ObjectTracker {
return c.tracker
}
var _ clientset.Interface = &Clientset{}
// ExampleV1 retrieves the ExampleV1Client
@ -78,17 +83,7 @@ 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}
}
// SecondExampleV1 retrieves the SecondExampleV1Client
func (c *Clientset) SecondExampleV1() secondexamplev1.SecondExampleV1Interface {
return &fakesecondexamplev1.FakeSecondExampleV1{Fake: &c.Fake}
}
// SecondExample retrieves the SecondExampleV1Client
func (c *Clientset) SecondExample() secondexamplev1.SecondExampleV1Interface {
return &fakesecondexamplev1.FakeSecondExampleV1{Fake: &c.Fake}
}

View file

@ -23,6 +23,7 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
examplev1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
secondexamplev1 "k8s.io/code-generator/_examples/crd/apis/example2/v1"
)
@ -30,10 +31,9 @@ import (
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)
var localSchemeBuilder = runtime.SchemeBuilder{
examplev1.AddToScheme,
secondexamplev1.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
@ -46,11 +46,13 @@ func init() {
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
func AddToScheme(scheme *runtime.Scheme) {
examplev1.AddToScheme(scheme)
secondexamplev1.AddToScheme(scheme)
var AddToScheme = localSchemeBuilder.AddToScheme
func init() {
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
utilruntime.Must(AddToScheme(scheme))
}

View file

@ -23,6 +23,7 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
examplev1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
secondexamplev1 "k8s.io/code-generator/_examples/crd/apis/example2/v1"
)
@ -30,10 +31,9 @@ import (
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)
var localSchemeBuilder = runtime.SchemeBuilder{
examplev1.AddToScheme,
secondexamplev1.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
@ -46,11 +46,13 @@ func init() {
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
func AddToScheme(scheme *runtime.Scheme) {
examplev1.AddToScheme(scheme)
secondexamplev1.AddToScheme(scheme)
var AddToScheme = localSchemeBuilder.AddToScheme
func init() {
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
utilruntime.Must(AddToScheme(Scheme))
}

View file

@ -19,7 +19,9 @@ limitations under the License.
package v1
import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"time"
metav1 "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"
@ -39,13 +41,13 @@ type ClusterTestTypeInterface interface {
Create(*v1.ClusterTestType) (*v1.ClusterTestType, error)
Update(*v1.ClusterTestType) (*v1.ClusterTestType, error)
UpdateStatus(*v1.ClusterTestType) (*v1.ClusterTestType, 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.ClusterTestType, error)
List(opts meta_v1.ListOptions) (*v1.ClusterTestTypeList, error)
Watch(opts meta_v1.ListOptions) (watch.Interface, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error
Get(name string, options metav1.GetOptions) (*v1.ClusterTestType, error)
List(opts metav1.ListOptions) (*v1.ClusterTestTypeList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ClusterTestType, err error)
GetScale(clusterTestTypeName string, options meta_v1.GetOptions) (*autoscaling.Scale, error)
GetScale(clusterTestTypeName string, options metav1.GetOptions) (*autoscaling.Scale, error)
UpdateScale(clusterTestTypeName string, scale *autoscaling.Scale) (*autoscaling.Scale, error)
ClusterTestTypeExpansion
@ -64,7 +66,7 @@ func newClusterTestTypes(c *ExampleV1Client) *clusterTestTypes {
}
// Get takes name of the clusterTestType, and returns the corresponding clusterTestType object, and an error if there is any.
func (c *clusterTestTypes) Get(name string, options meta_v1.GetOptions) (result *v1.ClusterTestType, err error) {
func (c *clusterTestTypes) Get(name string, options metav1.GetOptions) (result *v1.ClusterTestType, err error) {
result = &v1.ClusterTestType{}
err = c.client.Get().
Resource("clustertesttypes").
@ -76,22 +78,32 @@ func (c *clusterTestTypes) Get(name string, options meta_v1.GetOptions) (result
}
// List takes label and field selectors, and returns the list of ClusterTestTypes that match those selectors.
func (c *clusterTestTypes) List(opts meta_v1.ListOptions) (result *v1.ClusterTestTypeList, err error) {
func (c *clusterTestTypes) List(opts metav1.ListOptions) (result *v1.ClusterTestTypeList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1.ClusterTestTypeList{}
err = c.client.Get().
Resource("clustertesttypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested clusterTestTypes.
func (c *clusterTestTypes) Watch(opts meta_v1.ListOptions) (watch.Interface, error) {
func (c *clusterTestTypes) Watch(opts metav1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Resource("clustertesttypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
@ -134,7 +146,7 @@ func (c *clusterTestTypes) UpdateStatus(clusterTestType *v1.ClusterTestType) (re
}
// Delete takes name of the clusterTestType and deletes it. Returns an error if one occurs.
func (c *clusterTestTypes) Delete(name string, options *meta_v1.DeleteOptions) error {
func (c *clusterTestTypes) Delete(name string, options *metav1.DeleteOptions) error {
return c.client.Delete().
Resource("clustertesttypes").
Name(name).
@ -144,10 +156,15 @@ func (c *clusterTestTypes) Delete(name string, options *meta_v1.DeleteOptions) e
}
// DeleteCollection deletes a collection of objects.
func (c *clusterTestTypes) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error {
func (c *clusterTestTypes) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Resource("clustertesttypes").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()
@ -167,7 +184,7 @@ func (c *clusterTestTypes) Patch(name string, pt types.PatchType, data []byte, s
}
// GetScale takes name of the clusterTestType, and returns the corresponding autoscaling.Scale object, and an error if there is any.
func (c *clusterTestTypes) GetScale(clusterTestTypeName string, options meta_v1.GetOptions) (result *autoscaling.Scale, err error) {
func (c *clusterTestTypes) GetScale(clusterTestTypeName string, options metav1.GetOptions) (result *autoscaling.Scale, err error) {
result = &autoscaling.Scale{}
err = c.client.Get().
Resource("clustertesttypes").

View file

@ -19,7 +19,6 @@ 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/crd/apis/example/v1"
"k8s.io/code-generator/_examples/crd/clientset/versioned/scheme"
@ -76,7 +75,7 @@ func setConfigDefaults(config *rest.Config) error {
gv := v1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()

View file

@ -25,7 +25,7 @@ import (
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/crd/apis/example/v1"
examplev1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
autoscaling "k8s.io/kubernetes/pkg/apis/autoscaling"
)
@ -39,19 +39,19 @@ var clustertesttypesResource = schema.GroupVersionResource{Group: "example.crd.c
var clustertesttypesKind = schema.GroupVersionKind{Group: "example.crd.code-generator.k8s.io", Version: "v1", Kind: "ClusterTestType"}
// Get takes name of the clusterTestType, and returns the corresponding clusterTestType object, and an error if there is any.
func (c *FakeClusterTestTypes) Get(name string, options v1.GetOptions) (result *example_v1.ClusterTestType, err error) {
func (c *FakeClusterTestTypes) Get(name string, options v1.GetOptions) (result *examplev1.ClusterTestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(clustertesttypesResource, name), &example_v1.ClusterTestType{})
Invokes(testing.NewRootGetAction(clustertesttypesResource, name), &examplev1.ClusterTestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.ClusterTestType), err
return obj.(*examplev1.ClusterTestType), err
}
// List takes label and field selectors, and returns the list of ClusterTestTypes that match those selectors.
func (c *FakeClusterTestTypes) List(opts v1.ListOptions) (result *example_v1.ClusterTestTypeList, err error) {
func (c *FakeClusterTestTypes) List(opts v1.ListOptions) (result *examplev1.ClusterTestTypeList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(clustertesttypesResource, clustertesttypesKind, opts), &example_v1.ClusterTestTypeList{})
Invokes(testing.NewRootListAction(clustertesttypesResource, clustertesttypesKind, opts), &examplev1.ClusterTestTypeList{})
if obj == nil {
return nil, err
}
@ -60,8 +60,8 @@ func (c *FakeClusterTestTypes) List(opts v1.ListOptions) (result *example_v1.Clu
if label == nil {
label = labels.Everything()
}
list := &example_v1.ClusterTestTypeList{ListMeta: obj.(*example_v1.ClusterTestTypeList).ListMeta}
for _, item := range obj.(*example_v1.ClusterTestTypeList).Items {
list := &examplev1.ClusterTestTypeList{ListMeta: obj.(*examplev1.ClusterTestTypeList).ListMeta}
for _, item := range obj.(*examplev1.ClusterTestTypeList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
@ -76,40 +76,40 @@ func (c *FakeClusterTestTypes) Watch(opts v1.ListOptions) (watch.Interface, erro
}
// Create takes the representation of a clusterTestType and creates it. Returns the server's representation of the clusterTestType, and an error, if there is any.
func (c *FakeClusterTestTypes) Create(clusterTestType *example_v1.ClusterTestType) (result *example_v1.ClusterTestType, err error) {
func (c *FakeClusterTestTypes) Create(clusterTestType *examplev1.ClusterTestType) (result *examplev1.ClusterTestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(clustertesttypesResource, clusterTestType), &example_v1.ClusterTestType{})
Invokes(testing.NewRootCreateAction(clustertesttypesResource, clusterTestType), &examplev1.ClusterTestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.ClusterTestType), err
return obj.(*examplev1.ClusterTestType), err
}
// Update takes the representation of a clusterTestType and updates it. Returns the server's representation of the clusterTestType, and an error, if there is any.
func (c *FakeClusterTestTypes) Update(clusterTestType *example_v1.ClusterTestType) (result *example_v1.ClusterTestType, err error) {
func (c *FakeClusterTestTypes) Update(clusterTestType *examplev1.ClusterTestType) (result *examplev1.ClusterTestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(clustertesttypesResource, clusterTestType), &example_v1.ClusterTestType{})
Invokes(testing.NewRootUpdateAction(clustertesttypesResource, clusterTestType), &examplev1.ClusterTestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.ClusterTestType), err
return obj.(*examplev1.ClusterTestType), 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 *FakeClusterTestTypes) UpdateStatus(clusterTestType *example_v1.ClusterTestType) (*example_v1.ClusterTestType, error) {
func (c *FakeClusterTestTypes) UpdateStatus(clusterTestType *examplev1.ClusterTestType) (*examplev1.ClusterTestType, error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateSubresourceAction(clustertesttypesResource, "status", clusterTestType), &example_v1.ClusterTestType{})
Invokes(testing.NewRootUpdateSubresourceAction(clustertesttypesResource, "status", clusterTestType), &examplev1.ClusterTestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.ClusterTestType), err
return obj.(*examplev1.ClusterTestType), err
}
// Delete takes name of the clusterTestType and deletes it. Returns an error if one occurs.
func (c *FakeClusterTestTypes) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteAction(clustertesttypesResource, name), &example_v1.ClusterTestType{})
Invokes(testing.NewRootDeleteAction(clustertesttypesResource, name), &examplev1.ClusterTestType{})
return err
}
@ -117,24 +117,24 @@ func (c *FakeClusterTestTypes) Delete(name string, options *v1.DeleteOptions) er
func (c *FakeClusterTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(clustertesttypesResource, listOptions)
_, err := c.Fake.Invokes(action, &example_v1.ClusterTestTypeList{})
_, err := c.Fake.Invokes(action, &examplev1.ClusterTestTypeList{})
return err
}
// Patch applies the patch and returns the patched clusterTestType.
func (c *FakeClusterTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example_v1.ClusterTestType, err error) {
func (c *FakeClusterTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *examplev1.ClusterTestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(clustertesttypesResource, name, data, subresources...), &example_v1.ClusterTestType{})
Invokes(testing.NewRootPatchSubresourceAction(clustertesttypesResource, name, pt, data, subresources...), &examplev1.ClusterTestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.ClusterTestType), err
return obj.(*examplev1.ClusterTestType), err
}
// GetScale takes name of the clusterTestType, and returns the corresponding scale object, and an error if there is any.
func (c *FakeClusterTestTypes) GetScale(clusterTestTypeName string, options v1.GetOptions) (result *autoscaling.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetSubresourceAction(clustertesttypesResource, clusterTestTypeName), &autoscaling.Scale{})
Invokes(testing.NewRootGetSubresourceAction(clustertesttypesResource, "scale", clusterTestTypeName), &autoscaling.Scale{})
if obj == nil {
return nil, err
}

View file

@ -25,7 +25,7 @@ import (
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/crd/apis/example/v1"
examplev1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
)
// FakeTestTypes implements TestTypeInterface
@ -39,20 +39,20 @@ var testtypesResource = schema.GroupVersionResource{Group: "example.crd.code-gen
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.
func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example_v1.TestType, err error) {
func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *examplev1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example_v1.TestType{})
Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.TestType), err
return obj.(*examplev1.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) {
func (c *FakeTestTypes) List(opts v1.ListOptions) (result *examplev1.TestTypeList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example_v1.TestTypeList{})
Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &examplev1.TestTypeList{})
if obj == nil {
return nil, err
@ -62,8 +62,8 @@ func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example_v1.TestTypeLi
if label == nil {
label = labels.Everything()
}
list := &example_v1.TestTypeList{ListMeta: obj.(*example_v1.TestTypeList).ListMeta}
for _, item := range obj.(*example_v1.TestTypeList).Items {
list := &examplev1.TestTypeList{ListMeta: obj.(*examplev1.TestTypeList).ListMeta}
for _, item := range obj.(*examplev1.TestTypeList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
@ -79,43 +79,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.
func (c *FakeTestTypes) Create(testType *example_v1.TestType) (result *example_v1.TestType, err error) {
func (c *FakeTestTypes) Create(testType *examplev1.TestType) (result *examplev1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example_v1.TestType{})
Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.TestType), err
return obj.(*examplev1.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) {
func (c *FakeTestTypes) Update(testType *examplev1.TestType) (result *examplev1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example_v1.TestType{})
Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.TestType), err
return obj.(*examplev1.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) {
func (c *FakeTestTypes) UpdateStatus(testType *examplev1.TestType) (*examplev1.TestType, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example_v1.TestType{})
Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.TestType), err
return obj.(*examplev1.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{})
Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &examplev1.TestType{})
return err
}
@ -124,17 +124,17 @@ func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error {
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{})
_, err := c.Fake.Invokes(action, &examplev1.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) {
func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *examplev1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example_v1.TestType{})
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &examplev1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example_v1.TestType), err
return obj.(*examplev1.TestType), err
}

View file

@ -19,7 +19,9 @@ limitations under the License.
package v1
import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"time"
metav1 "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"
@ -38,11 +40,11 @@ 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)
Delete(name string, options *metav1.DeleteOptions) error
DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error
Get(name string, options metav1.GetOptions) (*v1.TestType, error)
List(opts metav1.ListOptions) (*v1.TestTypeList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error)
TestTypeExpansion
}
@ -62,7 +64,7 @@ func newTestTypes(c *ExampleV1Client, namespace string) *testTypes {
}
// 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) {
func (c *testTypes) Get(name string, options metav1.GetOptions) (result *v1.TestType, err error) {
result = &v1.TestType{}
err = c.client.Get().
Namespace(c.ns).
@ -75,24 +77,34 @@ func (c *testTypes) Get(name string, options meta_v1.GetOptions) (result *v1.Tes
}
// 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) {
func (c *testTypes) List(opts metav1.ListOptions) (result *v1.TestTypeList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1.TestTypeList{}
err = c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
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) {
func (c *testTypes) Watch(opts metav1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
@ -138,7 +150,7 @@ func (c *testTypes) UpdateStatus(testType *v1.TestType) (result *v1.TestType, er
}
// 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 {
func (c *testTypes) Delete(name string, options *metav1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
@ -149,11 +161,16 @@ func (c *testTypes) Delete(name string, options *meta_v1.DeleteOptions) error {
}
// DeleteCollection deletes a collection of objects.
func (c *testTypes) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error {
func (c *testTypes) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()

View file

@ -19,7 +19,6 @@ 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/crd/apis/example2/v1"
"k8s.io/code-generator/_examples/crd/clientset/versioned/scheme"
@ -71,7 +70,7 @@ func setConfigDefaults(config *rest.Config) error {
gv := v1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()

View file

@ -25,7 +25,7 @@ import (
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
example2_v1 "k8s.io/code-generator/_examples/crd/apis/example2/v1"
example2v1 "k8s.io/code-generator/_examples/crd/apis/example2/v1"
)
// FakeTestTypes implements TestTypeInterface
@ -39,20 +39,20 @@ var testtypesResource = schema.GroupVersionResource{Group: "example.test.crd.cod
var testtypesKind = schema.GroupVersionKind{Group: "example.test.crd.code-generator.k8s.io", Version: "v1", Kind: "TestType"}
// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any.
func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example2_v1.TestType, err error) {
func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example2v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example2_v1.TestType{})
Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example2v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
return obj.(*example2v1.TestType), err
}
// List takes label and field selectors, and returns the list of TestTypes that match those selectors.
func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example2_v1.TestTypeList, err error) {
func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example2v1.TestTypeList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example2_v1.TestTypeList{})
Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example2v1.TestTypeList{})
if obj == nil {
return nil, err
@ -62,8 +62,8 @@ func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example2_v1.TestTypeL
if label == nil {
label = labels.Everything()
}
list := &example2_v1.TestTypeList{ListMeta: obj.(*example2_v1.TestTypeList).ListMeta}
for _, item := range obj.(*example2_v1.TestTypeList).Items {
list := &example2v1.TestTypeList{ListMeta: obj.(*example2v1.TestTypeList).ListMeta}
for _, item := range obj.(*example2v1.TestTypeList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
@ -79,43 +79,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.
func (c *FakeTestTypes) Create(testType *example2_v1.TestType) (result *example2_v1.TestType, err error) {
func (c *FakeTestTypes) Create(testType *example2v1.TestType) (result *example2v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example2_v1.TestType{})
Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example2v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
return obj.(*example2v1.TestType), err
}
// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any.
func (c *FakeTestTypes) Update(testType *example2_v1.TestType) (result *example2_v1.TestType, err error) {
func (c *FakeTestTypes) Update(testType *example2v1.TestType) (result *example2v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example2_v1.TestType{})
Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example2v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
return obj.(*example2v1.TestType), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeTestTypes) UpdateStatus(testType *example2_v1.TestType) (*example2_v1.TestType, error) {
func (c *FakeTestTypes) UpdateStatus(testType *example2v1.TestType) (*example2v1.TestType, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example2_v1.TestType{})
Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example2v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
return obj.(*example2v1.TestType), err
}
// Delete takes name of the testType and deletes it. Returns an error if one occurs.
func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &example2_v1.TestType{})
Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &example2v1.TestType{})
return err
}
@ -124,17 +124,17 @@ func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error {
func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &example2_v1.TestTypeList{})
_, err := c.Fake.Invokes(action, &example2v1.TestTypeList{})
return err
}
// Patch applies the patch and returns the patched testType.
func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example2_v1.TestType, err error) {
func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example2v1.TestType, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example2_v1.TestType{})
Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &example2v1.TestType{})
if obj == nil {
return nil, err
}
return obj.(*example2_v1.TestType), err
return obj.(*example2v1.TestType), err
}

View file

@ -19,7 +19,9 @@ limitations under the License.
package v1
import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"time"
metav1 "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"
@ -38,11 +40,11 @@ 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)
Delete(name string, options *metav1.DeleteOptions) error
DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error
Get(name string, options metav1.GetOptions) (*v1.TestType, error)
List(opts metav1.ListOptions) (*v1.TestTypeList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error)
TestTypeExpansion
}
@ -62,7 +64,7 @@ func newTestTypes(c *SecondExampleV1Client, namespace string) *testTypes {
}
// 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) {
func (c *testTypes) Get(name string, options metav1.GetOptions) (result *v1.TestType, err error) {
result = &v1.TestType{}
err = c.client.Get().
Namespace(c.ns).
@ -75,24 +77,34 @@ func (c *testTypes) Get(name string, options meta_v1.GetOptions) (result *v1.Tes
}
// 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) {
func (c *testTypes) List(opts metav1.ListOptions) (result *v1.TestTypeList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1.TestTypeList{}
err = c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
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) {
func (c *testTypes) Watch(opts metav1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
@ -138,7 +150,7 @@ func (c *testTypes) UpdateStatus(testType *v1.TestType) (result *v1.TestType, er
}
// 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 {
func (c *testTypes) Delete(name string, options *metav1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
@ -149,11 +161,16 @@ func (c *testTypes) Delete(name string, options *meta_v1.DeleteOptions) error {
}
// DeleteCollection deletes a collection of objects.
func (c *testTypes) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error {
func (c *testTypes) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("testtypes").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()

View file

@ -21,11 +21,11 @@ package v1
import (
time "time"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "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/crd/apis/example/v1"
examplev1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
versioned "k8s.io/code-generator/_examples/crd/clientset/versioned"
internalinterfaces "k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces"
v1 "k8s.io/code-generator/_examples/crd/listers/example/v1"
@ -56,20 +56,20 @@ func NewClusterTestTypeInformer(client versioned.Interface, resyncPeriod time.Du
func NewFilteredClusterTestTypeInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ExampleV1().ClusterTestTypes().List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ExampleV1().ClusterTestTypes().Watch(options)
},
},
&example_v1.ClusterTestType{},
&examplev1.ClusterTestType{},
resyncPeriod,
indexers,
)
@ -80,7 +80,7 @@ func (f *clusterTestTypeInformer) defaultInformer(client versioned.Interface, re
}
func (f *clusterTestTypeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&example_v1.ClusterTestType{}, f.defaultInformer)
return f.factory.InformerFor(&examplev1.ClusterTestType{}, f.defaultInformer)
}
func (f *clusterTestTypeInformer) Lister() v1.ClusterTestTypeLister {

View file

@ -21,11 +21,11 @@ package v1
import (
time "time"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "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/crd/apis/example/v1"
examplev1 "k8s.io/code-generator/_examples/crd/apis/example/v1"
versioned "k8s.io/code-generator/_examples/crd/clientset/versioned"
internalinterfaces "k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces"
v1 "k8s.io/code-generator/_examples/crd/listers/example/v1"
@ -57,20 +57,20 @@ func NewTestTypeInformer(client versioned.Interface, namespace string, resyncPer
func NewFilteredTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ExampleV1().TestTypes(namespace).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ExampleV1().TestTypes(namespace).Watch(options)
},
},
&example_v1.TestType{},
&examplev1.TestType{},
resyncPeriod,
indexers,
)
@ -81,7 +81,7 @@ func (f *testTypeInformer) defaultInformer(client versioned.Interface, resyncPer
}
func (f *testTypeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&example_v1.TestType{}, f.defaultInformer)
return f.factory.InformerFor(&examplev1.TestType{}, f.defaultInformer)
}
func (f *testTypeInformer) Lister() v1.TestTypeLister {

View file

@ -21,11 +21,11 @@ package v1
import (
time "time"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
example2_v1 "k8s.io/code-generator/_examples/crd/apis/example2/v1"
example2v1 "k8s.io/code-generator/_examples/crd/apis/example2/v1"
versioned "k8s.io/code-generator/_examples/crd/clientset/versioned"
internalinterfaces "k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces"
v1 "k8s.io/code-generator/_examples/crd/listers/example2/v1"
@ -57,20 +57,20 @@ func NewTestTypeInformer(client versioned.Interface, namespace string, resyncPer
func NewFilteredTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.SecondExampleV1().TestTypes(namespace).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.SecondExampleV1().TestTypes(namespace).Watch(options)
},
},
&example2_v1.TestType{},
&example2v1.TestType{},
resyncPeriod,
indexers,
)
@ -81,7 +81,7 @@ func (f *testTypeInformer) defaultInformer(client versioned.Interface, resyncPer
}
func (f *testTypeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&example2_v1.TestType{}, f.defaultInformer)
return f.factory.InformerFor(&example2v1.TestType{}, f.defaultInformer)
}
func (f *testTypeInformer) Lister() v1.TestTypeLister {

View file

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

View file

@ -27,6 +27,7 @@ import (
versioned "k8s.io/code-generator/_examples/crd/clientset/versioned"
)
// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer.
type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
@ -35,4 +36,5 @@ type SharedInformerFactory interface {
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
}
// TweakListOptionsFunc is a function that transforms a v1.ListOptions.
type TweakListOptionsFunc func(*v1.ListOptions)

View file

@ -1,3 +1,5 @@
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- lavalamp
- wojtek-t

View file

@ -1,4 +1,4 @@
See [generating-clientset.md](https://git.k8s.io/community/contributors/devel/generating-clientset.md)
See [generating-clientset.md](https://git.k8s.io/community/contributors/devel/sig-api-machinery/generating-clientset.md)
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/staging/src/k8s.io/code-generator/client-gen/README.md?pixel)]()

View file

@ -27,12 +27,13 @@ import (
"k8s.io/code-generator/cmd/client-gen/generators/util"
"k8s.io/code-generator/cmd/client-gen/path"
clientgentypes "k8s.io/code-generator/cmd/client-gen/types"
codegennamer "k8s.io/code-generator/pkg/namer"
"k8s.io/gengo/args"
"k8s.io/gengo/generator"
"k8s.io/gengo/namer"
"k8s.io/gengo/types"
"github.com/golang/glog"
"k8s.io/klog"
)
// NameSystems returns the name system used by the generators in this package.
@ -101,7 +102,7 @@ func NameSystems() namer.NameSystems {
"publicPlural": publicPluralNamer,
"privatePlural": privatePluralNamer,
"allLowercasePlural": lowercaseNamer,
"resource": NewTagOverrideNamer("resourceName", lowercaseNamer),
"resource": codegennamer.NewTagOverrideNamer("resourceName", lowercaseNamer),
}
}
@ -130,7 +131,7 @@ func DefaultNameSystem() string {
}
func packageForGroup(gv clientgentypes.GroupVersion, typeList []*types.Type, clientsetPackage string, groupPackageName string, groupGoName string, apiPath string, srcTreePath string, inputPackage string, boilerplate []byte) generator.Package {
groupVersionClientPackage := strings.ToLower(filepath.Join(clientsetPackage, "typed", groupPackageName, gv.Version.NonEmpty()))
groupVersionClientPackage := filepath.Join(clientsetPackage, "typed", strings.ToLower(groupPackageName), strings.ToLower(gv.Version.NonEmpty()))
return &generator.DefaultPackage{
PackageName: strings.ToLower(gv.Version.NonEmpty()),
PackagePath: groupVersionClientPackage,
@ -318,12 +319,12 @@ func applyGroupOverrides(universe types.Universe, customArgs *clientgenargs.Cust
func Packages(context *generator.Context, arguments *args.GeneratorArgs) generator.Packages {
boilerplate, err := arguments.LoadGoBoilerplate()
if err != nil {
glog.Fatalf("Failed loading boilerplate: %v", err)
klog.Fatalf("Failed loading boilerplate: %v", err)
}
customArgs, ok := arguments.CustomArgs.(*clientgenargs.CustomArgs)
if !ok {
glog.Fatalf("cannot convert arguments.CustomArgs to clientgenargs.CustomArgs")
klog.Fatalf("cannot convert arguments.CustomArgs to clientgenargs.CustomArgs")
}
includedTypesOverrides := customArgs.IncludedTypesOverrides
@ -400,27 +401,3 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
return generator.Packages(packageList)
}
// tagOverrideNamer is a namer which pulls names from a given tag, if specified,
// and otherwise falls back to a different namer.
type tagOverrideNamer struct {
tagName string
fallback namer.Namer
}
func (n *tagOverrideNamer) Name(t *types.Type) string {
if nameOverride := extractTag(n.tagName, append(t.SecondClosestCommentLines, t.CommentLines...)); nameOverride != "" {
return nameOverride
}
return n.fallback.Name(t)
}
// NewTagOverrideNamer creates a namer.Namer which uses the contents of the given tag as
// the name, or falls back to another Namer if the tag is not present.
func NewTagOverrideNamer(tagName string, fallback namer.Namer) namer.Namer {
return &tagOverrideNamer{
tagName: tagName,
fallback: fallback,
}
}

View file

@ -30,9 +30,9 @@ import (
)
func PackageForGroup(gv clientgentypes.GroupVersion, typeList []*types.Type, clientsetPackage string, groupPackageName string, groupGoName string, inputPackage string, boilerplate []byte) generator.Package {
outputPackage := strings.ToLower(filepath.Join(clientsetPackage, "typed", groupPackageName, gv.Version.NonEmpty(), "fake"))
outputPackage := filepath.Join(clientsetPackage, "typed", strings.ToLower(groupPackageName), strings.ToLower(gv.Version.NonEmpty()), "fake")
// TODO: should make this a function, called by here and in client-generator.go
realClientPackage := filepath.Join(clientsetPackage, "typed", groupPackageName, gv.Version.NonEmpty())
realClientPackage := filepath.Join(clientsetPackage, "typed", strings.ToLower(groupPackageName), strings.ToLower(gv.Version.NonEmpty()))
return &generator.DefaultPackage{
PackageName: "fake",
PackagePath: outputPackage,

View file

@ -60,12 +60,12 @@ func (g *genClientset) Imports(c *generator.Context) (imports []string) {
imports = append(imports, g.imports.ImportLines()...)
for _, group := range g.groups {
for _, version := range group.Versions {
groupClientPackage := filepath.Join(g.fakeClientsetPackage, "typed", group.PackageName, version.NonEmpty())
groupClientPackage := filepath.Join(g.fakeClientsetPackage, "typed", strings.ToLower(group.PackageName), strings.ToLower(version.NonEmpty()))
fakeGroupClientPackage := filepath.Join(groupClientPackage, "fake")
groupAlias := strings.ToLower(g.groupGoNames[clientgentypes.GroupVersion{Group: group.Group, Version: version.Version}])
imports = append(imports, strings.ToLower(fmt.Sprintf("%s%s \"%s\"", groupAlias, version.NonEmpty(), groupClientPackage)))
imports = append(imports, strings.ToLower(fmt.Sprintf("fake%s%s \"%s\"", groupAlias, version.NonEmpty(), fakeGroupClientPackage)))
imports = append(imports, fmt.Sprintf("%s%s \"%s\"", groupAlias, strings.ToLower(version.NonEmpty()), groupClientPackage))
imports = append(imports, fmt.Sprintf("fake%s%s \"%s\"", groupAlias, strings.ToLower(version.NonEmpty()), fakeGroupClientPackage))
}
}
// the package that has the clientset Interface
@ -102,10 +102,6 @@ func (g *genClientset) GenerateType(c *generator.Context, t *types.Type, w io.Wr
}
sw.Do(clientsetInterfaceImplTemplate, m)
// don't generated the default method if generating internalversion clientset
if group.IsDefaultVersion && group.Version != "" {
sw.Do(clientsetInterfaceDefaultVersionImpl, m)
}
}
return sw.Error()
@ -125,7 +121,7 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
}
}
cs := &Clientset{}
cs := &Clientset{tracker: o}
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
cs.AddReactor("*", "*", testing.ObjectReaction(o))
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
@ -147,11 +143,16 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
type Clientset struct {
testing.Fake
discovery *fakediscovery.FakeDiscovery
tracker testing.ObjectTracker
}
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return c.discovery
}
func (c *Clientset) Tracker() testing.ObjectTracker {
return c.tracker
}
`
var checkImpl = `

View file

@ -64,7 +64,7 @@ func (g *genFakeForGroup) Namers(c *generator.Context) namer.NameSystems {
func (g *genFakeForGroup) Imports(c *generator.Context) (imports []string) {
imports = g.imports.ImportLines()
if len(g.types) != 0 {
imports = append(imports, strings.ToLower(fmt.Sprintf("%s \"%s\"", filepath.Base(g.realClientPackage), g.realClientPackage)))
imports = append(imports, fmt.Sprintf("%s \"%s\"", strings.ToLower(filepath.Base(g.realClientPackage)), g.realClientPackage))
}
return imports
}

View file

@ -362,7 +362,7 @@ var getSubresourceTemplate = `
func (c *Fake$.type|publicPlural$) Get($.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
obj, err := c.Fake.
$if .namespaced$Invokes($.NewGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, "$.subresourcePath$", $.type|private$Name), &$.resultType|raw${})
$else$Invokes($.NewRootGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, $.type|private$Name), &$.resultType|raw${})$end$
$else$Invokes($.NewRootGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", $.type|private$Name), &$.resultType|raw${})$end$
if obj == nil {
return nil, err
}
@ -469,8 +469,8 @@ var patchTemplate = `
// Patch applies the patch and returns the patched $.resultType|private$.
func (c *Fake$.type|publicPlural$) Patch(name string, pt $.PatchType|raw$, data []byte, subresources ...string) (result *$.resultType|raw$, err error) {
obj, err := c.Fake.
$if .namespaced$Invokes($.NewPatchSubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, name, data, subresources... ), &$.resultType|raw${})
$else$Invokes($.NewRootPatchSubresourceAction|raw$($.type|allLowercasePlural$Resource, name, data, subresources...), &$.resultType|raw${})$end$
$if .namespaced$Invokes($.NewPatchSubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, name, pt, data, subresources... ), &$.resultType|raw${})
$else$Invokes($.NewRootPatchSubresourceAction|raw$($.type|allLowercasePlural$Resource, name, pt, data, subresources...), &$.resultType|raw${})$end$
if obj == nil {
return nil, err
}

View file

@ -58,9 +58,9 @@ func (g *genClientset) Imports(c *generator.Context) (imports []string) {
imports = append(imports, g.imports.ImportLines()...)
for _, group := range g.groups {
for _, version := range group.Versions {
typedClientPath := filepath.Join(g.clientsetPackage, "typed", group.PackageName, version.NonEmpty())
typedClientPath := filepath.Join(g.clientsetPackage, "typed", strings.ToLower(group.PackageName), strings.ToLower(version.NonEmpty()))
groupAlias := strings.ToLower(g.groupGoNames[clientgentypes.GroupVersion{Group: group.Group, Version: version.Version}])
imports = append(imports, strings.ToLower(fmt.Sprintf("%s%s \"%s\"", groupAlias, version.NonEmpty(), typedClientPath)))
imports = append(imports, fmt.Sprintf("%s%s \"%s\"", groupAlias, strings.ToLower(version.NonEmpty()), typedClientPath))
}
}
return
@ -88,10 +88,6 @@ func (g *genClientset) GenerateType(c *generator.Context, t *types.Type, w io.Wr
sw.Do(clientsetTemplate, m)
for _, g := range allGroups {
sw.Do(clientsetInterfaceImplTemplate, g)
// don't generated the default method if generating internalversion clientset
if g.IsDefaultVersion && g.Version != "" {
sw.Do(clientsetInterfaceDefaultVersionImpl, g)
}
}
sw.Do(getDiscoveryTemplate, m)
sw.Do(newClientsetForConfigTemplate, m)
@ -105,9 +101,7 @@ var clientsetInterface = `
type Interface interface {
Discovery() $.DiscoveryInterface|raw$
$range .allGroups$$.GroupGoName$$.Version$() $.PackageAlias$.$.GroupGoName$$.Version$Interface
$if .IsDefaultVersion$// Deprecated: please explicitly pick a version if possible.
$.GroupGoName$() $.PackageAlias$.$.GroupGoName$$.Version$Interface
$end$$end$
$end$
}
`
@ -128,14 +122,6 @@ func (c *Clientset) $.GroupGoName$$.Version$() $.PackageAlias$.$.GroupGoName$$.V
}
`
var clientsetInterfaceDefaultVersionImpl = `
// Deprecated: $.GroupGoName$ retrieves the default version of $.GroupGoName$Client.
// Please explicitly pick a version.
func (c *Clientset) $.GroupGoName$() $.PackageAlias$.$.GroupGoName$$.Version$Interface {
return c.$.LowerCaseGroupGoName$$.Version$
}
`
var getDiscoveryTemplate = `
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() $.DiscoveryInterface|raw$ {

View file

@ -98,7 +98,6 @@ func (g *genGroup) GenerateType(c *generator.Context, t *types.Type, w io.Writer
"apiPath": apiPath(g.group),
"schemaGroupVersion": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/runtime/schema", Name: "GroupVersion"}),
"runtimeAPIVersionInternal": c.Universe.Variable(types.Name{Package: "k8s.io/apimachinery/pkg/runtime", Name: "APIVersionInternal"}),
"serializerDirectCodecFactory": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/runtime/serializer", Name: "DirectCodecFactory"}),
"restConfig": c.Universe.Type(types.Name{Package: "k8s.io/client-go/rest", Name: "Config"}),
"restDefaultKubernetesUserAgent": c.Universe.Function(types.Name{Package: "k8s.io/client-go/rest", Name: "DefaultKubernetesUserAgent"}),
"restRESTClientInterface": c.Universe.Type(types.Name{Package: "k8s.io/client-go/rest", Name: "Interface"}),
@ -236,7 +235,7 @@ func setConfigDefaults(config *$.restConfig|raw$) error {
gv := $.SchemeGroupVersion|raw$
config.GroupVersion = &gv
config.APIPath = $.apiPath$
config.NegotiatedSerializer = $.serializerDirectCodecFactory|raw${CodecFactory: scheme.Codecs}
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = $.restDefaultKubernetesUserAgent|raw$()

View file

@ -387,11 +387,16 @@ func new$.type|publicPlural$(c *$.GroupGoName$$.Version$Client) *$.type|privateP
var listTemplate = `
// List takes label and field selectors, and returns the list of $.resultType|publicPlural$ that match those selectors.
func (c *$.type|privatePlural$) List(opts $.ListOptions|raw$) (result *$.resultType|raw$List, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil{
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &$.resultType|raw$List{}
err = c.client.Get().
$if .namespaced$Namespace(c.ns).$end$
Resource("$.type|resource$").
VersionedParams(&opts, $.schemeParameterCodec|raw$).
Timeout(timeout).
Do().
Into(result)
return
@ -401,6 +406,10 @@ func (c *$.type|privatePlural$) List(opts $.ListOptions|raw$) (result *$.resultT
var listSubresourceTemplate = `
// List takes $.type|raw$ name, label and field selectors, and returns the list of $.resultType|publicPlural$ that match those selectors.
func (c *$.type|privatePlural$) List($.type|private$Name string, opts $.ListOptions|raw$) (result *$.resultType|raw$List, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil{
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &$.resultType|raw$List{}
err = c.client.Get().
$if .namespaced$Namespace(c.ns).$end$
@ -408,6 +417,7 @@ func (c *$.type|privatePlural$) List($.type|private$Name string, opts $.ListOpti
Name($.type|private$Name).
SubResource("$.subresourcePath$").
VersionedParams(&opts, $.schemeParameterCodec|raw$).
Timeout(timeout).
Do().
Into(result)
return
@ -461,10 +471,15 @@ func (c *$.type|privatePlural$) Delete(name string, options *$.DeleteOptions|raw
var deleteCollectionTemplate = `
// DeleteCollection deletes a collection of objects.
func (c *$.type|privatePlural$) DeleteCollection(options *$.DeleteOptions|raw$, listOptions $.ListOptions|raw$) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil{
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
$if .namespaced$Namespace(c.ns).$end$
Resource("$.type|resource$").
VersionedParams(&listOptions, $.schemeParameterCodec|raw$).
Timeout(timeout).
Body(options).
Do().
Error()
@ -553,11 +568,16 @@ func (c *$.type|privatePlural$) UpdateStatus($.type|private$ *$.type|raw$) (resu
var watchTemplate = `
// Watch returns a $.watchInterface|raw$ that watches the requested $.type|privatePlural$.
func (c *$.type|privatePlural$) Watch(opts $.ListOptions|raw$) ($.watchInterface|raw$, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil{
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
$if .namespaced$Namespace(c.ns).$end$
Resource("$.type|resource$").
VersionedParams(&opts, $.schemeParameterCodec|raw$).
Timeout(timeout).
Watch()
}
`

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