1/* 2Copyright The Kubernetes Authors. 3 4Licensed under the Apache License, Version 2.0 (the "License"); 5you may not use this file except in compliance with the License. 6You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10Unless required by applicable law or agreed to in writing, software 11distributed under the License is distributed on an "AS IS" BASIS, 12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13See the License for the specific language governing permissions and 14limitations under the License. 15*/ 16 17// Code generated by applyconfiguration-gen. DO NOT EDIT. 18 19package v1beta2 20 21import ( 22 appsv1beta2 "k8s.io/api/apps/v1beta2" 23 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 types "k8s.io/apimachinery/pkg/types" 25 managedfields "k8s.io/apimachinery/pkg/util/managedfields" 26 internal "k8s.io/client-go/applyconfigurations/internal" 27 v1 "k8s.io/client-go/applyconfigurations/meta/v1" 28) 29 30// StatefulSetApplyConfiguration represents an declarative configuration of the StatefulSet type for use 31// with apply. 32type StatefulSetApplyConfiguration struct { 33 v1.TypeMetaApplyConfiguration `json:",inline"` 34 *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` 35 Spec *StatefulSetSpecApplyConfiguration `json:"spec,omitempty"` 36 Status *StatefulSetStatusApplyConfiguration `json:"status,omitempty"` 37} 38 39// StatefulSet constructs an declarative configuration of the StatefulSet type for use with 40// apply. 41func StatefulSet(name, namespace string) *StatefulSetApplyConfiguration { 42 b := &StatefulSetApplyConfiguration{} 43 b.WithName(name) 44 b.WithNamespace(namespace) 45 b.WithKind("StatefulSet") 46 b.WithAPIVersion("apps/v1beta2") 47 return b 48} 49 50// ExtractStatefulSet extracts the applied configuration owned by fieldManager from 51// statefulSet. If no managedFields are found in statefulSet for fieldManager, a 52// StatefulSetApplyConfiguration is returned with only the Name, Namespace (if applicable), 53// APIVersion and Kind populated. Is is possible that no managed fields were found for because other 54// field managers have taken ownership of all the fields previously owned by fieldManager, or because 55// the fieldManager never owned fields any fields. 56// statefulSet must be a unmodified StatefulSet API object that was retrieved from the Kubernetes API. 57// ExtractStatefulSet provides a way to perform a extract/modify-in-place/apply workflow. 58// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously 59// applied if another fieldManager has updated or force applied any of the previously applied fields. 60// Experimental! 61func ExtractStatefulSet(statefulSet *appsv1beta2.StatefulSet, fieldManager string) (*StatefulSetApplyConfiguration, error) { 62 b := &StatefulSetApplyConfiguration{} 63 err := managedfields.ExtractInto(statefulSet, internal.Parser().Type("io.k8s.api.apps.v1beta2.StatefulSet"), fieldManager, b) 64 if err != nil { 65 return nil, err 66 } 67 b.WithName(statefulSet.Name) 68 b.WithNamespace(statefulSet.Namespace) 69 70 b.WithKind("StatefulSet") 71 b.WithAPIVersion("apps/v1beta2") 72 return b, nil 73} 74 75// WithKind sets the Kind field in the declarative configuration to the given value 76// and returns the receiver, so that objects can be built by chaining "With" function invocations. 77// If called multiple times, the Kind field is set to the value of the last call. 78func (b *StatefulSetApplyConfiguration) WithKind(value string) *StatefulSetApplyConfiguration { 79 b.Kind = &value 80 return b 81} 82 83// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value 84// and returns the receiver, so that objects can be built by chaining "With" function invocations. 85// If called multiple times, the APIVersion field is set to the value of the last call. 86func (b *StatefulSetApplyConfiguration) WithAPIVersion(value string) *StatefulSetApplyConfiguration { 87 b.APIVersion = &value 88 return b 89} 90 91// WithName sets the Name field in the declarative configuration to the given value 92// and returns the receiver, so that objects can be built by chaining "With" function invocations. 93// If called multiple times, the Name field is set to the value of the last call. 94func (b *StatefulSetApplyConfiguration) WithName(value string) *StatefulSetApplyConfiguration { 95 b.ensureObjectMetaApplyConfigurationExists() 96 b.Name = &value 97 return b 98} 99 100// WithGenerateName sets the GenerateName field in the declarative configuration to the given value 101// and returns the receiver, so that objects can be built by chaining "With" function invocations. 102// If called multiple times, the GenerateName field is set to the value of the last call. 103func (b *StatefulSetApplyConfiguration) WithGenerateName(value string) *StatefulSetApplyConfiguration { 104 b.ensureObjectMetaApplyConfigurationExists() 105 b.GenerateName = &value 106 return b 107} 108 109// WithNamespace sets the Namespace field in the declarative configuration to the given value 110// and returns the receiver, so that objects can be built by chaining "With" function invocations. 111// If called multiple times, the Namespace field is set to the value of the last call. 112func (b *StatefulSetApplyConfiguration) WithNamespace(value string) *StatefulSetApplyConfiguration { 113 b.ensureObjectMetaApplyConfigurationExists() 114 b.Namespace = &value 115 return b 116} 117 118// WithSelfLink sets the SelfLink field in the declarative configuration to the given value 119// and returns the receiver, so that objects can be built by chaining "With" function invocations. 120// If called multiple times, the SelfLink field is set to the value of the last call. 121func (b *StatefulSetApplyConfiguration) WithSelfLink(value string) *StatefulSetApplyConfiguration { 122 b.ensureObjectMetaApplyConfigurationExists() 123 b.SelfLink = &value 124 return b 125} 126 127// WithUID sets the UID field in the declarative configuration to the given value 128// and returns the receiver, so that objects can be built by chaining "With" function invocations. 129// If called multiple times, the UID field is set to the value of the last call. 130func (b *StatefulSetApplyConfiguration) WithUID(value types.UID) *StatefulSetApplyConfiguration { 131 b.ensureObjectMetaApplyConfigurationExists() 132 b.UID = &value 133 return b 134} 135 136// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value 137// and returns the receiver, so that objects can be built by chaining "With" function invocations. 138// If called multiple times, the ResourceVersion field is set to the value of the last call. 139func (b *StatefulSetApplyConfiguration) WithResourceVersion(value string) *StatefulSetApplyConfiguration { 140 b.ensureObjectMetaApplyConfigurationExists() 141 b.ResourceVersion = &value 142 return b 143} 144 145// WithGeneration sets the Generation field in the declarative configuration to the given value 146// and returns the receiver, so that objects can be built by chaining "With" function invocations. 147// If called multiple times, the Generation field is set to the value of the last call. 148func (b *StatefulSetApplyConfiguration) WithGeneration(value int64) *StatefulSetApplyConfiguration { 149 b.ensureObjectMetaApplyConfigurationExists() 150 b.Generation = &value 151 return b 152} 153 154// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value 155// and returns the receiver, so that objects can be built by chaining "With" function invocations. 156// If called multiple times, the CreationTimestamp field is set to the value of the last call. 157func (b *StatefulSetApplyConfiguration) WithCreationTimestamp(value metav1.Time) *StatefulSetApplyConfiguration { 158 b.ensureObjectMetaApplyConfigurationExists() 159 b.CreationTimestamp = &value 160 return b 161} 162 163// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value 164// and returns the receiver, so that objects can be built by chaining "With" function invocations. 165// If called multiple times, the DeletionTimestamp field is set to the value of the last call. 166func (b *StatefulSetApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *StatefulSetApplyConfiguration { 167 b.ensureObjectMetaApplyConfigurationExists() 168 b.DeletionTimestamp = &value 169 return b 170} 171 172// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value 173// and returns the receiver, so that objects can be built by chaining "With" function invocations. 174// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. 175func (b *StatefulSetApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *StatefulSetApplyConfiguration { 176 b.ensureObjectMetaApplyConfigurationExists() 177 b.DeletionGracePeriodSeconds = &value 178 return b 179} 180 181// WithLabels puts the entries into the Labels field in the declarative configuration 182// and returns the receiver, so that objects can be build by chaining "With" function invocations. 183// If called multiple times, the entries provided by each call will be put on the Labels field, 184// overwriting an existing map entries in Labels field with the same key. 185func (b *StatefulSetApplyConfiguration) WithLabels(entries map[string]string) *StatefulSetApplyConfiguration { 186 b.ensureObjectMetaApplyConfigurationExists() 187 if b.Labels == nil && len(entries) > 0 { 188 b.Labels = make(map[string]string, len(entries)) 189 } 190 for k, v := range entries { 191 b.Labels[k] = v 192 } 193 return b 194} 195 196// WithAnnotations puts the entries into the Annotations field in the declarative configuration 197// and returns the receiver, so that objects can be build by chaining "With" function invocations. 198// If called multiple times, the entries provided by each call will be put on the Annotations field, 199// overwriting an existing map entries in Annotations field with the same key. 200func (b *StatefulSetApplyConfiguration) WithAnnotations(entries map[string]string) *StatefulSetApplyConfiguration { 201 b.ensureObjectMetaApplyConfigurationExists() 202 if b.Annotations == nil && len(entries) > 0 { 203 b.Annotations = make(map[string]string, len(entries)) 204 } 205 for k, v := range entries { 206 b.Annotations[k] = v 207 } 208 return b 209} 210 211// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration 212// and returns the receiver, so that objects can be build by chaining "With" function invocations. 213// If called multiple times, values provided by each call will be appended to the OwnerReferences field. 214func (b *StatefulSetApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *StatefulSetApplyConfiguration { 215 b.ensureObjectMetaApplyConfigurationExists() 216 for i := range values { 217 if values[i] == nil { 218 panic("nil value passed to WithOwnerReferences") 219 } 220 b.OwnerReferences = append(b.OwnerReferences, *values[i]) 221 } 222 return b 223} 224 225// WithFinalizers adds the given value to the Finalizers field in the declarative configuration 226// and returns the receiver, so that objects can be build by chaining "With" function invocations. 227// If called multiple times, values provided by each call will be appended to the Finalizers field. 228func (b *StatefulSetApplyConfiguration) WithFinalizers(values ...string) *StatefulSetApplyConfiguration { 229 b.ensureObjectMetaApplyConfigurationExists() 230 for i := range values { 231 b.Finalizers = append(b.Finalizers, values[i]) 232 } 233 return b 234} 235 236// WithClusterName sets the ClusterName field in the declarative configuration to the given value 237// and returns the receiver, so that objects can be built by chaining "With" function invocations. 238// If called multiple times, the ClusterName field is set to the value of the last call. 239func (b *StatefulSetApplyConfiguration) WithClusterName(value string) *StatefulSetApplyConfiguration { 240 b.ensureObjectMetaApplyConfigurationExists() 241 b.ClusterName = &value 242 return b 243} 244 245func (b *StatefulSetApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { 246 if b.ObjectMetaApplyConfiguration == nil { 247 b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} 248 } 249} 250 251// WithSpec sets the Spec field in the declarative configuration to the given value 252// and returns the receiver, so that objects can be built by chaining "With" function invocations. 253// If called multiple times, the Spec field is set to the value of the last call. 254func (b *StatefulSetApplyConfiguration) WithSpec(value *StatefulSetSpecApplyConfiguration) *StatefulSetApplyConfiguration { 255 b.Spec = value 256 return b 257} 258 259// WithStatus sets the Status field in the declarative configuration to the given value 260// and returns the receiver, so that objects can be built by chaining "With" function invocations. 261// If called multiple times, the Status field is set to the value of the last call. 262func (b *StatefulSetApplyConfiguration) WithStatus(value *StatefulSetStatusApplyConfiguration) *StatefulSetApplyConfiguration { 263 b.Status = value 264 return b 265} 266