...

Source file src/k8s.io/client-go/applyconfigurations/storage/v1beta1/storageclass.go

Documentation: k8s.io/client-go/applyconfigurations/storage/v1beta1

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

View as plain text