From 634fb1b93658f2a8624d79401f645b516b26c09e Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Wed, 1 Feb 2023 12:30:44 +0100 Subject: [PATCH] Update client examples with generated apply configurations --- .../applyconfiguration/cr/v1/example.go | 219 +++++++++++++++++ .../applyconfiguration/cr/v1/examplespec.go | 48 ++++ .../applyconfiguration/cr/v1/examplestatus.go | 52 +++++ .../applyconfiguration/internal/internal.go | 62 +++++ .../pkg/client/applyconfiguration/utils.go | 41 ++++ .../versioned/typed/cr/v1/example.go | 30 +++ .../typed/cr/v1/fake/fake_example.go | 25 ++ .../applyconfiguration/internal/internal.go | 62 +++++ .../pkg/generated/applyconfiguration/utils.go | 49 ++++ .../wardle/v1alpha1/fischer.go | 211 +++++++++++++++++ .../wardle/v1alpha1/flunder.go | 220 ++++++++++++++++++ .../wardle/v1alpha1/flunderspec.go | 52 +++++ .../wardle/v1beta1/flunder.go | 220 ++++++++++++++++++ .../wardle/v1beta1/flunderspec.go | 61 +++++ .../wardle/v1alpha1/fake/fake_fischer.go | 24 ++ .../wardle/v1alpha1/fake/fake_flunder.go | 48 ++++ .../typed/wardle/v1alpha1/fischer.go | 29 +++ .../typed/wardle/v1alpha1/flunder.go | 61 +++++ .../typed/wardle/v1beta1/fake/fake_flunder.go | 48 ++++ .../versioned/typed/wardle/v1beta1/flunder.go | 61 +++++ 20 files changed, 1623 insertions(+) create mode 100644 staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1/example.go create mode 100644 staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1/examplespec.go create mode 100644 staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1/examplestatus.go create mode 100644 staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/internal/internal.go create mode 100644 staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/utils.go create mode 100644 staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/internal/internal.go create mode 100644 staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/utils.go create mode 100644 staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/fischer.go create mode 100644 staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/flunder.go create mode 100644 staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/flunderspec.go create mode 100644 staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1/flunder.go create mode 100644 staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1/flunderspec.go diff --git a/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1/example.go b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1/example.go new file mode 100644 index 00000000000..2d29303a8d3 --- /dev/null +++ b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1/example.go @@ -0,0 +1,219 @@ +/* +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/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// ExampleApplyConfiguration represents an declarative configuration of the Example type for use +// with apply. +type ExampleApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *ExampleSpecApplyConfiguration `json:"spec,omitempty"` + Status *ExampleStatusApplyConfiguration `json:"status,omitempty"` +} + +// Example constructs an declarative configuration of the Example type for use with +// apply. +func Example(name, namespace string) *ExampleApplyConfiguration { + b := &ExampleApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("Example") + b.WithAPIVersion("cr.example.apiextensions.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 *ExampleApplyConfiguration) WithKind(value string) *ExampleApplyConfiguration { + b.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 *ExampleApplyConfiguration) WithAPIVersion(value string) *ExampleApplyConfiguration { + b.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 *ExampleApplyConfiguration) WithName(value string) *ExampleApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *ExampleApplyConfiguration) WithGenerateName(value string) *ExampleApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *ExampleApplyConfiguration) WithNamespace(value string) *ExampleApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *ExampleApplyConfiguration) WithUID(value types.UID) *ExampleApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *ExampleApplyConfiguration) WithResourceVersion(value string) *ExampleApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *ExampleApplyConfiguration) WithGeneration(value int64) *ExampleApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *ExampleApplyConfiguration) WithCreationTimestamp(value metav1.Time) *ExampleApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *ExampleApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *ExampleApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *ExampleApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ExampleApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *ExampleApplyConfiguration) WithLabels(entries map[string]string) *ExampleApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.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 *ExampleApplyConfiguration) WithAnnotations(entries map[string]string) *ExampleApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.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 *ExampleApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *ExampleApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.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 *ExampleApplyConfiguration) WithFinalizers(values ...string) *ExampleApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *ExampleApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec 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 Spec field is set to the value of the last call. +func (b *ExampleApplyConfiguration) WithSpec(value *ExampleSpecApplyConfiguration) *ExampleApplyConfiguration { + b.Spec = value + return b +} + +// 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 *ExampleApplyConfiguration) WithStatus(value *ExampleStatusApplyConfiguration) *ExampleApplyConfiguration { + b.Status = value + return b +} diff --git a/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1/examplespec.go b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1/examplespec.go new file mode 100644 index 00000000000..46d67835be4 --- /dev/null +++ b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1/examplespec.go @@ -0,0 +1,48 @@ +/* +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 + +// ExampleSpecApplyConfiguration represents an declarative configuration of the ExampleSpec type for use +// with apply. +type ExampleSpecApplyConfiguration struct { + Foo *string `json:"foo,omitempty"` + Bar *bool `json:"bar,omitempty"` +} + +// ExampleSpecApplyConfiguration constructs an declarative configuration of the ExampleSpec type for use with +// apply. +func ExampleSpec() *ExampleSpecApplyConfiguration { + return &ExampleSpecApplyConfiguration{} +} + +// WithFoo sets the Foo 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 Foo field is set to the value of the last call. +func (b *ExampleSpecApplyConfiguration) WithFoo(value string) *ExampleSpecApplyConfiguration { + b.Foo = &value + return b +} + +// WithBar sets the Bar 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 Bar field is set to the value of the last call. +func (b *ExampleSpecApplyConfiguration) WithBar(value bool) *ExampleSpecApplyConfiguration { + b.Bar = &value + return b +} diff --git a/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1/examplestatus.go b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1/examplestatus.go new file mode 100644 index 00000000000..ca1b36fae04 --- /dev/null +++ b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1/examplestatus.go @@ -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 applyconfiguration-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" +) + +// ExampleStatusApplyConfiguration represents an declarative configuration of the ExampleStatus type for use +// with apply. +type ExampleStatusApplyConfiguration struct { + State *v1.ExampleState `json:"state,omitempty"` + Message *string `json:"message,omitempty"` +} + +// ExampleStatusApplyConfiguration constructs an declarative configuration of the ExampleStatus type for use with +// apply. +func ExampleStatus() *ExampleStatusApplyConfiguration { + return &ExampleStatusApplyConfiguration{} +} + +// WithState sets the State 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 State field is set to the value of the last call. +func (b *ExampleStatusApplyConfiguration) WithState(value v1.ExampleState) *ExampleStatusApplyConfiguration { + b.State = &value + return b +} + +// WithMessage sets the Message 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 Message field is set to the value of the last call. +func (b *ExampleStatusApplyConfiguration) WithMessage(value string) *ExampleStatusApplyConfiguration { + b.Message = &value + return b +} diff --git a/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/internal/internal.go b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/internal/internal.go new file mode 100644 index 00000000000..4d7ef1313fb --- /dev/null +++ b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/internal/internal.go @@ -0,0 +1,62 @@ +/* +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 internal + +import ( + "fmt" + "sync" + + typed "sigs.k8s.io/structured-merge-diff/v4/typed" +) + +func Parser() *typed.Parser { + parserOnce.Do(func() { + var err error + parser, err = typed.NewParser(schemaYAML) + if err != nil { + panic(fmt.Sprintf("Failed to parse schema: %v", err)) + } + }) + return parser +} + +var parserOnce sync.Once +var parser *typed.Parser +var schemaYAML = typed.YAMLObject(`types: +- name: __untyped_atomic_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic +- name: __untyped_deduced_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +`) diff --git a/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/utils.go b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/utils.go new file mode 100644 index 00000000000..f7e26e0f0f8 --- /dev/null +++ b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/utils.go @@ -0,0 +1,41 @@ +/* +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 applyconfiguration + +import ( + v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" + crv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1" + schema "k8s.io/apimachinery/pkg/runtime/schema" +) + +// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no +// apply configuration type exists for the given GroupVersionKind. +func ForKind(kind schema.GroupVersionKind) interface{} { + switch kind { + // Group=cr.example.apiextensions.k8s.io, Version=v1 + case v1.SchemeGroupVersion.WithKind("Example"): + return &crv1.ExampleApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("ExampleSpec"): + return &crv1.ExampleSpecApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("ExampleStatus"): + return &crv1.ExampleStatusApplyConfiguration{} + + } + return nil +} diff --git a/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/example.go b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/example.go index dfb8a54df70..1bbe8d88db4 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/example.go +++ b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/example.go @@ -20,9 +20,12 @@ package v1 import ( "context" + json "encoding/json" + "fmt" "time" v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" + crv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1" scheme "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/scheme" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" @@ -46,6 +49,7 @@ type ExampleInterface interface { List(ctx context.Context, opts metav1.ListOptions) (*v1.ExampleList, 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 *v1.Example, err error) + Apply(ctx context.Context, example *crv1.ExampleApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Example, err error) ExampleExpansion } @@ -176,3 +180,29 @@ func (c *examples) Patch(ctx context.Context, name string, pt types.PatchType, d Into(result) return } + +// Apply takes the given apply declarative configuration, applies it and returns the applied example. +func (c *examples) Apply(ctx context.Context, example *crv1.ExampleApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Example, err error) { + if example == nil { + return nil, fmt.Errorf("example provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(example) + if err != nil { + return nil, err + } + name := example.Name + if name == nil { + return nil, fmt.Errorf("example.Name must be provided to Apply") + } + result = &v1.Example{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("examples"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_example.go b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_example.go index eae8365a437..409b62ad5db 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_example.go +++ b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_example.go @@ -20,8 +20,11 @@ package fake import ( "context" + json "encoding/json" + "fmt" v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" + crv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" types "k8s.io/apimachinery/pkg/types" @@ -127,3 +130,25 @@ func (c *FakeExamples) Patch(ctx context.Context, name string, pt types.PatchTyp } return obj.(*v1.Example), err } + +// Apply takes the given apply declarative configuration, applies it and returns the applied example. +func (c *FakeExamples) Apply(ctx context.Context, example *crv1.ExampleApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Example, err error) { + if example == nil { + return nil, fmt.Errorf("example provided to Apply must not be nil") + } + data, err := json.Marshal(example) + if err != nil { + return nil, err + } + name := example.Name + if name == nil { + return nil, fmt.Errorf("example.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(examplesResource, c.ns, *name, types.ApplyPatchType, data), &v1.Example{}) + + if obj == nil { + return nil, err + } + return obj.(*v1.Example), err +} diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/internal/internal.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/internal/internal.go new file mode 100644 index 00000000000..4d7ef1313fb --- /dev/null +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/internal/internal.go @@ -0,0 +1,62 @@ +/* +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 internal + +import ( + "fmt" + "sync" + + typed "sigs.k8s.io/structured-merge-diff/v4/typed" +) + +func Parser() *typed.Parser { + parserOnce.Do(func() { + var err error + parser, err = typed.NewParser(schemaYAML) + if err != nil { + panic(fmt.Sprintf("Failed to parse schema: %v", err)) + } + }) + return parser +} + +var parserOnce sync.Once +var parser *typed.Parser +var schemaYAML = typed.YAMLObject(`types: +- name: __untyped_atomic_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic +- name: __untyped_deduced_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +`) diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/utils.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/utils.go new file mode 100644 index 00000000000..94166b810de --- /dev/null +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/utils.go @@ -0,0 +1,49 @@ +/* +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 applyconfiguration + +import ( + schema "k8s.io/apimachinery/pkg/runtime/schema" + v1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" + v1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" + wardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1" + wardlev1beta1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1" +) + +// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no +// apply configuration type exists for the given GroupVersionKind. +func ForKind(kind schema.GroupVersionKind) interface{} { + switch kind { + // Group=wardle.example.com, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithKind("Fischer"): + return &wardlev1alpha1.FischerApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Flunder"): + return &wardlev1alpha1.FlunderApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("FlunderSpec"): + return &wardlev1alpha1.FlunderSpecApplyConfiguration{} + + // Group=wardle.example.com, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithKind("Flunder"): + return &wardlev1beta1.FlunderApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("FlunderSpec"): + return &wardlev1beta1.FlunderSpecApplyConfiguration{} + + } + return nil +} diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/fischer.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/fischer.go new file mode 100644 index 00000000000..f43db39b33c --- /dev/null +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/fischer.go @@ -0,0 +1,211 @@ +/* +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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// FischerApplyConfiguration represents an declarative configuration of the Fischer type for use +// with apply. +type FischerApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + DisallowedFlunders []string `json:"disallowedFlunders,omitempty"` +} + +// Fischer constructs an declarative configuration of the Fischer type for use with +// apply. +func Fischer(name string) *FischerApplyConfiguration { + b := &FischerApplyConfiguration{} + b.WithName(name) + b.WithKind("Fischer") + b.WithAPIVersion("wardle.example.com/v1alpha1") + 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 *FischerApplyConfiguration) WithKind(value string) *FischerApplyConfiguration { + b.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 *FischerApplyConfiguration) WithAPIVersion(value string) *FischerApplyConfiguration { + b.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 *FischerApplyConfiguration) WithName(value string) *FischerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FischerApplyConfiguration) WithGenerateName(value string) *FischerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FischerApplyConfiguration) WithNamespace(value string) *FischerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FischerApplyConfiguration) WithUID(value types.UID) *FischerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FischerApplyConfiguration) WithResourceVersion(value string) *FischerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FischerApplyConfiguration) WithGeneration(value int64) *FischerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FischerApplyConfiguration) WithCreationTimestamp(value metav1.Time) *FischerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FischerApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *FischerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FischerApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *FischerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FischerApplyConfiguration) WithLabels(entries map[string]string) *FischerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.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 *FischerApplyConfiguration) WithAnnotations(entries map[string]string) *FischerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.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 *FischerApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *FischerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.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 *FischerApplyConfiguration) WithFinalizers(values ...string) *FischerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *FischerApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithDisallowedFlunders adds the given value to the DisallowedFlunders 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 DisallowedFlunders field. +func (b *FischerApplyConfiguration) WithDisallowedFlunders(values ...string) *FischerApplyConfiguration { + for i := range values { + b.DisallowedFlunders = append(b.DisallowedFlunders, values[i]) + } + return b +} diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/flunder.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/flunder.go new file mode 100644 index 00000000000..cec5c33de2f --- /dev/null +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/flunder.go @@ -0,0 +1,220 @@ +/* +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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" + wardlev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" +) + +// FlunderApplyConfiguration represents an declarative configuration of the Flunder type for use +// with apply. +type FlunderApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *FlunderSpecApplyConfiguration `json:"spec,omitempty"` + Status *wardlev1alpha1.FlunderStatus `json:"status,omitempty"` +} + +// Flunder constructs an declarative configuration of the Flunder type for use with +// apply. +func Flunder(name, namespace string) *FlunderApplyConfiguration { + b := &FlunderApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("Flunder") + b.WithAPIVersion("wardle.example.com/v1alpha1") + 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 *FlunderApplyConfiguration) WithKind(value string) *FlunderApplyConfiguration { + b.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 *FlunderApplyConfiguration) WithAPIVersion(value string) *FlunderApplyConfiguration { + b.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 *FlunderApplyConfiguration) WithName(value string) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithGenerateName(value string) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithNamespace(value string) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithUID(value types.UID) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithResourceVersion(value string) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithGeneration(value int64) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithCreationTimestamp(value metav1.Time) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithLabels(entries map[string]string) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.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 *FlunderApplyConfiguration) WithAnnotations(entries map[string]string) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.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 *FlunderApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.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 *FlunderApplyConfiguration) WithFinalizers(values ...string) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *FlunderApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec 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 Spec field is set to the value of the last call. +func (b *FlunderApplyConfiguration) WithSpec(value *FlunderSpecApplyConfiguration) *FlunderApplyConfiguration { + b.Spec = value + return b +} + +// 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 *FlunderApplyConfiguration) WithStatus(value wardlev1alpha1.FlunderStatus) *FlunderApplyConfiguration { + b.Status = &value + return b +} diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/flunderspec.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/flunderspec.go new file mode 100644 index 00000000000..dd7844a537b --- /dev/null +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/flunderspec.go @@ -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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" +) + +// FlunderSpecApplyConfiguration represents an declarative configuration of the FlunderSpec type for use +// with apply. +type FlunderSpecApplyConfiguration struct { + Reference *string `json:"reference,omitempty"` + ReferenceType *v1alpha1.ReferenceType `json:"referenceType,omitempty"` +} + +// FlunderSpecApplyConfiguration constructs an declarative configuration of the FlunderSpec type for use with +// apply. +func FlunderSpec() *FlunderSpecApplyConfiguration { + return &FlunderSpecApplyConfiguration{} +} + +// WithReference sets the Reference 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 Reference field is set to the value of the last call. +func (b *FlunderSpecApplyConfiguration) WithReference(value string) *FlunderSpecApplyConfiguration { + b.Reference = &value + return b +} + +// WithReferenceType sets the ReferenceType 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 ReferenceType field is set to the value of the last call. +func (b *FlunderSpecApplyConfiguration) WithReferenceType(value v1alpha1.ReferenceType) *FlunderSpecApplyConfiguration { + b.ReferenceType = &value + return b +} diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1/flunder.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1/flunder.go new file mode 100644 index 00000000000..ff69086603e --- /dev/null +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1/flunder.go @@ -0,0 +1,220 @@ +/* +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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" + wardlev1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" +) + +// FlunderApplyConfiguration represents an declarative configuration of the Flunder type for use +// with apply. +type FlunderApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *FlunderSpecApplyConfiguration `json:"spec,omitempty"` + Status *wardlev1beta1.FlunderStatus `json:"status,omitempty"` +} + +// Flunder constructs an declarative configuration of the Flunder type for use with +// apply. +func Flunder(name, namespace string) *FlunderApplyConfiguration { + b := &FlunderApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("Flunder") + b.WithAPIVersion("wardle.example.com/v1beta1") + 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 *FlunderApplyConfiguration) WithKind(value string) *FlunderApplyConfiguration { + b.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 *FlunderApplyConfiguration) WithAPIVersion(value string) *FlunderApplyConfiguration { + b.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 *FlunderApplyConfiguration) WithName(value string) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithGenerateName(value string) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithNamespace(value string) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithUID(value types.UID) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithResourceVersion(value string) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithGeneration(value int64) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithCreationTimestamp(value metav1.Time) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *FlunderApplyConfiguration) WithLabels(entries map[string]string) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.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 *FlunderApplyConfiguration) WithAnnotations(entries map[string]string) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.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 *FlunderApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.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 *FlunderApplyConfiguration) WithFinalizers(values ...string) *FlunderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *FlunderApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec 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 Spec field is set to the value of the last call. +func (b *FlunderApplyConfiguration) WithSpec(value *FlunderSpecApplyConfiguration) *FlunderApplyConfiguration { + b.Spec = value + return b +} + +// 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 *FlunderApplyConfiguration) WithStatus(value wardlev1beta1.FlunderStatus) *FlunderApplyConfiguration { + b.Status = &value + return b +} diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1/flunderspec.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1/flunderspec.go new file mode 100644 index 00000000000..b88c4e52d4b --- /dev/null +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1/flunderspec.go @@ -0,0 +1,61 @@ +/* +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 v1beta1 + +import ( + v1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" +) + +// FlunderSpecApplyConfiguration represents an declarative configuration of the FlunderSpec type for use +// with apply. +type FlunderSpecApplyConfiguration struct { + FlunderReference *string `json:"flunderReference,omitempty"` + FischerReference *string `json:"fischerReference,omitempty"` + ReferenceType *v1beta1.ReferenceType `json:"referenceType,omitempty"` +} + +// FlunderSpecApplyConfiguration constructs an declarative configuration of the FlunderSpec type for use with +// apply. +func FlunderSpec() *FlunderSpecApplyConfiguration { + return &FlunderSpecApplyConfiguration{} +} + +// WithFlunderReference sets the FlunderReference 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 FlunderReference field is set to the value of the last call. +func (b *FlunderSpecApplyConfiguration) WithFlunderReference(value string) *FlunderSpecApplyConfiguration { + b.FlunderReference = &value + return b +} + +// WithFischerReference sets the FischerReference 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 FischerReference field is set to the value of the last call. +func (b *FlunderSpecApplyConfiguration) WithFischerReference(value string) *FlunderSpecApplyConfiguration { + b.FischerReference = &value + return b +} + +// WithReferenceType sets the ReferenceType 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 ReferenceType field is set to the value of the last call. +func (b *FlunderSpecApplyConfiguration) WithReferenceType(value v1beta1.ReferenceType) *FlunderSpecApplyConfiguration { + b.ReferenceType = &value + return b +} diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fake/fake_fischer.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fake/fake_fischer.go index 5ae13af0974..8f0deb2b6bf 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fake/fake_fischer.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fake/fake_fischer.go @@ -20,6 +20,8 @@ package fake import ( "context" + json "encoding/json" + "fmt" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -27,6 +29,7 @@ import ( watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" v1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" + wardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1" ) // FakeFischers implements FischerInterface @@ -119,3 +122,24 @@ func (c *FakeFischers) Patch(ctx context.Context, name string, pt types.PatchTyp } return obj.(*v1alpha1.Fischer), err } + +// Apply takes the given apply declarative configuration, applies it and returns the applied fischer. +func (c *FakeFischers) Apply(ctx context.Context, fischer *wardlev1alpha1.FischerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Fischer, err error) { + if fischer == nil { + return nil, fmt.Errorf("fischer provided to Apply must not be nil") + } + data, err := json.Marshal(fischer) + if err != nil { + return nil, err + } + name := fischer.Name + if name == nil { + return nil, fmt.Errorf("fischer.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(fischersResource, *name, types.ApplyPatchType, data), &v1alpha1.Fischer{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Fischer), err +} diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fake/fake_flunder.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fake/fake_flunder.go index 9cc6f6dc61e..d77f55750f9 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fake/fake_flunder.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fake/fake_flunder.go @@ -20,6 +20,8 @@ package fake import ( "context" + json "encoding/json" + "fmt" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -27,6 +29,7 @@ import ( watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" v1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" + wardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1" ) // FakeFlunders implements FlunderInterface @@ -139,3 +142,48 @@ func (c *FakeFlunders) Patch(ctx context.Context, name string, pt types.PatchTyp } return obj.(*v1alpha1.Flunder), err } + +// Apply takes the given apply declarative configuration, applies it and returns the applied flunder. +func (c *FakeFlunders) Apply(ctx context.Context, flunder *wardlev1alpha1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Flunder, err error) { + if flunder == nil { + return nil, fmt.Errorf("flunder provided to Apply must not be nil") + } + data, err := json.Marshal(flunder) + if err != nil { + return nil, err + } + name := flunder.Name + if name == nil { + return nil, fmt.Errorf("flunder.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(flundersResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.Flunder{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Flunder), 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 *FakeFlunders) ApplyStatus(ctx context.Context, flunder *wardlev1alpha1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Flunder, err error) { + if flunder == nil { + return nil, fmt.Errorf("flunder provided to Apply must not be nil") + } + data, err := json.Marshal(flunder) + if err != nil { + return nil, err + } + name := flunder.Name + if name == nil { + return nil, fmt.Errorf("flunder.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(flundersResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.Flunder{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Flunder), err +} diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fischer.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fischer.go index d2d9df76c65..57d5546f820 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fischer.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fischer.go @@ -20,6 +20,8 @@ package v1alpha1 import ( "context" + json "encoding/json" + "fmt" "time" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -27,6 +29,7 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" v1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" + wardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1" scheme "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/scheme" ) @@ -46,6 +49,7 @@ type FischerInterface interface { List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.FischerList, error) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Fischer, err error) + Apply(ctx context.Context, fischer *wardlev1alpha1.FischerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Fischer, err error) FischerExpansion } @@ -166,3 +170,28 @@ func (c *fischers) Patch(ctx context.Context, name string, pt types.PatchType, d Into(result) return } + +// Apply takes the given apply declarative configuration, applies it and returns the applied fischer. +func (c *fischers) Apply(ctx context.Context, fischer *wardlev1alpha1.FischerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Fischer, err error) { + if fischer == nil { + return nil, fmt.Errorf("fischer provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(fischer) + if err != nil { + return nil, err + } + name := fischer.Name + if name == nil { + return nil, fmt.Errorf("fischer.Name must be provided to Apply") + } + result = &v1alpha1.Fischer{} + err = c.client.Patch(types.ApplyPatchType). + Resource("fischers"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/flunder.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/flunder.go index 30b1f5c297c..d5cb97abf0c 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/flunder.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/flunder.go @@ -20,6 +20,8 @@ package v1alpha1 import ( "context" + json "encoding/json" + "fmt" "time" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -27,6 +29,7 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" v1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" + wardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1" scheme "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/scheme" ) @@ -47,6 +50,8 @@ type FlunderInterface interface { List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.FlunderList, error) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Flunder, err error) + Apply(ctx context.Context, flunder *wardlev1alpha1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Flunder, err error) + ApplyStatus(ctx context.Context, flunder *wardlev1alpha1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Flunder, err error) FlunderExpansion } @@ -193,3 +198,59 @@ func (c *flunders) Patch(ctx context.Context, name string, pt types.PatchType, d Into(result) return } + +// Apply takes the given apply declarative configuration, applies it and returns the applied flunder. +func (c *flunders) Apply(ctx context.Context, flunder *wardlev1alpha1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Flunder, err error) { + if flunder == nil { + return nil, fmt.Errorf("flunder provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(flunder) + if err != nil { + return nil, err + } + name := flunder.Name + if name == nil { + return nil, fmt.Errorf("flunder.Name must be provided to Apply") + } + result = &v1alpha1.Flunder{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("flunders"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *flunders) ApplyStatus(ctx context.Context, flunder *wardlev1alpha1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Flunder, err error) { + if flunder == nil { + return nil, fmt.Errorf("flunder provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(flunder) + if err != nil { + return nil, err + } + + name := flunder.Name + if name == nil { + return nil, fmt.Errorf("flunder.Name must be provided to Apply") + } + + result = &v1alpha1.Flunder{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("flunders"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1/fake/fake_flunder.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1/fake/fake_flunder.go index 7b73aca15ce..590fa746ff6 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1/fake/fake_flunder.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1/fake/fake_flunder.go @@ -20,6 +20,8 @@ package fake import ( "context" + json "encoding/json" + "fmt" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -27,6 +29,7 @@ import ( watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" v1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" + wardlev1beta1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1" ) // FakeFlunders implements FlunderInterface @@ -139,3 +142,48 @@ func (c *FakeFlunders) Patch(ctx context.Context, name string, pt types.PatchTyp } return obj.(*v1beta1.Flunder), err } + +// Apply takes the given apply declarative configuration, applies it and returns the applied flunder. +func (c *FakeFlunders) Apply(ctx context.Context, flunder *wardlev1beta1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Flunder, err error) { + if flunder == nil { + return nil, fmt.Errorf("flunder provided to Apply must not be nil") + } + data, err := json.Marshal(flunder) + if err != nil { + return nil, err + } + name := flunder.Name + if name == nil { + return nil, fmt.Errorf("flunder.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(flundersResource, c.ns, *name, types.ApplyPatchType, data), &v1beta1.Flunder{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Flunder), 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 *FakeFlunders) ApplyStatus(ctx context.Context, flunder *wardlev1beta1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Flunder, err error) { + if flunder == nil { + return nil, fmt.Errorf("flunder provided to Apply must not be nil") + } + data, err := json.Marshal(flunder) + if err != nil { + return nil, err + } + name := flunder.Name + if name == nil { + return nil, fmt.Errorf("flunder.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(flundersResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1beta1.Flunder{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Flunder), err +} diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1/flunder.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1/flunder.go index 9afcb3a17d5..c3b1c646c75 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1/flunder.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1/flunder.go @@ -20,6 +20,8 @@ package v1beta1 import ( "context" + json "encoding/json" + "fmt" "time" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -27,6 +29,7 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" v1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" + wardlev1beta1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1" scheme "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/scheme" ) @@ -47,6 +50,8 @@ type FlunderInterface interface { List(ctx context.Context, opts v1.ListOptions) (*v1beta1.FlunderList, error) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Flunder, err error) + Apply(ctx context.Context, flunder *wardlev1beta1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Flunder, err error) + ApplyStatus(ctx context.Context, flunder *wardlev1beta1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Flunder, err error) FlunderExpansion } @@ -193,3 +198,59 @@ func (c *flunders) Patch(ctx context.Context, name string, pt types.PatchType, d Into(result) return } + +// Apply takes the given apply declarative configuration, applies it and returns the applied flunder. +func (c *flunders) Apply(ctx context.Context, flunder *wardlev1beta1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Flunder, err error) { + if flunder == nil { + return nil, fmt.Errorf("flunder provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(flunder) + if err != nil { + return nil, err + } + name := flunder.Name + if name == nil { + return nil, fmt.Errorf("flunder.Name must be provided to Apply") + } + result = &v1beta1.Flunder{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("flunders"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *flunders) ApplyStatus(ctx context.Context, flunder *wardlev1beta1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Flunder, err error) { + if flunder == nil { + return nil, fmt.Errorf("flunder provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(flunder) + if err != nil { + return nil, err + } + + name := flunder.Name + if name == nil { + return nil, fmt.Errorf("flunder.Name must be provided to Apply") + } + + result = &v1beta1.Flunder{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("flunders"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +}