...

Source file src/k8s.io/client-go/applyconfigurations/discovery/v1beta1/endpointslice.go

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

View as plain text