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