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