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