k8s.io/client-go@v0.22.2/applyconfigurations/storage/v1beta1/storageclass.go (about) 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 v1beta1 20 21 import ( 22 corev1 "k8s.io/api/core/v1" 23 v1beta1 "k8s.io/api/storage/v1beta1" 24 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 types "k8s.io/apimachinery/pkg/types" 26 managedfields "k8s.io/apimachinery/pkg/util/managedfields" 27 applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1" 28 internal "k8s.io/client-go/applyconfigurations/internal" 29 v1 "k8s.io/client-go/applyconfigurations/meta/v1" 30 ) 31 32 // StorageClassApplyConfiguration represents an declarative configuration of the StorageClass type for use 33 // with apply. 34 type StorageClassApplyConfiguration struct { 35 v1.TypeMetaApplyConfiguration `json:",inline"` 36 *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` 37 Provisioner *string `json:"provisioner,omitempty"` 38 Parameters map[string]string `json:"parameters,omitempty"` 39 ReclaimPolicy *corev1.PersistentVolumeReclaimPolicy `json:"reclaimPolicy,omitempty"` 40 MountOptions []string `json:"mountOptions,omitempty"` 41 AllowVolumeExpansion *bool `json:"allowVolumeExpansion,omitempty"` 42 VolumeBindingMode *v1beta1.VolumeBindingMode `json:"volumeBindingMode,omitempty"` 43 AllowedTopologies []applyconfigurationscorev1.TopologySelectorTermApplyConfiguration `json:"allowedTopologies,omitempty"` 44 } 45 46 // StorageClass constructs an declarative configuration of the StorageClass type for use with 47 // apply. 48 func StorageClass(name string) *StorageClassApplyConfiguration { 49 b := &StorageClassApplyConfiguration{} 50 b.WithName(name) 51 b.WithKind("StorageClass") 52 b.WithAPIVersion("storage.k8s.io/v1beta1") 53 return b 54 } 55 56 // ExtractStorageClass extracts the applied configuration owned by fieldManager from 57 // storageClass. If no managedFields are found in storageClass for fieldManager, a 58 // StorageClassApplyConfiguration is returned with only the Name, Namespace (if applicable), 59 // APIVersion and Kind populated. It is possible that no managed fields were found for because other 60 // field managers have taken ownership of all the fields previously owned by fieldManager, or because 61 // the fieldManager never owned fields any fields. 62 // storageClass must be a unmodified StorageClass API object that was retrieved from the Kubernetes API. 63 // ExtractStorageClass provides a way to perform a extract/modify-in-place/apply workflow. 64 // Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously 65 // applied if another fieldManager has updated or force applied any of the previously applied fields. 66 // Experimental! 67 func ExtractStorageClass(storageClass *v1beta1.StorageClass, fieldManager string) (*StorageClassApplyConfiguration, error) { 68 return extractStorageClass(storageClass, fieldManager, "") 69 } 70 71 // ExtractStorageClassStatus is the same as ExtractStorageClass except 72 // that it extracts the status subresource applied configuration. 73 // Experimental! 74 func ExtractStorageClassStatus(storageClass *v1beta1.StorageClass, fieldManager string) (*StorageClassApplyConfiguration, error) { 75 return extractStorageClass(storageClass, fieldManager, "status") 76 } 77 78 func extractStorageClass(storageClass *v1beta1.StorageClass, fieldManager string, subresource string) (*StorageClassApplyConfiguration, error) { 79 b := &StorageClassApplyConfiguration{} 80 err := managedfields.ExtractInto(storageClass, internal.Parser().Type("io.k8s.api.storage.v1beta1.StorageClass"), fieldManager, b, subresource) 81 if err != nil { 82 return nil, err 83 } 84 b.WithName(storageClass.Name) 85 86 b.WithKind("StorageClass") 87 b.WithAPIVersion("storage.k8s.io/v1beta1") 88 return b, nil 89 } 90 91 // WithKind sets the Kind 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 Kind field is set to the value of the last call. 94 func (b *StorageClassApplyConfiguration) WithKind(value string) *StorageClassApplyConfiguration { 95 b.Kind = &value 96 return b 97 } 98 99 // WithAPIVersion sets the APIVersion field in the declarative configuration to the given value 100 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 101 // If called multiple times, the APIVersion field is set to the value of the last call. 102 func (b *StorageClassApplyConfiguration) WithAPIVersion(value string) *StorageClassApplyConfiguration { 103 b.APIVersion = &value 104 return b 105 } 106 107 // WithName sets the Name field in the declarative configuration to the given value 108 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 109 // If called multiple times, the Name field is set to the value of the last call. 110 func (b *StorageClassApplyConfiguration) WithName(value string) *StorageClassApplyConfiguration { 111 b.ensureObjectMetaApplyConfigurationExists() 112 b.Name = &value 113 return b 114 } 115 116 // WithGenerateName sets the GenerateName field in the declarative configuration to the given value 117 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 118 // If called multiple times, the GenerateName field is set to the value of the last call. 119 func (b *StorageClassApplyConfiguration) WithGenerateName(value string) *StorageClassApplyConfiguration { 120 b.ensureObjectMetaApplyConfigurationExists() 121 b.GenerateName = &value 122 return b 123 } 124 125 // WithNamespace sets the Namespace field in the declarative configuration to the given value 126 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 127 // If called multiple times, the Namespace field is set to the value of the last call. 128 func (b *StorageClassApplyConfiguration) WithNamespace(value string) *StorageClassApplyConfiguration { 129 b.ensureObjectMetaApplyConfigurationExists() 130 b.Namespace = &value 131 return b 132 } 133 134 // WithSelfLink sets the SelfLink field in the declarative configuration to the given value 135 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 136 // If called multiple times, the SelfLink field is set to the value of the last call. 137 func (b *StorageClassApplyConfiguration) WithSelfLink(value string) *StorageClassApplyConfiguration { 138 b.ensureObjectMetaApplyConfigurationExists() 139 b.SelfLink = &value 140 return b 141 } 142 143 // WithUID sets the UID field in the declarative configuration to the given value 144 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 145 // If called multiple times, the UID field is set to the value of the last call. 146 func (b *StorageClassApplyConfiguration) WithUID(value types.UID) *StorageClassApplyConfiguration { 147 b.ensureObjectMetaApplyConfigurationExists() 148 b.UID = &value 149 return b 150 } 151 152 // WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value 153 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 154 // If called multiple times, the ResourceVersion field is set to the value of the last call. 155 func (b *StorageClassApplyConfiguration) WithResourceVersion(value string) *StorageClassApplyConfiguration { 156 b.ensureObjectMetaApplyConfigurationExists() 157 b.ResourceVersion = &value 158 return b 159 } 160 161 // WithGeneration sets the Generation field in the declarative configuration to the given value 162 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 163 // If called multiple times, the Generation field is set to the value of the last call. 164 func (b *StorageClassApplyConfiguration) WithGeneration(value int64) *StorageClassApplyConfiguration { 165 b.ensureObjectMetaApplyConfigurationExists() 166 b.Generation = &value 167 return b 168 } 169 170 // WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value 171 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 172 // If called multiple times, the CreationTimestamp field is set to the value of the last call. 173 func (b *StorageClassApplyConfiguration) WithCreationTimestamp(value metav1.Time) *StorageClassApplyConfiguration { 174 b.ensureObjectMetaApplyConfigurationExists() 175 b.CreationTimestamp = &value 176 return b 177 } 178 179 // WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value 180 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 181 // If called multiple times, the DeletionTimestamp field is set to the value of the last call. 182 func (b *StorageClassApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *StorageClassApplyConfiguration { 183 b.ensureObjectMetaApplyConfigurationExists() 184 b.DeletionTimestamp = &value 185 return b 186 } 187 188 // WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value 189 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 190 // If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. 191 func (b *StorageClassApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *StorageClassApplyConfiguration { 192 b.ensureObjectMetaApplyConfigurationExists() 193 b.DeletionGracePeriodSeconds = &value 194 return b 195 } 196 197 // WithLabels puts the entries into the Labels field in the declarative configuration 198 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 199 // If called multiple times, the entries provided by each call will be put on the Labels field, 200 // overwriting an existing map entries in Labels field with the same key. 201 func (b *StorageClassApplyConfiguration) WithLabels(entries map[string]string) *StorageClassApplyConfiguration { 202 b.ensureObjectMetaApplyConfigurationExists() 203 if b.Labels == nil && len(entries) > 0 { 204 b.Labels = make(map[string]string, len(entries)) 205 } 206 for k, v := range entries { 207 b.Labels[k] = v 208 } 209 return b 210 } 211 212 // WithAnnotations puts the entries into the Annotations field in the declarative configuration 213 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 214 // If called multiple times, the entries provided by each call will be put on the Annotations field, 215 // overwriting an existing map entries in Annotations field with the same key. 216 func (b *StorageClassApplyConfiguration) WithAnnotations(entries map[string]string) *StorageClassApplyConfiguration { 217 b.ensureObjectMetaApplyConfigurationExists() 218 if b.Annotations == nil && len(entries) > 0 { 219 b.Annotations = make(map[string]string, len(entries)) 220 } 221 for k, v := range entries { 222 b.Annotations[k] = v 223 } 224 return b 225 } 226 227 // WithOwnerReferences adds the given value to the OwnerReferences 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 OwnerReferences field. 230 func (b *StorageClassApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *StorageClassApplyConfiguration { 231 b.ensureObjectMetaApplyConfigurationExists() 232 for i := range values { 233 if values[i] == nil { 234 panic("nil value passed to WithOwnerReferences") 235 } 236 b.OwnerReferences = append(b.OwnerReferences, *values[i]) 237 } 238 return b 239 } 240 241 // WithFinalizers adds the given value to the Finalizers field in the declarative configuration 242 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 243 // If called multiple times, values provided by each call will be appended to the Finalizers field. 244 func (b *StorageClassApplyConfiguration) WithFinalizers(values ...string) *StorageClassApplyConfiguration { 245 b.ensureObjectMetaApplyConfigurationExists() 246 for i := range values { 247 b.Finalizers = append(b.Finalizers, values[i]) 248 } 249 return b 250 } 251 252 // WithClusterName sets the ClusterName 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 ClusterName field is set to the value of the last call. 255 func (b *StorageClassApplyConfiguration) WithClusterName(value string) *StorageClassApplyConfiguration { 256 b.ensureObjectMetaApplyConfigurationExists() 257 b.ClusterName = &value 258 return b 259 } 260 261 func (b *StorageClassApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { 262 if b.ObjectMetaApplyConfiguration == nil { 263 b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} 264 } 265 } 266 267 // WithProvisioner sets the Provisioner field in the declarative configuration to the given value 268 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 269 // If called multiple times, the Provisioner field is set to the value of the last call. 270 func (b *StorageClassApplyConfiguration) WithProvisioner(value string) *StorageClassApplyConfiguration { 271 b.Provisioner = &value 272 return b 273 } 274 275 // WithParameters puts the entries into the Parameters field in the declarative configuration 276 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 277 // If called multiple times, the entries provided by each call will be put on the Parameters field, 278 // overwriting an existing map entries in Parameters field with the same key. 279 func (b *StorageClassApplyConfiguration) WithParameters(entries map[string]string) *StorageClassApplyConfiguration { 280 if b.Parameters == nil && len(entries) > 0 { 281 b.Parameters = make(map[string]string, len(entries)) 282 } 283 for k, v := range entries { 284 b.Parameters[k] = v 285 } 286 return b 287 } 288 289 // WithReclaimPolicy sets the ReclaimPolicy field in the declarative configuration to the given value 290 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 291 // If called multiple times, the ReclaimPolicy field is set to the value of the last call. 292 func (b *StorageClassApplyConfiguration) WithReclaimPolicy(value corev1.PersistentVolumeReclaimPolicy) *StorageClassApplyConfiguration { 293 b.ReclaimPolicy = &value 294 return b 295 } 296 297 // WithMountOptions adds the given value to the MountOptions field in the declarative configuration 298 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 299 // If called multiple times, values provided by each call will be appended to the MountOptions field. 300 func (b *StorageClassApplyConfiguration) WithMountOptions(values ...string) *StorageClassApplyConfiguration { 301 for i := range values { 302 b.MountOptions = append(b.MountOptions, values[i]) 303 } 304 return b 305 } 306 307 // WithAllowVolumeExpansion sets the AllowVolumeExpansion field in the declarative configuration to the given value 308 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 309 // If called multiple times, the AllowVolumeExpansion field is set to the value of the last call. 310 func (b *StorageClassApplyConfiguration) WithAllowVolumeExpansion(value bool) *StorageClassApplyConfiguration { 311 b.AllowVolumeExpansion = &value 312 return b 313 } 314 315 // WithVolumeBindingMode sets the VolumeBindingMode field in the declarative configuration to the given value 316 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 317 // If called multiple times, the VolumeBindingMode field is set to the value of the last call. 318 func (b *StorageClassApplyConfiguration) WithVolumeBindingMode(value v1beta1.VolumeBindingMode) *StorageClassApplyConfiguration { 319 b.VolumeBindingMode = &value 320 return b 321 } 322 323 // WithAllowedTopologies adds the given value to the AllowedTopologies field in the declarative configuration 324 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 325 // If called multiple times, values provided by each call will be appended to the AllowedTopologies field. 326 func (b *StorageClassApplyConfiguration) WithAllowedTopologies(values ...*applyconfigurationscorev1.TopologySelectorTermApplyConfiguration) *StorageClassApplyConfiguration { 327 for i := range values { 328 if values[i] == nil { 329 panic("nil value passed to WithAllowedTopologies") 330 } 331 b.AllowedTopologies = append(b.AllowedTopologies, *values[i]) 332 } 333 return b 334 }