1/* 2Copyright The Kubernetes Authors. 3 4Licensed under the Apache License, Version 2.0 (the "License"); 5you may not use this file except in compliance with the License. 6You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10Unless required by applicable law or agreed to in writing, software 11distributed under the License is distributed on an "AS IS" BASIS, 12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13See the License for the specific language governing permissions and 14limitations under the License. 15*/ 16 17// Code generated by applyconfiguration-gen. DO NOT EDIT. 18 19package v1 20 21import ( 22 corev1 "k8s.io/api/core/v1" 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// SecretApplyConfiguration represents an declarative configuration of the Secret type for use 31// with apply. 32type SecretApplyConfiguration struct { 33 v1.TypeMetaApplyConfiguration `json:",inline"` 34 *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` 35 Immutable *bool `json:"immutable,omitempty"` 36 Data map[string][]byte `json:"data,omitempty"` 37 StringData map[string]string `json:"stringData,omitempty"` 38 Type *corev1.SecretType `json:"type,omitempty"` 39} 40 41// Secret constructs an declarative configuration of the Secret type for use with 42// apply. 43func Secret(name, namespace string) *SecretApplyConfiguration { 44 b := &SecretApplyConfiguration{} 45 b.WithName(name) 46 b.WithNamespace(namespace) 47 b.WithKind("Secret") 48 b.WithAPIVersion("v1") 49 return b 50} 51 52// ExtractSecret extracts the applied configuration owned by fieldManager from 53// secret. If no managedFields are found in secret for fieldManager, a 54// SecretApplyConfiguration 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// secret must be a unmodified Secret API object that was retrieved from the Kubernetes API. 59// ExtractSecret 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! 63func ExtractSecret(secret *corev1.Secret, fieldManager string) (*SecretApplyConfiguration, error) { 64 return extractSecret(secret, fieldManager, "") 65} 66 67// ExtractSecretStatus is the same as ExtractSecret except 68// that it extracts the status subresource applied configuration. 69// Experimental! 70func ExtractSecretStatus(secret *corev1.Secret, fieldManager string) (*SecretApplyConfiguration, error) { 71 return extractSecret(secret, fieldManager, "status") 72} 73 74func extractSecret(secret *corev1.Secret, fieldManager string, subresource string) (*SecretApplyConfiguration, error) { 75 b := &SecretApplyConfiguration{} 76 err := managedfields.ExtractInto(secret, internal.Parser().Type("io.k8s.api.core.v1.Secret"), fieldManager, b, subresource) 77 if err != nil { 78 return nil, err 79 } 80 b.WithName(secret.Name) 81 b.WithNamespace(secret.Namespace) 82 83 b.WithKind("Secret") 84 b.WithAPIVersion("v1") 85 return b, nil 86} 87 88// WithKind sets the Kind field in the declarative configuration to the given value 89// and returns the receiver, so that objects can be built by chaining "With" function invocations. 90// If called multiple times, the Kind field is set to the value of the last call. 91func (b *SecretApplyConfiguration) WithKind(value string) *SecretApplyConfiguration { 92 b.Kind = &value 93 return b 94} 95 96// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value 97// and returns the receiver, so that objects can be built by chaining "With" function invocations. 98// If called multiple times, the APIVersion field is set to the value of the last call. 99func (b *SecretApplyConfiguration) WithAPIVersion(value string) *SecretApplyConfiguration { 100 b.APIVersion = &value 101 return b 102} 103 104// WithName sets the Name field in the declarative configuration to the given value 105// and returns the receiver, so that objects can be built by chaining "With" function invocations. 106// If called multiple times, the Name field is set to the value of the last call. 107func (b *SecretApplyConfiguration) WithName(value string) *SecretApplyConfiguration { 108 b.ensureObjectMetaApplyConfigurationExists() 109 b.Name = &value 110 return b 111} 112 113// WithGenerateName sets the GenerateName field in the declarative configuration to the given value 114// and returns the receiver, so that objects can be built by chaining "With" function invocations. 115// If called multiple times, the GenerateName field is set to the value of the last call. 116func (b *SecretApplyConfiguration) WithGenerateName(value string) *SecretApplyConfiguration { 117 b.ensureObjectMetaApplyConfigurationExists() 118 b.GenerateName = &value 119 return b 120} 121 122// WithNamespace sets the Namespace field in the declarative configuration to the given value 123// and returns the receiver, so that objects can be built by chaining "With" function invocations. 124// If called multiple times, the Namespace field is set to the value of the last call. 125func (b *SecretApplyConfiguration) WithNamespace(value string) *SecretApplyConfiguration { 126 b.ensureObjectMetaApplyConfigurationExists() 127 b.Namespace = &value 128 return b 129} 130 131// WithSelfLink sets the SelfLink field in the declarative configuration to the given value 132// and returns the receiver, so that objects can be built by chaining "With" function invocations. 133// If called multiple times, the SelfLink field is set to the value of the last call. 134func (b *SecretApplyConfiguration) WithSelfLink(value string) *SecretApplyConfiguration { 135 b.ensureObjectMetaApplyConfigurationExists() 136 b.SelfLink = &value 137 return b 138} 139 140// WithUID sets the UID field in the declarative configuration to the given value 141// and returns the receiver, so that objects can be built by chaining "With" function invocations. 142// If called multiple times, the UID field is set to the value of the last call. 143func (b *SecretApplyConfiguration) WithUID(value types.UID) *SecretApplyConfiguration { 144 b.ensureObjectMetaApplyConfigurationExists() 145 b.UID = &value 146 return b 147} 148 149// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value 150// and returns the receiver, so that objects can be built by chaining "With" function invocations. 151// If called multiple times, the ResourceVersion field is set to the value of the last call. 152func (b *SecretApplyConfiguration) WithResourceVersion(value string) *SecretApplyConfiguration { 153 b.ensureObjectMetaApplyConfigurationExists() 154 b.ResourceVersion = &value 155 return b 156} 157 158// WithGeneration sets the Generation field in the declarative configuration to the given value 159// and returns the receiver, so that objects can be built by chaining "With" function invocations. 160// If called multiple times, the Generation field is set to the value of the last call. 161func (b *SecretApplyConfiguration) WithGeneration(value int64) *SecretApplyConfiguration { 162 b.ensureObjectMetaApplyConfigurationExists() 163 b.Generation = &value 164 return b 165} 166 167// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value 168// and returns the receiver, so that objects can be built by chaining "With" function invocations. 169// If called multiple times, the CreationTimestamp field is set to the value of the last call. 170func (b *SecretApplyConfiguration) WithCreationTimestamp(value metav1.Time) *SecretApplyConfiguration { 171 b.ensureObjectMetaApplyConfigurationExists() 172 b.CreationTimestamp = &value 173 return b 174} 175 176// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value 177// and returns the receiver, so that objects can be built by chaining "With" function invocations. 178// If called multiple times, the DeletionTimestamp field is set to the value of the last call. 179func (b *SecretApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *SecretApplyConfiguration { 180 b.ensureObjectMetaApplyConfigurationExists() 181 b.DeletionTimestamp = &value 182 return b 183} 184 185// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value 186// and returns the receiver, so that objects can be built by chaining "With" function invocations. 187// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. 188func (b *SecretApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *SecretApplyConfiguration { 189 b.ensureObjectMetaApplyConfigurationExists() 190 b.DeletionGracePeriodSeconds = &value 191 return b 192} 193 194// WithLabels puts the entries into the Labels field in the declarative configuration 195// and returns the receiver, so that objects can be build by chaining "With" function invocations. 196// If called multiple times, the entries provided by each call will be put on the Labels field, 197// overwriting an existing map entries in Labels field with the same key. 198func (b *SecretApplyConfiguration) WithLabels(entries map[string]string) *SecretApplyConfiguration { 199 b.ensureObjectMetaApplyConfigurationExists() 200 if b.Labels == nil && len(entries) > 0 { 201 b.Labels = make(map[string]string, len(entries)) 202 } 203 for k, v := range entries { 204 b.Labels[k] = v 205 } 206 return b 207} 208 209// WithAnnotations puts the entries into the Annotations field in the declarative configuration 210// and returns the receiver, so that objects can be build by chaining "With" function invocations. 211// If called multiple times, the entries provided by each call will be put on the Annotations field, 212// overwriting an existing map entries in Annotations field with the same key. 213func (b *SecretApplyConfiguration) WithAnnotations(entries map[string]string) *SecretApplyConfiguration { 214 b.ensureObjectMetaApplyConfigurationExists() 215 if b.Annotations == nil && len(entries) > 0 { 216 b.Annotations = make(map[string]string, len(entries)) 217 } 218 for k, v := range entries { 219 b.Annotations[k] = v 220 } 221 return b 222} 223 224// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration 225// and returns the receiver, so that objects can be build by chaining "With" function invocations. 226// If called multiple times, values provided by each call will be appended to the OwnerReferences field. 227func (b *SecretApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *SecretApplyConfiguration { 228 b.ensureObjectMetaApplyConfigurationExists() 229 for i := range values { 230 if values[i] == nil { 231 panic("nil value passed to WithOwnerReferences") 232 } 233 b.OwnerReferences = append(b.OwnerReferences, *values[i]) 234 } 235 return b 236} 237 238// WithFinalizers adds the given value to the Finalizers field in the declarative configuration 239// and returns the receiver, so that objects can be build by chaining "With" function invocations. 240// If called multiple times, values provided by each call will be appended to the Finalizers field. 241func (b *SecretApplyConfiguration) WithFinalizers(values ...string) *SecretApplyConfiguration { 242 b.ensureObjectMetaApplyConfigurationExists() 243 for i := range values { 244 b.Finalizers = append(b.Finalizers, values[i]) 245 } 246 return b 247} 248 249// WithClusterName sets the ClusterName field in the declarative configuration to the given value 250// and returns the receiver, so that objects can be built by chaining "With" function invocations. 251// If called multiple times, the ClusterName field is set to the value of the last call. 252func (b *SecretApplyConfiguration) WithClusterName(value string) *SecretApplyConfiguration { 253 b.ensureObjectMetaApplyConfigurationExists() 254 b.ClusterName = &value 255 return b 256} 257 258func (b *SecretApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { 259 if b.ObjectMetaApplyConfiguration == nil { 260 b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} 261 } 262} 263 264// WithImmutable sets the Immutable field in the declarative configuration to the given value 265// and returns the receiver, so that objects can be built by chaining "With" function invocations. 266// If called multiple times, the Immutable field is set to the value of the last call. 267func (b *SecretApplyConfiguration) WithImmutable(value bool) *SecretApplyConfiguration { 268 b.Immutable = &value 269 return b 270} 271 272// WithData puts the entries into the Data field in the declarative configuration 273// and returns the receiver, so that objects can be build by chaining "With" function invocations. 274// If called multiple times, the entries provided by each call will be put on the Data field, 275// overwriting an existing map entries in Data field with the same key. 276func (b *SecretApplyConfiguration) WithData(entries map[string][]byte) *SecretApplyConfiguration { 277 if b.Data == nil && len(entries) > 0 { 278 b.Data = make(map[string][]byte, len(entries)) 279 } 280 for k, v := range entries { 281 b.Data[k] = v 282 } 283 return b 284} 285 286// WithStringData puts the entries into the StringData field in the declarative configuration 287// and returns the receiver, so that objects can be build by chaining "With" function invocations. 288// If called multiple times, the entries provided by each call will be put on the StringData field, 289// overwriting an existing map entries in StringData field with the same key. 290func (b *SecretApplyConfiguration) WithStringData(entries map[string]string) *SecretApplyConfiguration { 291 if b.StringData == nil && len(entries) > 0 { 292 b.StringData = make(map[string]string, len(entries)) 293 } 294 for k, v := range entries { 295 b.StringData[k] = v 296 } 297 return b 298} 299 300// WithType sets the Type field in the declarative configuration to the given value 301// and returns the receiver, so that objects can be built by chaining "With" function invocations. 302// If called multiple times, the Type field is set to the value of the last call. 303func (b *SecretApplyConfiguration) WithType(value corev1.SecretType) *SecretApplyConfiguration { 304 b.Type = &value 305 return b 306} 307