...

Source file src/k8s.io/client-go/applyconfigurations/core/v1/secret.go

Documentation: k8s.io/client-go/applyconfigurations/core/v1

     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 v1
    20  
    21  import (
    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.
    32  type 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.
    43  func 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!
    63  func 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!
    70  func ExtractSecretStatus(secret *corev1.Secret, fieldManager string) (*SecretApplyConfiguration, error) {
    71  	return extractSecret(secret, fieldManager, "status")
    72  }
    73  
    74  func 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.
    91  func (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.
    99  func (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.
   107  func (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.
   116  func (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.
   125  func (b *SecretApplyConfiguration) WithNamespace(value string) *SecretApplyConfiguration {
   126  	b.ensureObjectMetaApplyConfigurationExists()
   127  	b.Namespace = &value
   128  	return b
   129  }
   130  
   131  // WithUID sets the UID 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 UID field is set to the value of the last call.
   134  func (b *SecretApplyConfiguration) WithUID(value types.UID) *SecretApplyConfiguration {
   135  	b.ensureObjectMetaApplyConfigurationExists()
   136  	b.UID = &value
   137  	return b
   138  }
   139  
   140  // WithResourceVersion sets the ResourceVersion 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 ResourceVersion field is set to the value of the last call.
   143  func (b *SecretApplyConfiguration) WithResourceVersion(value string) *SecretApplyConfiguration {
   144  	b.ensureObjectMetaApplyConfigurationExists()
   145  	b.ResourceVersion = &value
   146  	return b
   147  }
   148  
   149  // WithGeneration sets the Generation 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 Generation field is set to the value of the last call.
   152  func (b *SecretApplyConfiguration) WithGeneration(value int64) *SecretApplyConfiguration {
   153  	b.ensureObjectMetaApplyConfigurationExists()
   154  	b.Generation = &value
   155  	return b
   156  }
   157  
   158  // WithCreationTimestamp sets the CreationTimestamp 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 CreationTimestamp field is set to the value of the last call.
   161  func (b *SecretApplyConfiguration) WithCreationTimestamp(value metav1.Time) *SecretApplyConfiguration {
   162  	b.ensureObjectMetaApplyConfigurationExists()
   163  	b.CreationTimestamp = &value
   164  	return b
   165  }
   166  
   167  // WithDeletionTimestamp sets the DeletionTimestamp 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 DeletionTimestamp field is set to the value of the last call.
   170  func (b *SecretApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *SecretApplyConfiguration {
   171  	b.ensureObjectMetaApplyConfigurationExists()
   172  	b.DeletionTimestamp = &value
   173  	return b
   174  }
   175  
   176  // WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds 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 DeletionGracePeriodSeconds field is set to the value of the last call.
   179  func (b *SecretApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *SecretApplyConfiguration {
   180  	b.ensureObjectMetaApplyConfigurationExists()
   181  	b.DeletionGracePeriodSeconds = &value
   182  	return b
   183  }
   184  
   185  // WithLabels puts the entries into the Labels field in the declarative configuration
   186  // and returns the receiver, so that objects can be build by chaining "With" function invocations.
   187  // If called multiple times, the entries provided by each call will be put on the Labels field,
   188  // overwriting an existing map entries in Labels field with the same key.
   189  func (b *SecretApplyConfiguration) WithLabels(entries map[string]string) *SecretApplyConfiguration {
   190  	b.ensureObjectMetaApplyConfigurationExists()
   191  	if b.Labels == nil && len(entries) > 0 {
   192  		b.Labels = make(map[string]string, len(entries))
   193  	}
   194  	for k, v := range entries {
   195  		b.Labels[k] = v
   196  	}
   197  	return b
   198  }
   199  
   200  // WithAnnotations puts the entries into the Annotations field in the declarative configuration
   201  // and returns the receiver, so that objects can be build by chaining "With" function invocations.
   202  // If called multiple times, the entries provided by each call will be put on the Annotations field,
   203  // overwriting an existing map entries in Annotations field with the same key.
   204  func (b *SecretApplyConfiguration) WithAnnotations(entries map[string]string) *SecretApplyConfiguration {
   205  	b.ensureObjectMetaApplyConfigurationExists()
   206  	if b.Annotations == nil && len(entries) > 0 {
   207  		b.Annotations = make(map[string]string, len(entries))
   208  	}
   209  	for k, v := range entries {
   210  		b.Annotations[k] = v
   211  	}
   212  	return b
   213  }
   214  
   215  // WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
   216  // and returns the receiver, so that objects can be build by chaining "With" function invocations.
   217  // If called multiple times, values provided by each call will be appended to the OwnerReferences field.
   218  func (b *SecretApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *SecretApplyConfiguration {
   219  	b.ensureObjectMetaApplyConfigurationExists()
   220  	for i := range values {
   221  		if values[i] == nil {
   222  			panic("nil value passed to WithOwnerReferences")
   223  		}
   224  		b.OwnerReferences = append(b.OwnerReferences, *values[i])
   225  	}
   226  	return b
   227  }
   228  
   229  // WithFinalizers adds the given value to the Finalizers field in the declarative configuration
   230  // and returns the receiver, so that objects can be build by chaining "With" function invocations.
   231  // If called multiple times, values provided by each call will be appended to the Finalizers field.
   232  func (b *SecretApplyConfiguration) WithFinalizers(values ...string) *SecretApplyConfiguration {
   233  	b.ensureObjectMetaApplyConfigurationExists()
   234  	for i := range values {
   235  		b.Finalizers = append(b.Finalizers, values[i])
   236  	}
   237  	return b
   238  }
   239  
   240  func (b *SecretApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
   241  	if b.ObjectMetaApplyConfiguration == nil {
   242  		b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
   243  	}
   244  }
   245  
   246  // WithImmutable sets the Immutable field in the declarative configuration to the given value
   247  // and returns the receiver, so that objects can be built by chaining "With" function invocations.
   248  // If called multiple times, the Immutable field is set to the value of the last call.
   249  func (b *SecretApplyConfiguration) WithImmutable(value bool) *SecretApplyConfiguration {
   250  	b.Immutable = &value
   251  	return b
   252  }
   253  
   254  // WithData puts the entries into the Data field in the declarative configuration
   255  // and returns the receiver, so that objects can be build by chaining "With" function invocations.
   256  // If called multiple times, the entries provided by each call will be put on the Data field,
   257  // overwriting an existing map entries in Data field with the same key.
   258  func (b *SecretApplyConfiguration) WithData(entries map[string][]byte) *SecretApplyConfiguration {
   259  	if b.Data == nil && len(entries) > 0 {
   260  		b.Data = make(map[string][]byte, len(entries))
   261  	}
   262  	for k, v := range entries {
   263  		b.Data[k] = v
   264  	}
   265  	return b
   266  }
   267  
   268  // WithStringData puts the entries into the StringData field in the declarative configuration
   269  // and returns the receiver, so that objects can be build by chaining "With" function invocations.
   270  // If called multiple times, the entries provided by each call will be put on the StringData field,
   271  // overwriting an existing map entries in StringData field with the same key.
   272  func (b *SecretApplyConfiguration) WithStringData(entries map[string]string) *SecretApplyConfiguration {
   273  	if b.StringData == nil && len(entries) > 0 {
   274  		b.StringData = make(map[string]string, len(entries))
   275  	}
   276  	for k, v := range entries {
   277  		b.StringData[k] = v
   278  	}
   279  	return b
   280  }
   281  
   282  // WithType sets the Type field in the declarative configuration to the given value
   283  // and returns the receiver, so that objects can be built by chaining "With" function invocations.
   284  // If called multiple times, the Type field is set to the value of the last call.
   285  func (b *SecretApplyConfiguration) WithType(value corev1.SecretType) *SecretApplyConfiguration {
   286  	b.Type = &value
   287  	return b
   288  }
   289  

View as plain text