...

Source file src/k8s.io/client-go/applyconfigurations/policy/v1beta1/poddisruptionbudget.go

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

View as plain text