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