diff --git a/staging/src/k8s.io/code-generator/examples/crd/applyconfiguration/extensions/v1/testsubresource.go b/staging/src/k8s.io/code-generator/examples/crd/applyconfiguration/extensions/v1/testsubresource.go new file mode 100644 index 00000000000..6b9eb0f2ff9 --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/applyconfiguration/extensions/v1/testsubresource.go @@ -0,0 +1,63 @@ +/* +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 applyconfiguration-gen. DO NOT EDIT. + +package v1 + +import ( + metav1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// TestSubresourceApplyConfiguration represents a declarative configuration of the TestSubresource type for use +// with apply. +type TestSubresourceApplyConfiguration struct { + metav1.TypeMetaApplyConfiguration `json:",inline"` + Name *string `json:"name,omitempty"` +} + +// TestSubresourceApplyConfiguration constructs a declarative configuration of the TestSubresource type for use with +// apply. +func TestSubresource() *TestSubresourceApplyConfiguration { + b := &TestSubresourceApplyConfiguration{} + b.WithKind("TestSubresource") + b.WithAPIVersion("extensions.test.crd.code-generator.k8s.io/v1") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *TestSubresourceApplyConfiguration) WithKind(value string) *TestSubresourceApplyConfiguration { + b.TypeMetaApplyConfiguration.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *TestSubresourceApplyConfiguration) WithAPIVersion(value string) *TestSubresourceApplyConfiguration { + b.TypeMetaApplyConfiguration.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *TestSubresourceApplyConfiguration) WithName(value string) *TestSubresourceApplyConfiguration { + b.Name = &value + return b +} diff --git a/staging/src/k8s.io/code-generator/examples/crd/applyconfiguration/extensions/v1/testtype.go b/staging/src/k8s.io/code-generator/examples/crd/applyconfiguration/extensions/v1/testtype.go new file mode 100644 index 00000000000..e8f9048443c --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/applyconfiguration/extensions/v1/testtype.go @@ -0,0 +1,216 @@ +/* +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 applyconfiguration-gen. DO NOT EDIT. + +package v1 + +import ( + apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + metav1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// TestTypeApplyConfiguration represents a declarative configuration of the TestType type for use +// with apply. +type TestTypeApplyConfiguration struct { + metav1.TypeMetaApplyConfiguration `json:",inline"` + *metav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Status *TestTypeStatusApplyConfiguration `json:"status,omitempty"` +} + +// TestType constructs a declarative configuration of the TestType type for use with +// apply. +func TestType(name, namespace string) *TestTypeApplyConfiguration { + b := &TestTypeApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("TestType") + b.WithAPIVersion("extensions.test.crd.code-generator.k8s.io/v1") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *TestTypeApplyConfiguration) WithKind(value string) *TestTypeApplyConfiguration { + b.TypeMetaApplyConfiguration.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *TestTypeApplyConfiguration) WithAPIVersion(value string) *TestTypeApplyConfiguration { + b.TypeMetaApplyConfiguration.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *TestTypeApplyConfiguration) WithName(value string) *TestTypeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *TestTypeApplyConfiguration) WithGenerateName(value string) *TestTypeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *TestTypeApplyConfiguration) WithNamespace(value string) *TestTypeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *TestTypeApplyConfiguration) WithUID(value types.UID) *TestTypeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *TestTypeApplyConfiguration) WithResourceVersion(value string) *TestTypeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *TestTypeApplyConfiguration) WithGeneration(value int64) *TestTypeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *TestTypeApplyConfiguration) WithCreationTimestamp(value apismetav1.Time) *TestTypeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *TestTypeApplyConfiguration) WithDeletionTimestamp(value apismetav1.Time) *TestTypeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *TestTypeApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *TestTypeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *TestTypeApplyConfiguration) WithLabels(entries map[string]string) *TestTypeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.ObjectMetaApplyConfiguration.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *TestTypeApplyConfiguration) WithAnnotations(entries map[string]string) *TestTypeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.ObjectMetaApplyConfiguration.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *TestTypeApplyConfiguration) WithOwnerReferences(values ...*metav1.OwnerReferenceApplyConfiguration) *TestTypeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *TestTypeApplyConfiguration) WithFinalizers(values ...string) *TestTypeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) + } + return b +} + +func (b *TestTypeApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &metav1.ObjectMetaApplyConfiguration{} + } +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *TestTypeApplyConfiguration) WithStatus(value *TestTypeStatusApplyConfiguration) *TestTypeApplyConfiguration { + b.Status = value + return b +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *TestTypeApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Name +} diff --git a/staging/src/k8s.io/code-generator/examples/crd/applyconfiguration/extensions/v1/testtypestatus.go b/staging/src/k8s.io/code-generator/examples/crd/applyconfiguration/extensions/v1/testtypestatus.go new file mode 100644 index 00000000000..246b2ee1889 --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/applyconfiguration/extensions/v1/testtypestatus.go @@ -0,0 +1,39 @@ +/* +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 applyconfiguration-gen. DO NOT EDIT. + +package v1 + +// TestTypeStatusApplyConfiguration represents a declarative configuration of the TestTypeStatus type for use +// with apply. +type TestTypeStatusApplyConfiguration struct { + Blah *string `json:"blah,omitempty"` +} + +// TestTypeStatusApplyConfiguration constructs a declarative configuration of the TestTypeStatus type for use with +// apply. +func TestTypeStatus() *TestTypeStatusApplyConfiguration { + return &TestTypeStatusApplyConfiguration{} +} + +// WithBlah sets the Blah field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Blah field is set to the value of the last call. +func (b *TestTypeStatusApplyConfiguration) WithBlah(value string) *TestTypeStatusApplyConfiguration { + b.Blah = &value + return b +} diff --git a/staging/src/k8s.io/code-generator/examples/crd/applyconfiguration/utils.go b/staging/src/k8s.io/code-generator/examples/crd/applyconfiguration/utils.go index 6ee2582b4be..274fed02ae4 100644 --- a/staging/src/k8s.io/code-generator/examples/crd/applyconfiguration/utils.go +++ b/staging/src/k8s.io/code-generator/examples/crd/applyconfiguration/utils.go @@ -25,9 +25,11 @@ import ( v1 "k8s.io/code-generator/examples/crd/apis/conflicting/v1" examplev1 "k8s.io/code-generator/examples/crd/apis/example/v1" example2v1 "k8s.io/code-generator/examples/crd/apis/example2/v1" + extensionsv1 "k8s.io/code-generator/examples/crd/apis/extensions/v1" conflictingv1 "k8s.io/code-generator/examples/crd/applyconfiguration/conflicting/v1" applyconfigurationexamplev1 "k8s.io/code-generator/examples/crd/applyconfiguration/example/v1" applyconfigurationexample2v1 "k8s.io/code-generator/examples/crd/applyconfiguration/example2/v1" + applyconfigurationextensionsv1 "k8s.io/code-generator/examples/crd/applyconfiguration/extensions/v1" internal "k8s.io/code-generator/examples/crd/applyconfiguration/internal" ) @@ -59,6 +61,14 @@ func ForKind(kind schema.GroupVersionKind) interface{} { case example2v1.SchemeGroupVersion.WithKind("TestTypeStatus"): return &applyconfigurationexample2v1.TestTypeStatusApplyConfiguration{} + // Group=extensions.test.crd.code-generator.k8s.io, Version=v1 + case extensionsv1.SchemeGroupVersion.WithKind("TestSubresource"): + return &applyconfigurationextensionsv1.TestSubresourceApplyConfiguration{} + case extensionsv1.SchemeGroupVersion.WithKind("TestType"): + return &applyconfigurationextensionsv1.TestTypeApplyConfiguration{} + case extensionsv1.SchemeGroupVersion.WithKind("TestTypeStatus"): + return &applyconfigurationextensionsv1.TestTypeStatusApplyConfiguration{} + } return nil } diff --git a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/clientset.go b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/clientset.go index dea1369fba1..705352af275 100644 --- a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/clientset.go +++ b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/clientset.go @@ -28,6 +28,7 @@ import ( conflictingexamplev1 "k8s.io/code-generator/examples/crd/clientset/versioned/typed/conflicting/v1" examplev1 "k8s.io/code-generator/examples/crd/clientset/versioned/typed/example/v1" secondexamplev1 "k8s.io/code-generator/examples/crd/clientset/versioned/typed/example2/v1" + extensionsexamplev1 "k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1" ) type Interface interface { @@ -35,6 +36,7 @@ type Interface interface { ConflictingExampleV1() conflictingexamplev1.ConflictingExampleV1Interface ExampleV1() examplev1.ExampleV1Interface SecondExampleV1() secondexamplev1.SecondExampleV1Interface + ExtensionsExampleV1() extensionsexamplev1.ExtensionsExampleV1Interface } // Clientset contains the clients for groups. @@ -43,6 +45,7 @@ type Clientset struct { conflictingExampleV1 *conflictingexamplev1.ConflictingExampleV1Client exampleV1 *examplev1.ExampleV1Client secondExampleV1 *secondexamplev1.SecondExampleV1Client + extensionsExampleV1 *extensionsexamplev1.ExtensionsExampleV1Client } // ConflictingExampleV1 retrieves the ConflictingExampleV1Client @@ -60,6 +63,11 @@ func (c *Clientset) SecondExampleV1() secondexamplev1.SecondExampleV1Interface { return c.secondExampleV1 } +// ExtensionsExampleV1 retrieves the ExtensionsExampleV1Client +func (c *Clientset) ExtensionsExampleV1() extensionsexamplev1.ExtensionsExampleV1Interface { + return c.extensionsExampleV1 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -116,6 +124,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, if err != nil { return nil, err } + cs.extensionsExampleV1, err = extensionsexamplev1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) if err != nil { @@ -140,6 +152,7 @@ func New(c rest.Interface) *Clientset { cs.conflictingExampleV1 = conflictingexamplev1.New(c) cs.exampleV1 = examplev1.New(c) cs.secondExampleV1 = secondexamplev1.New(c) + cs.extensionsExampleV1 = extensionsexamplev1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/fake/clientset_generated.go b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/fake/clientset_generated.go index a1d5fb472c1..5a40cfece36 100644 --- a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/fake/clientset_generated.go +++ b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/fake/clientset_generated.go @@ -32,6 +32,8 @@ import ( fakeexamplev1 "k8s.io/code-generator/examples/crd/clientset/versioned/typed/example/v1/fake" secondexamplev1 "k8s.io/code-generator/examples/crd/clientset/versioned/typed/example2/v1" fakesecondexamplev1 "k8s.io/code-generator/examples/crd/clientset/versioned/typed/example2/v1/fake" + extensionsexamplev1 "k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1" + fakeextensionsexamplev1 "k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/fake" ) // NewSimpleClientset returns a clientset that will respond with the provided objects. @@ -134,3 +136,8 @@ func (c *Clientset) ExampleV1() examplev1.ExampleV1Interface { func (c *Clientset) SecondExampleV1() secondexamplev1.SecondExampleV1Interface { return &fakesecondexamplev1.FakeSecondExampleV1{Fake: &c.Fake} } + +// ExtensionsExampleV1 retrieves the ExtensionsExampleV1Client +func (c *Clientset) ExtensionsExampleV1() extensionsexamplev1.ExtensionsExampleV1Interface { + return &fakeextensionsexamplev1.FakeExtensionsExampleV1{Fake: &c.Fake} +} diff --git a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/fake/register.go b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/fake/register.go index 4cb0b57b930..9b1944efe35 100644 --- a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/fake/register.go +++ b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/fake/register.go @@ -27,6 +27,7 @@ import ( conflictingexamplev1 "k8s.io/code-generator/examples/crd/apis/conflicting/v1" examplev1 "k8s.io/code-generator/examples/crd/apis/example/v1" secondexamplev1 "k8s.io/code-generator/examples/crd/apis/example2/v1" + extensionsexamplev1 "k8s.io/code-generator/examples/crd/apis/extensions/v1" ) var scheme = runtime.NewScheme() @@ -36,6 +37,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ conflictingexamplev1.AddToScheme, examplev1.AddToScheme, secondexamplev1.AddToScheme, + extensionsexamplev1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/scheme/register.go b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/scheme/register.go index 146825e2d44..619f2828f1d 100644 --- a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/scheme/register.go +++ b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/scheme/register.go @@ -27,6 +27,7 @@ import ( conflictingexamplev1 "k8s.io/code-generator/examples/crd/apis/conflicting/v1" examplev1 "k8s.io/code-generator/examples/crd/apis/example/v1" secondexamplev1 "k8s.io/code-generator/examples/crd/apis/example2/v1" + extensionsexamplev1 "k8s.io/code-generator/examples/crd/apis/extensions/v1" ) var Scheme = runtime.NewScheme() @@ -36,6 +37,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ conflictingexamplev1.AddToScheme, examplev1.AddToScheme, secondexamplev1.AddToScheme, + extensionsexamplev1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/doc.go b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/doc.go new file mode 100644 index 00000000000..3af5d054f10 --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/doc.go @@ -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 diff --git a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/extensions_client.go b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/extensions_client.go new file mode 100644 index 00000000000..de26a13b1b8 --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/extensions_client.go @@ -0,0 +1,107 @@ +/* +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 ( + http "net/http" + + rest "k8s.io/client-go/rest" + extensionsv1 "k8s.io/code-generator/examples/crd/apis/extensions/v1" + scheme "k8s.io/code-generator/examples/crd/clientset/versioned/scheme" +) + +type ExtensionsExampleV1Interface interface { + RESTClient() rest.Interface + TestTypesGetter +} + +// ExtensionsExampleV1Client is used to interact with features provided by the extensions.test.crd.code-generator.k8s.io group. +type ExtensionsExampleV1Client struct { + restClient rest.Interface +} + +func (c *ExtensionsExampleV1Client) TestTypes(namespace string) TestTypeInterface { + return newTestTypes(c, namespace) +} + +// NewForConfig creates a new ExtensionsExampleV1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*ExtensionsExampleV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new ExtensionsExampleV1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*ExtensionsExampleV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &ExtensionsExampleV1Client{client}, nil +} + +// NewForConfigOrDie creates a new ExtensionsExampleV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ExtensionsExampleV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ExtensionsExampleV1Client for the given RESTClient. +func New(c rest.Interface) *ExtensionsExampleV1Client { + return &ExtensionsExampleV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := extensionsv1.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 *ExtensionsExampleV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/fake/doc.go b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/fake/doc.go new file mode 100644 index 00000000000..16f44399065 --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/fake/doc.go @@ -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 diff --git a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/fake/fake_extensions_client.go b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/fake/fake_extensions_client.go new file mode 100644 index 00000000000..2c8de554fd2 --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/fake/fake_extensions_client.go @@ -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 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/crd/clientset/versioned/typed/extensions/v1" +) + +type FakeExtensionsExampleV1 struct { + *testing.Fake +} + +func (c *FakeExtensionsExampleV1) 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 *FakeExtensionsExampleV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/fake/fake_testtype.go b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/fake/fake_testtype.go new file mode 100644 index 00000000000..77dbcf93dc5 --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/fake/fake_testtype.go @@ -0,0 +1,336 @@ +/* +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 ( + context "context" + json "encoding/json" + fmt "fmt" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1 "k8s.io/code-generator/examples/crd/apis/extensions/v1" + extensionsv1 "k8s.io/code-generator/examples/crd/applyconfiguration/extensions/v1" +) + +// FakeTestTypes implements TestTypeInterface +type FakeTestTypes struct { + Fake *FakeExtensionsExampleV1 + ns string +} + +var testtypesResource = v1.SchemeGroupVersion.WithResource("testtypes") + +var testtypesKind = v1.SchemeGroupVersion.WithKind("TestType") + +// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *FakeTestTypes) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.TestType, err error) { + emptyResult := &v1.TestType{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(testtypesResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestType), err +} + +// List takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *FakeTestTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { + emptyResult := &v1.TestTypeList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(testtypesResource, testtypesKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1.TestTypeList{ListMeta: obj.(*v1.TestTypeList).ListMeta} + for _, item := range obj.(*v1.TestTypeList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested testTypes. +func (c *FakeTestTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(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(ctx context.Context, testType *v1.TestType, opts metav1.CreateOptions) (result *v1.TestType, err error) { + emptyResult := &v1.TestType{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(testtypesResource, c.ns, testType, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestType), err +} + +// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *FakeTestTypes) Update(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (result *v1.TestType, err error) { + emptyResult := &v1.TestType{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(testtypesResource, c.ns, testType, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestType), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (result *v1.TestType, err error) { + emptyResult := &v1.TestType{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(testtypesResource, "status", c.ns, testType, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestType), err +} + +// Delete takes name of the testType and deletes it. Returns an error if one occurs. +func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &v1.TestType{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(testtypesResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1.TestTypeList{}) + return err +} + +// Patch applies the patch and returns the patched testType. +func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.TestType, err error) { + emptyResult := &v1.TestType{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(testtypesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestType), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied testType. +func (c *FakeTestTypes) Apply(ctx context.Context, testType *extensionsv1.TestTypeApplyConfiguration, opts metav1.ApplyOptions) (result *v1.TestType, err error) { + if testType == nil { + return nil, fmt.Errorf("testType provided to Apply must not be nil") + } + data, err := json.Marshal(testType) + if err != nil { + return nil, err + } + name := testType.Name + if name == nil { + return nil, fmt.Errorf("testType.Name must be provided to Apply") + } + emptyResult := &v1.TestType{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(testtypesResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestType), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeTestTypes) ApplyStatus(ctx context.Context, testType *extensionsv1.TestTypeApplyConfiguration, opts metav1.ApplyOptions) (result *v1.TestType, err error) { + if testType == nil { + return nil, fmt.Errorf("testType provided to Apply must not be nil") + } + data, err := json.Marshal(testType) + if err != nil { + return nil, err + } + name := testType.Name + if name == nil { + return nil, fmt.Errorf("testType.Name must be provided to Apply") + } + emptyResult := &v1.TestType{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(testtypesResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions(), "status"), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestType), err +} + +// GetExtended takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *FakeTestTypes) GetExtended(ctx context.Context, name string, options metav1.GetOptions) (result *v1.TestType, err error) { + emptyResult := &v1.TestType{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(testtypesResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestType), err +} + +// ListExtended takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *FakeTestTypes) ListExtended(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { + emptyResult := &v1.TestTypeList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(testtypesResource, testtypesKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestTypeList), err +} + +// CreateExtended 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) CreateExtended(ctx context.Context, testType *v1.TestType, opts metav1.CreateOptions) (result *v1.TestType, err error) { + emptyResult := &v1.TestType{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(testtypesResource, c.ns, testType, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestType), err +} + +// UpdateExtended 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) UpdateExtended(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (result *v1.TestType, err error) { + emptyResult := &v1.TestType{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(testtypesResource, c.ns, testType, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestType), err +} + +// PatchExtended applies the patch and returns the patched testType. +func (c *FakeTestTypes) PatchExtended(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.TestType, err error) { + emptyResult := &v1.TestType{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(testtypesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestType), err +} + +// ApplyExtended takes the given apply declarative configuration, applies it and returns the applied testType. +func (c *FakeTestTypes) ApplyExtended(ctx context.Context, testType *extensionsv1.TestTypeApplyConfiguration, opts metav1.ApplyOptions) (result *v1.TestType, err error) { + if testType == nil { + return nil, fmt.Errorf("testType provided to ApplyExtended must not be nil") + } + data, err := json.Marshal(testType) + if err != nil { + return nil, err + } + name := testType.Name + if name == nil { + return nil, fmt.Errorf("testType.Name must be provided to ApplyExtended") + } + emptyResult := &v1.TestType{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(testtypesResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestType), err +} + +// GetSubresource takes name of the testType, and returns the corresponding testSubresource object, and an error if there is any. +func (c *FakeTestTypes) GetSubresource(ctx context.Context, testTypeName string, options metav1.GetOptions) (result *v1.TestSubresource, err error) { + emptyResult := &v1.TestSubresource{} + obj, err := c.Fake. + Invokes(testing.NewGetSubresourceActionWithOptions(testtypesResource, c.ns, "testsubresource", testTypeName, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestSubresource), err +} + +// CreateSubresource takes the representation of a testSubresource and creates it. Returns the server's representation of the testSubresource, and an error, if there is any. +func (c *FakeTestTypes) CreateSubresource(ctx context.Context, testTypeName string, testSubresource *v1.TestSubresource, opts metav1.CreateOptions) (result *v1.TestSubresource, err error) { + emptyResult := &v1.TestSubresource{} + obj, err := c.Fake. + Invokes(testing.NewCreateSubresourceActionWithOptions(testtypesResource, testTypeName, "testsubresource", c.ns, testSubresource, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestSubresource), err +} + +// UpdateSubresource takes the representation of a testSubresource and updates it. Returns the server's representation of the testSubresource, and an error, if there is any. +func (c *FakeTestTypes) UpdateSubresource(ctx context.Context, testTypeName string, testSubresource *v1.TestSubresource, opts metav1.UpdateOptions) (result *v1.TestSubresource, err error) { + emptyResult := &v1.TestSubresource{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(testtypesResource, "subresource", c.ns, testSubresource, opts), &v1.TestSubresource{}) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestSubresource), err +} + +// ApplySubresource takes top resource name and the apply declarative configuration for subresource, +// applies it and returns the applied testSubresource, and an error, if there is any. +func (c *FakeTestTypes) ApplySubresource(ctx context.Context, testTypeName string, testSubresource *extensionsv1.TestSubresourceApplyConfiguration, opts metav1.ApplyOptions) (result *v1.TestSubresource, err error) { + if testSubresource == nil { + return nil, fmt.Errorf("testSubresource provided to ApplySubresource must not be nil") + } + data, err := json.Marshal(testSubresource) + if err != nil { + return nil, err + } + emptyResult := &v1.TestSubresource{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(testtypesResource, c.ns, testTypeName, types.ApplyPatchType, data, opts.ToPatchOptions(), "testSubresource"), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1.TestSubresource), err +} diff --git a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/generated_expansion.go b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/generated_expansion.go new file mode 100644 index 00000000000..d513810d0d7 --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +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 + +type TestTypeExpansion interface{} diff --git a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/testtype.go b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/testtype.go new file mode 100644 index 00000000000..fb69c10cde2 --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/extensions/v1/testtype.go @@ -0,0 +1,291 @@ +/* +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 ( + context "context" + json "encoding/json" + fmt "fmt" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" + consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + extensionsv1 "k8s.io/code-generator/examples/crd/apis/extensions/v1" + applyconfigurationextensionsv1 "k8s.io/code-generator/examples/crd/applyconfiguration/extensions/v1" + scheme "k8s.io/code-generator/examples/crd/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(ctx context.Context, testType *extensionsv1.TestType, opts metav1.CreateOptions) (*extensionsv1.TestType, error) + Update(ctx context.Context, testType *extensionsv1.TestType, opts metav1.UpdateOptions) (*extensionsv1.TestType, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, testType *extensionsv1.TestType, opts metav1.UpdateOptions) (*extensionsv1.TestType, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*extensionsv1.TestType, error) + List(ctx context.Context, opts metav1.ListOptions) (*extensionsv1.TestTypeList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *extensionsv1.TestType, err error) + Apply(ctx context.Context, testType *applyconfigurationextensionsv1.TestTypeApplyConfiguration, opts metav1.ApplyOptions) (result *extensionsv1.TestType, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, testType *applyconfigurationextensionsv1.TestTypeApplyConfiguration, opts metav1.ApplyOptions) (result *extensionsv1.TestType, err error) + GetExtended(ctx context.Context, name string, opts metav1.GetOptions) (*extensionsv1.TestType, error) + ListExtended(ctx context.Context, opts metav1.ListOptions) (*extensionsv1.TestTypeList, error) + CreateExtended(ctx context.Context, testType *extensionsv1.TestType, opts metav1.CreateOptions) (*extensionsv1.TestType, error) + UpdateExtended(ctx context.Context, testType *extensionsv1.TestType, opts metav1.UpdateOptions) (*extensionsv1.TestType, error) + PatchExtended(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *extensionsv1.TestType, err error) + ApplyExtended(ctx context.Context, testType *applyconfigurationextensionsv1.TestTypeApplyConfiguration, opts metav1.ApplyOptions) (result *extensionsv1.TestType, err error) + GetSubresource(ctx context.Context, testTypeName string, options metav1.GetOptions) (*extensionsv1.TestSubresource, error) + CreateSubresource(ctx context.Context, testTypeName string, testSubresource *extensionsv1.TestSubresource, opts metav1.CreateOptions) (*extensionsv1.TestSubresource, error) + UpdateSubresource(ctx context.Context, testTypeName string, testSubresource *extensionsv1.TestSubresource, opts metav1.UpdateOptions) (*extensionsv1.TestSubresource, error) + ApplySubresource(ctx context.Context, testTypeName string, testSubresource *applyconfigurationextensionsv1.TestSubresourceApplyConfiguration, opts metav1.ApplyOptions) (*extensionsv1.TestSubresource, error) + + TestTypeExpansion +} + +// testTypes implements TestTypeInterface +type testTypes struct { + *gentype.ClientWithListAndApply[*extensionsv1.TestType, *extensionsv1.TestTypeList, *applyconfigurationextensionsv1.TestTypeApplyConfiguration] +} + +// newTestTypes returns a TestTypes +func newTestTypes(c *ExtensionsExampleV1Client, namespace string) *testTypes { + return &testTypes{ + gentype.NewClientWithListAndApply[*extensionsv1.TestType, *extensionsv1.TestTypeList, *applyconfigurationextensionsv1.TestTypeApplyConfiguration]( + "testtypes", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *extensionsv1.TestType { return &extensionsv1.TestType{} }, + func() *extensionsv1.TestTypeList { return &extensionsv1.TestTypeList{} }), + } +} + +// GetExtended takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *testTypes) GetExtended(ctx context.Context, name string, options metav1.GetOptions) (result *extensionsv1.TestType, err error) { + result = &extensionsv1.TestType{} + err = c.GetClient().Get(). + Namespace(c.GetNamespace()). + Resource("testtypes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// ListExtended takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *testTypes) ListExtended(ctx context.Context, opts metav1.ListOptions) (*extensionsv1.TestTypeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for testtypes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) + if err == nil { + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for testtypes", c.list, opts, result) + return result, nil + } + klog.Warningf("The watchlist request for testtypes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + } + return result, err +} + +// list takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *testTypes) list(ctx context.Context, opts metav1.ListOptions) (result *extensionsv1.TestTypeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &extensionsv1.TestTypeList{} + err = c.GetClient().Get(). + Namespace(c.GetNamespace()). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// watchList establishes a watch stream with the server and returns the list of TestTypes +func (c *testTypes) watchList(ctx context.Context, opts metav1.ListOptions) (result *extensionsv1.TestTypeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &extensionsv1.TestTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + +// CreateExtended 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) CreateExtended(ctx context.Context, testType *extensionsv1.TestType, opts metav1.CreateOptions) (result *extensionsv1.TestType, err error) { + result = &extensionsv1.TestType{} + err = c.GetClient().Post(). + Namespace(c.GetNamespace()). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(testType). + Do(ctx). + Into(result) + return +} + +// UpdateExtended 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) UpdateExtended(ctx context.Context, testType *extensionsv1.TestType, opts metav1.UpdateOptions) (result *extensionsv1.TestType, err error) { + result = &extensionsv1.TestType{} + err = c.GetClient().Put(). + Namespace(c.GetNamespace()). + Resource("testtypes"). + Name(testType.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(testType). + Do(ctx). + Into(result) + return +} + +// PatchExtended applies the patch and returns the patched testType. +func (c *testTypes) PatchExtended(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *extensionsv1.TestType, err error) { + result = &extensionsv1.TestType{} + err = c.GetClient().Patch(pt). + Namespace(c.GetNamespace()). + Resource("testtypes"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyExtended takes the given apply declarative configuration, applies it and returns the applied testType. +func (c *testTypes) ApplyExtended(ctx context.Context, testType *applyconfigurationextensionsv1.TestTypeApplyConfiguration, opts metav1.ApplyOptions) (result *extensionsv1.TestType, err error) { + if testType == nil { + return nil, fmt.Errorf("testType provided to ApplyExtended must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(testType) + if err != nil { + return nil, err + } + name := testType.Name + if name == nil { + return nil, fmt.Errorf("testType.Name must be provided to ApplyExtended") + } + result = &extensionsv1.TestType{} + err = c.GetClient().Patch(types.ApplyPatchType). + Namespace(c.GetNamespace()). + Resource("testtypes"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// GetSubresource takes name of the testType, and returns the corresponding extensionsv1.TestSubresource object, and an error if there is any. +func (c *testTypes) GetSubresource(ctx context.Context, testTypeName string, options metav1.GetOptions) (result *extensionsv1.TestSubresource, err error) { + result = &extensionsv1.TestSubresource{} + err = c.GetClient().Get(). + Namespace(c.GetNamespace()). + Resource("testtypes"). + Name(testTypeName). + SubResource("testsubresource"). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// CreateSubresource takes the representation of a testSubresource and creates it. Returns the server's representation of the testSubresource, and an error, if there is any. +func (c *testTypes) CreateSubresource(ctx context.Context, testTypeName string, testSubresource *extensionsv1.TestSubresource, opts metav1.CreateOptions) (result *extensionsv1.TestSubresource, err error) { + result = &extensionsv1.TestSubresource{} + err = c.GetClient().Post(). + Namespace(c.GetNamespace()). + Resource("testtypes"). + Name(testTypeName). + SubResource("testsubresource"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(testSubresource). + Do(ctx). + Into(result) + return +} + +// UpdateSubresource takes the top resource name and the representation of a testSubresource and updates it. Returns the server's representation of the testSubresource, and an error, if there is any. +func (c *testTypes) UpdateSubresource(ctx context.Context, testTypeName string, testSubresource *extensionsv1.TestSubresource, opts metav1.UpdateOptions) (result *extensionsv1.TestSubresource, err error) { + result = &extensionsv1.TestSubresource{} + err = c.GetClient().Put(). + Namespace(c.GetNamespace()). + Resource("testtypes"). + Name(testTypeName). + SubResource("subresource"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(testSubresource). + Do(ctx). + Into(result) + return +} + +// ApplySubresource takes top resource name and the apply declarative configuration for subresource, +// applies it and returns the applied testSubresource, and an error, if there is any. +func (c *testTypes) ApplySubresource(ctx context.Context, testTypeName string, testSubresource *applyconfigurationextensionsv1.TestSubresourceApplyConfiguration, opts metav1.ApplyOptions) (result *extensionsv1.TestSubresource, err error) { + if testSubresource == nil { + return nil, fmt.Errorf("testSubresource provided to ApplySubresource must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(testSubresource) + if err != nil { + return nil, err + } + + result = &extensionsv1.TestSubresource{} + err = c.GetClient().Patch(types.ApplyPatchType). + Namespace(c.GetNamespace()). + Resource("testtypes"). + Name(testTypeName). + SubResource("subresource"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/extensions/interface.go b/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/extensions/interface.go new file mode 100644 index 00000000000..5f271ea464f --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/extensions/interface.go @@ -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 extensions + +import ( + v1 "k8s.io/code-generator/examples/crd/informers/externalversions/extensions/v1" + internalinterfaces "k8s.io/code-generator/examples/crd/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) +} diff --git a/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/extensions/v1/interface.go b/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/extensions/v1/interface.go new file mode 100644 index 00000000000..d6c18a3a63e --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/extensions/v1/interface.go @@ -0,0 +1,45 @@ +/* +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/crd/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // TestTypes returns a TestTypeInformer. + TestTypes() TestTypeInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// TestTypes returns a TestTypeInformer. +func (v *version) TestTypes() TestTypeInformer { + return &testTypeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/extensions/v1/testtype.go b/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/extensions/v1/testtype.go new file mode 100644 index 00000000000..224f564baed --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/extensions/v1/testtype.go @@ -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 informer-gen. DO NOT EDIT. + +package v1 + +import ( + context "context" + 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" + apisextensionsv1 "k8s.io/code-generator/examples/crd/apis/extensions/v1" + versioned "k8s.io/code-generator/examples/crd/clientset/versioned" + internalinterfaces "k8s.io/code-generator/examples/crd/informers/externalversions/internalinterfaces" + extensionsv1 "k8s.io/code-generator/examples/crd/listers/extensions/v1" +) + +// TestTypeInformer provides access to a shared informer and lister for +// TestTypes. +type TestTypeInformer interface { + Informer() cache.SharedIndexInformer + Lister() extensionsv1.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.ExtensionsExampleV1().TestTypes(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ExtensionsExampleV1().TestTypes(namespace).Watch(context.TODO(), options) + }, + }, + &apisextensionsv1.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(&apisextensionsv1.TestType{}, f.defaultInformer) +} + +func (f *testTypeInformer) Lister() extensionsv1.TestTypeLister { + return extensionsv1.NewTestTypeLister(f.Informer().GetIndexer()) +} diff --git a/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/factory.go b/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/factory.go index f5bf1c2adbc..7723edb85b6 100644 --- a/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/factory.go +++ b/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/factory.go @@ -31,6 +31,7 @@ import ( conflicting "k8s.io/code-generator/examples/crd/informers/externalversions/conflicting" example "k8s.io/code-generator/examples/crd/informers/externalversions/example" example2 "k8s.io/code-generator/examples/crd/informers/externalversions/example2" + extensions "k8s.io/code-generator/examples/crd/informers/externalversions/extensions" internalinterfaces "k8s.io/code-generator/examples/crd/informers/externalversions/internalinterfaces" ) @@ -259,6 +260,7 @@ type SharedInformerFactory interface { ConflictingExample() conflicting.Interface Example() example.Interface SecondExample() example2.Interface + ExtensionsExample() extensions.Interface } func (f *sharedInformerFactory) ConflictingExample() conflicting.Interface { @@ -272,3 +274,7 @@ func (f *sharedInformerFactory) Example() example.Interface { func (f *sharedInformerFactory) SecondExample() example2.Interface { return example2.New(f, f.namespace, f.tweakListOptions) } + +func (f *sharedInformerFactory) ExtensionsExample() extensions.Interface { + return extensions.New(f, f.namespace, f.tweakListOptions) +} diff --git a/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/generic.go b/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/generic.go index 54b9cfbb93d..97c23d6e3d7 100644 --- a/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/generic.go +++ b/staging/src/k8s.io/code-generator/examples/crd/informers/externalversions/generic.go @@ -26,6 +26,7 @@ import ( v1 "k8s.io/code-generator/examples/crd/apis/conflicting/v1" examplev1 "k8s.io/code-generator/examples/crd/apis/example/v1" example2v1 "k8s.io/code-generator/examples/crd/apis/example2/v1" + extensionsv1 "k8s.io/code-generator/examples/crd/apis/extensions/v1" ) // GenericInformer is type of SharedIndexInformer which will locate and delegate to other @@ -68,6 +69,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case example2v1.SchemeGroupVersion.WithResource("testtypes"): return &genericInformer{resource: resource.GroupResource(), informer: f.SecondExample().V1().TestTypes().Informer()}, nil + // Group=extensions.test.crd.code-generator.k8s.io, Version=v1 + case extensionsv1.SchemeGroupVersion.WithResource("testtypes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.ExtensionsExample().V1().TestTypes().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/staging/src/k8s.io/code-generator/examples/crd/listers/extensions/v1/expansion_generated.go b/staging/src/k8s.io/code-generator/examples/crd/listers/extensions/v1/expansion_generated.go new file mode 100644 index 00000000000..0192e05f0d1 --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/listers/extensions/v1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +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 + +// TestTypeListerExpansion allows custom methods to be added to +// TestTypeLister. +type TestTypeListerExpansion interface{} + +// TestTypeNamespaceListerExpansion allows custom methods to be added to +// TestTypeNamespaceLister. +type TestTypeNamespaceListerExpansion interface{} diff --git a/staging/src/k8s.io/code-generator/examples/crd/listers/extensions/v1/testtype.go b/staging/src/k8s.io/code-generator/examples/crd/listers/extensions/v1/testtype.go new file mode 100644 index 00000000000..573b9535b9b --- /dev/null +++ b/staging/src/k8s.io/code-generator/examples/crd/listers/extensions/v1/testtype.go @@ -0,0 +1,70 @@ +/* +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 ( + labels "k8s.io/apimachinery/pkg/labels" + listers "k8s.io/client-go/listers" + cache "k8s.io/client-go/tools/cache" + extensionsv1 "k8s.io/code-generator/examples/crd/apis/extensions/v1" +) + +// TestTypeLister helps list TestTypes. +// All objects returned here must be treated as read-only. +type TestTypeLister interface { + // List lists all TestTypes in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*extensionsv1.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 { + listers.ResourceIndexer[*extensionsv1.TestType] +} + +// NewTestTypeLister returns a new TestTypeLister. +func NewTestTypeLister(indexer cache.Indexer) TestTypeLister { + return &testTypeLister{listers.New[*extensionsv1.TestType](indexer, extensionsv1.Resource("testtype"))} +} + +// TestTypes returns an object that can list and get TestTypes. +func (s *testTypeLister) TestTypes(namespace string) TestTypeNamespaceLister { + return testTypeNamespaceLister{listers.NewNamespaced[*extensionsv1.TestType](s.ResourceIndexer, namespace)} +} + +// TestTypeNamespaceLister helps list and get TestTypes. +// All objects returned here must be treated as read-only. +type TestTypeNamespaceLister interface { + // List lists all TestTypes in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*extensionsv1.TestType, err error) + // Get retrieves the TestType from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*extensionsv1.TestType, error) + TestTypeNamespaceListerExpansion +} + +// testTypeNamespaceLister implements the TestTypeNamespaceLister +// interface. +type testTypeNamespaceLister struct { + listers.ResourceIndexer[*extensionsv1.TestType] +}