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