| 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 | policyv1beta1 "k8s.io/api/policy/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 | // EvictionApplyConfiguration represents a declarative configuration of the Eviction type for use |
| 31 | // with apply. |
| 32 | type EvictionApplyConfiguration struct { |
| 33 | v1.TypeMetaApplyConfiguration `json:",inline"` |
| 34 | *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` |
| 35 | DeleteOptions *v1.DeleteOptionsApplyConfiguration `json:"deleteOptions,omitempty"` |
| 36 | } |
| 37 | |
| 38 | // Eviction constructs a declarative configuration of the Eviction type for use with |
| 39 | // apply. |
| 40 | func Eviction(name, namespace string) *EvictionApplyConfiguration { |
| 41 | b := &EvictionApplyConfiguration{} |
| 42 | b.WithName(name) |
| 43 | b.WithNamespace(namespace) |
| 44 | b.WithKind("Eviction") |
| 45 | b.WithAPIVersion("policy/v1beta1") |
| 46 | return b |
| 47 | } |
| 48 | |
| 49 | // ExtractEviction extracts the applied configuration owned by fieldManager from |
| 50 | // eviction. If no managedFields are found in eviction for fieldManager, a |
| 51 | // EvictionApplyConfiguration 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 | // eviction must be a unmodified Eviction API object that was retrieved from the Kubernetes API. |
| 56 | // ExtractEviction 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 ExtractEviction(eviction *policyv1beta1.Eviction, fieldManager string) (*EvictionApplyConfiguration, error) { |
| 61 | return extractEviction(eviction, fieldManager, "") |
| 62 | } |
| 63 | |
| 64 | // ExtractEvictionStatus is the same as ExtractEviction except |
| 65 | // that it extracts the status subresource applied configuration. |
| 66 | // Experimental! |
| 67 | func ExtractEvictionStatus(eviction *policyv1beta1.Eviction, fieldManager string) (*EvictionApplyConfiguration, error) { |
| 68 | return extractEviction(eviction, fieldManager, "status") |
| 69 | } |
| 70 | |
| 71 | func extractEviction(eviction *policyv1beta1.Eviction, fieldManager string, subresource string) (*EvictionApplyConfiguration, error) { |
| 72 | b := &EvictionApplyConfiguration{} |
| 73 | err := managedfields.ExtractInto(eviction, internal.Parser().Type("io.k8s.api.policy.v1beta1.Eviction"), fieldManager, b, subresource) |
| 74 | if err != nil { |
| 75 | return nil, err |
| 76 | } |
| 77 | b.WithName(eviction.Name) |
| 78 | b.WithNamespace(eviction.Namespace) |
| 79 | |
| 80 | b.WithKind("Eviction") |
| 81 | b.WithAPIVersion("policy/v1beta1") |
| 82 | return b, nil |
| 83 | } |
| 84 | |
| 85 | // WithKind sets the Kind field in the declarative configuration to the given value |
| 86 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. |
| 87 | // If called multiple times, the Kind field is set to the value of the last call. |
| 88 | func (b *EvictionApplyConfiguration) WithKind(value string) *EvictionApplyConfiguration { |
| 89 | b.TypeMetaApplyConfiguration.Kind = &value |
| 90 | return b |
| 91 | } |
| 92 | |
| 93 | // WithAPIVersion sets the APIVersion field in the declarative configuration to the given value |
| 94 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. |
| 95 | // If called multiple times, the APIVersion field is set to the value of the last call. |
| 96 | func (b *EvictionApplyConfiguration) WithAPIVersion(value string) *EvictionApplyConfiguration { |
| 97 | b.TypeMetaApplyConfiguration.APIVersion = &value |
| 98 | return b |
| 99 | } |
| 100 | |
| 101 | // WithName sets the Name field in the declarative configuration to the given value |
| 102 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. |
| 103 | // If called multiple times, the Name field is set to the value of the last call. |
| 104 | func (b *EvictionApplyConfiguration) WithName(value string) *EvictionApplyConfiguration { |
| 105 | b.ensureObjectMetaApplyConfigurationExists() |
| 106 | b.ObjectMetaApplyConfiguration.Name = &value |
| 107 | return b |
| 108 | } |
| 109 | |
| 110 | // WithGenerateName sets the GenerateName field in the declarative configuration to the given value |
| 111 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. |
| 112 | // If called multiple times, the GenerateName field is set to the value of the last call. |
| 113 | func (b *EvictionApplyConfiguration) WithGenerateName(value string) *EvictionApplyConfiguration { |
| 114 | b.ensureObjectMetaApplyConfigurationExists() |
| 115 | b.ObjectMetaApplyConfiguration.GenerateName = &value |
| 116 | return b |
| 117 | } |
| 118 | |
| 119 | // WithNamespace sets the Namespace field in the declarative configuration to the given value |
| 120 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. |
| 121 | // If called multiple times, the Namespace field is set to the value of the last call. |
| 122 | func (b *EvictionApplyConfiguration) WithNamespace(value string) *EvictionApplyConfiguration { |
| 123 | b.ensureObjectMetaApplyConfigurationExists() |
| 124 | b.ObjectMetaApplyConfiguration.Namespace = &value |
| 125 | return b |
| 126 | } |
| 127 | |
| 128 | // WithUID sets the UID field in the declarative configuration to the given value |
| 129 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. |
| 130 | // If called multiple times, the UID field is set to the value of the last call. |
| 131 | func (b *EvictionApplyConfiguration) WithUID(value types.UID) *EvictionApplyConfiguration { |
| 132 | b.ensureObjectMetaApplyConfigurationExists() |
| 133 | b.ObjectMetaApplyConfiguration.UID = &value |
| 134 | return b |
| 135 | } |
| 136 | |
| 137 | // WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value |
| 138 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. |
| 139 | // If called multiple times, the ResourceVersion field is set to the value of the last call. |
| 140 | func (b *EvictionApplyConfiguration) WithResourceVersion(value string) *EvictionApplyConfiguration { |
| 141 | b.ensureObjectMetaApplyConfigurationExists() |
| 142 | b.ObjectMetaApplyConfiguration.ResourceVersion = &value |
| 143 | return b |
| 144 | } |
| 145 | |
| 146 | // WithGeneration sets the Generation field in the declarative configuration to the given value |
| 147 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. |
| 148 | // If called multiple times, the Generation field is set to the value of the last call. |
| 149 | func (b *EvictionApplyConfiguration) WithGeneration(value int64) *EvictionApplyConfiguration { |
| 150 | b.ensureObjectMetaApplyConfigurationExists() |
| 151 | b.ObjectMetaApplyConfiguration.Generation = &value |
| 152 | return b |
| 153 | } |
| 154 | |
| 155 | // WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value |
| 156 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. |
| 157 | // If called multiple times, the CreationTimestamp field is set to the value of the last call. |
| 158 | func (b *EvictionApplyConfiguration) WithCreationTimestamp(value metav1.Time) *EvictionApplyConfiguration { |
| 159 | b.ensureObjectMetaApplyConfigurationExists() |
| 160 | b.ObjectMetaApplyConfiguration.CreationTimestamp = &value |
| 161 | return b |
| 162 | } |
| 163 | |
| 164 | // WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value |
| 165 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. |
| 166 | // If called multiple times, the DeletionTimestamp field is set to the value of the last call. |
| 167 | func (b *EvictionApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *EvictionApplyConfiguration { |
| 168 | b.ensureObjectMetaApplyConfigurationExists() |
| 169 | b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value |
| 170 | return b |
| 171 | } |
| 172 | |
| 173 | // WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value |
| 174 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. |
| 175 | // If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. |
| 176 | func (b *EvictionApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *EvictionApplyConfiguration { |
| 177 | b.ensureObjectMetaApplyConfigurationExists() |
| 178 | b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value |
| 179 | return b |
| 180 | } |
| 181 | |
| 182 | // WithLabels puts the entries into the Labels field in the declarative configuration |
| 183 | // and returns the receiver, so that objects can be build by chaining "With" function invocations. |
| 184 | // If called multiple times, the entries provided by each call will be put on the Labels field, |
| 185 | // overwriting an existing map entries in Labels field with the same key. |
| 186 | func (b *EvictionApplyConfiguration) WithLabels(entries map[string]string) *EvictionApplyConfiguration { |
| 187 | b.ensureObjectMetaApplyConfigurationExists() |
| 188 | if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 { |
| 189 | b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries)) |
| 190 | } |
| 191 | for k, v := range entries { |
| 192 | b.ObjectMetaApplyConfiguration.Labels[k] = v |
| 193 | } |
| 194 | return b |
| 195 | } |
| 196 | |
| 197 | // WithAnnotations puts the entries into the Annotations 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 Annotations field, |
| 200 | // overwriting an existing map entries in Annotations field with the same key. |
| 201 | func (b *EvictionApplyConfiguration) WithAnnotations(entries map[string]string) *EvictionApplyConfiguration { |
| 202 | b.ensureObjectMetaApplyConfigurationExists() |
| 203 | if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 { |
| 204 | b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries)) |
| 205 | } |
| 206 | for k, v := range entries { |
| 207 | b.ObjectMetaApplyConfiguration.Annotations[k] = v |
| 208 | } |
| 209 | return b |
| 210 | } |
| 211 | |
| 212 | // WithOwnerReferences adds the given value to the OwnerReferences 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, values provided by each call will be appended to the OwnerReferences field. |
| 215 | func (b *EvictionApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *EvictionApplyConfiguration { |
| 216 | b.ensureObjectMetaApplyConfigurationExists() |
| 217 | for i := range values { |
| 218 | if values[i] == nil { |
| 219 | panic("nil value passed to WithOwnerReferences") |
| 220 | } |
| 221 | b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i]) |
| 222 | } |
| 223 | return b |
| 224 | } |
| 225 | |
| 226 | // WithFinalizers adds the given value to the Finalizers field in the declarative configuration |
| 227 | // and returns the receiver, so that objects can be build by chaining "With" function invocations. |
| 228 | // If called multiple times, values provided by each call will be appended to the Finalizers field. |
| 229 | func (b *EvictionApplyConfiguration) WithFinalizers(values ...string) *EvictionApplyConfiguration { |
| 230 | b.ensureObjectMetaApplyConfigurationExists() |
| 231 | for i := range values { |
| 232 | b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) |
| 233 | } |
| 234 | return b |
| 235 | } |
| 236 | |
| 237 | func (b *EvictionApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { |
| 238 | if b.ObjectMetaApplyConfiguration == nil { |
| 239 | b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | // WithDeleteOptions sets the DeleteOptions field in the declarative configuration to the given value |
| 244 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. |
| 245 | // If called multiple times, the DeleteOptions field is set to the value of the last call. |
| 246 | func (b *EvictionApplyConfiguration) WithDeleteOptions(value *v1.DeleteOptionsApplyConfiguration) *EvictionApplyConfiguration { |
| 247 | b.DeleteOptions = value |
| 248 | return b |
| 249 | } |
| 250 | |
| 251 | // GetName retrieves the value of the Name field in the declarative configuration. |
| 252 | func (b *EvictionApplyConfiguration) GetName() *string { |
| 253 | b.ensureObjectMetaApplyConfigurationExists() |
| 254 | return b.ObjectMetaApplyConfiguration.Name |
| 255 | } |