1 /* 2 Copyright The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 // Code generated by applyconfiguration-gen. DO NOT EDIT. 18 19 package v1 20 21 import ( 22 apiappsv1 "k8s.io/api/apps/v1" 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. 32 type 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. 41 func StatefulSet(name, namespace string) *StatefulSetApplyConfiguration { 42 b := &StatefulSetApplyConfiguration{} 43 b.WithName(name) 44 b.WithNamespace(namespace) 45 b.WithKind("StatefulSet") 46 b.WithAPIVersion("apps/v1") 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. It 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! 61 func ExtractStatefulSet(statefulSet *apiappsv1.StatefulSet, fieldManager string) (*StatefulSetApplyConfiguration, error) { 62 return extractStatefulSet(statefulSet, fieldManager, "") 63 } 64 65 // ExtractStatefulSetStatus is the same as ExtractStatefulSet except 66 // that it extracts the status subresource applied configuration. 67 // Experimental! 68 func ExtractStatefulSetStatus(statefulSet *apiappsv1.StatefulSet, fieldManager string) (*StatefulSetApplyConfiguration, error) { 69 return extractStatefulSet(statefulSet, fieldManager, "status") 70 } 71 72 func extractStatefulSet(statefulSet *apiappsv1.StatefulSet, fieldManager string, subresource string) (*StatefulSetApplyConfiguration, error) { 73 b := &StatefulSetApplyConfiguration{} 74 err := managedfields.ExtractInto(statefulSet, internal.Parser().Type("io.k8s.api.apps.v1.StatefulSet"), fieldManager, b, subresource) 75 if err != nil { 76 return nil, err 77 } 78 b.WithName(statefulSet.Name) 79 b.WithNamespace(statefulSet.Namespace) 80 81 b.WithKind("StatefulSet") 82 b.WithAPIVersion("apps/v1") 83 return b, nil 84 } 85 86 // WithKind sets the Kind field in the declarative configuration to the given value 87 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 88 // If called multiple times, the Kind field is set to the value of the last call. 89 func (b *StatefulSetApplyConfiguration) WithKind(value string) *StatefulSetApplyConfiguration { 90 b.Kind = &value 91 return b 92 } 93 94 // WithAPIVersion sets the APIVersion field in the declarative configuration to the given value 95 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 96 // If called multiple times, the APIVersion field is set to the value of the last call. 97 func (b *StatefulSetApplyConfiguration) WithAPIVersion(value string) *StatefulSetApplyConfiguration { 98 b.APIVersion = &value 99 return b 100 } 101 102 // WithName sets the Name field in the declarative configuration to the given value 103 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 104 // If called multiple times, the Name field is set to the value of the last call. 105 func (b *StatefulSetApplyConfiguration) WithName(value string) *StatefulSetApplyConfiguration { 106 b.ensureObjectMetaApplyConfigurationExists() 107 b.Name = &value 108 return b 109 } 110 111 // WithGenerateName sets the GenerateName field in the declarative configuration to the given value 112 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 113 // If called multiple times, the GenerateName field is set to the value of the last call. 114 func (b *StatefulSetApplyConfiguration) WithGenerateName(value string) *StatefulSetApplyConfiguration { 115 b.ensureObjectMetaApplyConfigurationExists() 116 b.GenerateName = &value 117 return b 118 } 119 120 // WithNamespace sets the Namespace field in the declarative configuration to the given value 121 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 122 // If called multiple times, the Namespace field is set to the value of the last call. 123 func (b *StatefulSetApplyConfiguration) WithNamespace(value string) *StatefulSetApplyConfiguration { 124 b.ensureObjectMetaApplyConfigurationExists() 125 b.Namespace = &value 126 return b 127 } 128 129 // WithUID sets the UID field in the declarative configuration to the given value 130 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 131 // If called multiple times, the UID field is set to the value of the last call. 132 func (b *StatefulSetApplyConfiguration) WithUID(value types.UID) *StatefulSetApplyConfiguration { 133 b.ensureObjectMetaApplyConfigurationExists() 134 b.UID = &value 135 return b 136 } 137 138 // WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value 139 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 140 // If called multiple times, the ResourceVersion field is set to the value of the last call. 141 func (b *StatefulSetApplyConfiguration) WithResourceVersion(value string) *StatefulSetApplyConfiguration { 142 b.ensureObjectMetaApplyConfigurationExists() 143 b.ResourceVersion = &value 144 return b 145 } 146 147 // WithGeneration sets the Generation field in the declarative configuration to the given value 148 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 149 // If called multiple times, the Generation field is set to the value of the last call. 150 func (b *StatefulSetApplyConfiguration) WithGeneration(value int64) *StatefulSetApplyConfiguration { 151 b.ensureObjectMetaApplyConfigurationExists() 152 b.Generation = &value 153 return b 154 } 155 156 // WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value 157 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 158 // If called multiple times, the CreationTimestamp field is set to the value of the last call. 159 func (b *StatefulSetApplyConfiguration) WithCreationTimestamp(value metav1.Time) *StatefulSetApplyConfiguration { 160 b.ensureObjectMetaApplyConfigurationExists() 161 b.CreationTimestamp = &value 162 return b 163 } 164 165 // WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value 166 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 167 // If called multiple times, the DeletionTimestamp field is set to the value of the last call. 168 func (b *StatefulSetApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *StatefulSetApplyConfiguration { 169 b.ensureObjectMetaApplyConfigurationExists() 170 b.DeletionTimestamp = &value 171 return b 172 } 173 174 // WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value 175 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 176 // If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. 177 func (b *StatefulSetApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *StatefulSetApplyConfiguration { 178 b.ensureObjectMetaApplyConfigurationExists() 179 b.DeletionGracePeriodSeconds = &value 180 return b 181 } 182 183 // WithLabels puts the entries into the Labels field in the declarative configuration 184 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 185 // If called multiple times, the entries provided by each call will be put on the Labels field, 186 // overwriting an existing map entries in Labels field with the same key. 187 func (b *StatefulSetApplyConfiguration) WithLabels(entries map[string]string) *StatefulSetApplyConfiguration { 188 b.ensureObjectMetaApplyConfigurationExists() 189 if b.Labels == nil && len(entries) > 0 { 190 b.Labels = make(map[string]string, len(entries)) 191 } 192 for k, v := range entries { 193 b.Labels[k] = v 194 } 195 return b 196 } 197 198 // WithAnnotations puts the entries into the Annotations field in the declarative configuration 199 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 200 // If called multiple times, the entries provided by each call will be put on the Annotations field, 201 // overwriting an existing map entries in Annotations field with the same key. 202 func (b *StatefulSetApplyConfiguration) WithAnnotations(entries map[string]string) *StatefulSetApplyConfiguration { 203 b.ensureObjectMetaApplyConfigurationExists() 204 if b.Annotations == nil && len(entries) > 0 { 205 b.Annotations = make(map[string]string, len(entries)) 206 } 207 for k, v := range entries { 208 b.Annotations[k] = v 209 } 210 return b 211 } 212 213 // WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration 214 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 215 // If called multiple times, values provided by each call will be appended to the OwnerReferences field. 216 func (b *StatefulSetApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *StatefulSetApplyConfiguration { 217 b.ensureObjectMetaApplyConfigurationExists() 218 for i := range values { 219 if values[i] == nil { 220 panic("nil value passed to WithOwnerReferences") 221 } 222 b.OwnerReferences = append(b.OwnerReferences, *values[i]) 223 } 224 return b 225 } 226 227 // WithFinalizers adds the given value to the Finalizers field in the declarative configuration 228 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 229 // If called multiple times, values provided by each call will be appended to the Finalizers field. 230 func (b *StatefulSetApplyConfiguration) WithFinalizers(values ...string) *StatefulSetApplyConfiguration { 231 b.ensureObjectMetaApplyConfigurationExists() 232 for i := range values { 233 b.Finalizers = append(b.Finalizers, values[i]) 234 } 235 return b 236 } 237 238 func (b *StatefulSetApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { 239 if b.ObjectMetaApplyConfiguration == nil { 240 b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} 241 } 242 } 243 244 // WithSpec sets the Spec field in the declarative configuration to the given value 245 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 246 // If called multiple times, the Spec field is set to the value of the last call. 247 func (b *StatefulSetApplyConfiguration) WithSpec(value *StatefulSetSpecApplyConfiguration) *StatefulSetApplyConfiguration { 248 b.Spec = value 249 return b 250 } 251 252 // WithStatus sets the Status field in the declarative configuration to the given value 253 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 254 // If called multiple times, the Status field is set to the value of the last call. 255 func (b *StatefulSetApplyConfiguration) WithStatus(value *StatefulSetStatusApplyConfiguration) *StatefulSetApplyConfiguration { 256 b.Status = value 257 return b 258 } 259