1/* 2Copyright The Kubernetes Authors. 3 4Licensed under the Apache License, Version 2.0 (the "License"); 5you may not use this file except in compliance with the License. 6You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10Unless required by applicable law or agreed to in writing, software 11distributed under the License is distributed on an "AS IS" BASIS, 12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13See the License for the specific language governing permissions and 14limitations under the License. 15*/ 16 17// Code generated by applyconfiguration-gen. DO NOT EDIT. 18 19package v1alpha1 20 21import ( 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// RoleApplyConfiguration represents an declarative configuration of the Role type for use 31// with apply. 32type RoleApplyConfiguration struct { 33 v1.TypeMetaApplyConfiguration `json:",inline"` 34 *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` 35 Rules []PolicyRuleApplyConfiguration `json:"rules,omitempty"` 36} 37 38// Role constructs an declarative configuration of the Role type for use with 39// apply. 40func Role(name, namespace string) *RoleApplyConfiguration { 41 b := &RoleApplyConfiguration{} 42 b.WithName(name) 43 b.WithNamespace(namespace) 44 b.WithKind("Role") 45 b.WithAPIVersion("rbac.authorization.k8s.io/v1alpha1") 46 return b 47} 48 49// ExtractRole extracts the applied configuration owned by fieldManager from 50// role. If no managedFields are found in role for fieldManager, a 51// RoleApplyConfiguration is returned with only the Name, Namespace (if applicable), 52// APIVersion and Kind populated. Is 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// role must be a unmodified Role API object that was retrieved from the Kubernetes API. 56// ExtractRole 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! 60func ExtractRole(role *rbacv1alpha1.Role, fieldManager string) (*RoleApplyConfiguration, error) { 61 b := &RoleApplyConfiguration{} 62 err := managedfields.ExtractInto(role, internal.Parser().Type("io.k8s.api.rbac.v1alpha1.Role"), fieldManager, b) 63 if err != nil { 64 return nil, err 65 } 66 b.WithName(role.Name) 67 b.WithNamespace(role.Namespace) 68 69 b.WithKind("Role") 70 b.WithAPIVersion("rbac.authorization.k8s.io/v1alpha1") 71 return b, nil 72} 73 74// WithKind sets the Kind field in the declarative configuration to the given value 75// and returns the receiver, so that objects can be built by chaining "With" function invocations. 76// If called multiple times, the Kind field is set to the value of the last call. 77func (b *RoleApplyConfiguration) WithKind(value string) *RoleApplyConfiguration { 78 b.Kind = &value 79 return b 80} 81 82// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value 83// and returns the receiver, so that objects can be built by chaining "With" function invocations. 84// If called multiple times, the APIVersion field is set to the value of the last call. 85func (b *RoleApplyConfiguration) WithAPIVersion(value string) *RoleApplyConfiguration { 86 b.APIVersion = &value 87 return b 88} 89 90// WithName sets the Name field in the declarative configuration to the given value 91// and returns the receiver, so that objects can be built by chaining "With" function invocations. 92// If called multiple times, the Name field is set to the value of the last call. 93func (b *RoleApplyConfiguration) WithName(value string) *RoleApplyConfiguration { 94 b.ensureObjectMetaApplyConfigurationExists() 95 b.Name = &value 96 return b 97} 98 99// WithGenerateName sets the GenerateName 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 GenerateName field is set to the value of the last call. 102func (b *RoleApplyConfiguration) WithGenerateName(value string) *RoleApplyConfiguration { 103 b.ensureObjectMetaApplyConfigurationExists() 104 b.GenerateName = &value 105 return b 106} 107 108// WithNamespace sets the Namespace 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 Namespace field is set to the value of the last call. 111func (b *RoleApplyConfiguration) WithNamespace(value string) *RoleApplyConfiguration { 112 b.ensureObjectMetaApplyConfigurationExists() 113 b.Namespace = &value 114 return b 115} 116 117// WithSelfLink sets the SelfLink 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 SelfLink field is set to the value of the last call. 120func (b *RoleApplyConfiguration) WithSelfLink(value string) *RoleApplyConfiguration { 121 b.ensureObjectMetaApplyConfigurationExists() 122 b.SelfLink = &value 123 return b 124} 125 126// WithUID sets the UID 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 UID field is set to the value of the last call. 129func (b *RoleApplyConfiguration) WithUID(value types.UID) *RoleApplyConfiguration { 130 b.ensureObjectMetaApplyConfigurationExists() 131 b.UID = &value 132 return b 133} 134 135// WithResourceVersion sets the ResourceVersion 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 ResourceVersion field is set to the value of the last call. 138func (b *RoleApplyConfiguration) WithResourceVersion(value string) *RoleApplyConfiguration { 139 b.ensureObjectMetaApplyConfigurationExists() 140 b.ResourceVersion = &value 141 return b 142} 143 144// WithGeneration sets the Generation 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 Generation field is set to the value of the last call. 147func (b *RoleApplyConfiguration) WithGeneration(value int64) *RoleApplyConfiguration { 148 b.ensureObjectMetaApplyConfigurationExists() 149 b.Generation = &value 150 return b 151} 152 153// WithCreationTimestamp sets the CreationTimestamp 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 CreationTimestamp field is set to the value of the last call. 156func (b *RoleApplyConfiguration) WithCreationTimestamp(value metav1.Time) *RoleApplyConfiguration { 157 b.ensureObjectMetaApplyConfigurationExists() 158 b.CreationTimestamp = &value 159 return b 160} 161 162// WithDeletionTimestamp sets the DeletionTimestamp 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 DeletionTimestamp field is set to the value of the last call. 165func (b *RoleApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *RoleApplyConfiguration { 166 b.ensureObjectMetaApplyConfigurationExists() 167 b.DeletionTimestamp = &value 168 return b 169} 170 171// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds 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 DeletionGracePeriodSeconds field is set to the value of the last call. 174func (b *RoleApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *RoleApplyConfiguration { 175 b.ensureObjectMetaApplyConfigurationExists() 176 b.DeletionGracePeriodSeconds = &value 177 return b 178} 179 180// WithLabels puts the entries into the Labels field in the declarative configuration 181// and returns the receiver, so that objects can be build by chaining "With" function invocations. 182// If called multiple times, the entries provided by each call will be put on the Labels field, 183// overwriting an existing map entries in Labels field with the same key. 184func (b *RoleApplyConfiguration) WithLabels(entries map[string]string) *RoleApplyConfiguration { 185 b.ensureObjectMetaApplyConfigurationExists() 186 if b.Labels == nil && len(entries) > 0 { 187 b.Labels = make(map[string]string, len(entries)) 188 } 189 for k, v := range entries { 190 b.Labels[k] = v 191 } 192 return b 193} 194 195// WithAnnotations puts the entries into the Annotations field in the declarative configuration 196// and returns the receiver, so that objects can be build by chaining "With" function invocations. 197// If called multiple times, the entries provided by each call will be put on the Annotations field, 198// overwriting an existing map entries in Annotations field with the same key. 199func (b *RoleApplyConfiguration) WithAnnotations(entries map[string]string) *RoleApplyConfiguration { 200 b.ensureObjectMetaApplyConfigurationExists() 201 if b.Annotations == nil && len(entries) > 0 { 202 b.Annotations = make(map[string]string, len(entries)) 203 } 204 for k, v := range entries { 205 b.Annotations[k] = v 206 } 207 return b 208} 209 210// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration 211// and returns the receiver, so that objects can be build by chaining "With" function invocations. 212// If called multiple times, values provided by each call will be appended to the OwnerReferences field. 213func (b *RoleApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *RoleApplyConfiguration { 214 b.ensureObjectMetaApplyConfigurationExists() 215 for i := range values { 216 if values[i] == nil { 217 panic("nil value passed to WithOwnerReferences") 218 } 219 b.OwnerReferences = append(b.OwnerReferences, *values[i]) 220 } 221 return b 222} 223 224// WithFinalizers adds the given value to the Finalizers field in the declarative configuration 225// and returns the receiver, so that objects can be build by chaining "With" function invocations. 226// If called multiple times, values provided by each call will be appended to the Finalizers field. 227func (b *RoleApplyConfiguration) WithFinalizers(values ...string) *RoleApplyConfiguration { 228 b.ensureObjectMetaApplyConfigurationExists() 229 for i := range values { 230 b.Finalizers = append(b.Finalizers, values[i]) 231 } 232 return b 233} 234 235// WithClusterName sets the ClusterName field in the declarative configuration to the given value 236// and returns the receiver, so that objects can be built by chaining "With" function invocations. 237// If called multiple times, the ClusterName field is set to the value of the last call. 238func (b *RoleApplyConfiguration) WithClusterName(value string) *RoleApplyConfiguration { 239 b.ensureObjectMetaApplyConfigurationExists() 240 b.ClusterName = &value 241 return b 242} 243 244func (b *RoleApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { 245 if b.ObjectMetaApplyConfiguration == nil { 246 b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} 247 } 248} 249 250// WithRules adds the given value to the Rules field in the declarative configuration 251// and returns the receiver, so that objects can be build by chaining "With" function invocations. 252// If called multiple times, values provided by each call will be appended to the Rules field. 253func (b *RoleApplyConfiguration) WithRules(values ...*PolicyRuleApplyConfiguration) *RoleApplyConfiguration { 254 for i := range values { 255 if values[i] == nil { 256 panic("nil value passed to WithRules") 257 } 258 b.Rules = append(b.Rules, *values[i]) 259 } 260 return b 261} 262