rolebinding.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /*
  2. Copyright The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. // Code generated by applyconfiguration-gen. DO NOT EDIT.
  14. package v1alpha1
  15. import (
  16. rbacv1alpha1 "k8s.io/api/rbac/v1alpha1"
  17. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  18. types "k8s.io/apimachinery/pkg/types"
  19. managedfields "k8s.io/apimachinery/pkg/util/managedfields"
  20. internal "k8s.io/client-go/applyconfigurations/internal"
  21. v1 "k8s.io/client-go/applyconfigurations/meta/v1"
  22. )
  23. // RoleBindingApplyConfiguration represents an declarative configuration of the RoleBinding type for use
  24. // with apply.
  25. type RoleBindingApplyConfiguration struct {
  26. v1.TypeMetaApplyConfiguration `json:",inline"`
  27. *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
  28. Subjects []SubjectApplyConfiguration `json:"subjects,omitempty"`
  29. RoleRef *RoleRefApplyConfiguration `json:"roleRef,omitempty"`
  30. }
  31. // RoleBinding constructs an declarative configuration of the RoleBinding type for use with
  32. // apply.
  33. func RoleBinding(name, namespace string) *RoleBindingApplyConfiguration {
  34. b := &RoleBindingApplyConfiguration{}
  35. b.WithName(name)
  36. b.WithNamespace(namespace)
  37. b.WithKind("RoleBinding")
  38. b.WithAPIVersion("rbac.authorization.k8s.io/v1alpha1")
  39. return b
  40. }
  41. // ExtractRoleBinding extracts the applied configuration owned by fieldManager from
  42. // roleBinding. If no managedFields are found in roleBinding for fieldManager, a
  43. // RoleBindingApplyConfiguration is returned with only the Name, Namespace (if applicable),
  44. // APIVersion and Kind populated. It is possible that no managed fields were found for because other
  45. // field managers have taken ownership of all the fields previously owned by fieldManager, or because
  46. // the fieldManager never owned fields any fields.
  47. // roleBinding must be a unmodified RoleBinding API object that was retrieved from the Kubernetes API.
  48. // ExtractRoleBinding provides a way to perform a extract/modify-in-place/apply workflow.
  49. // Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
  50. // applied if another fieldManager has updated or force applied any of the previously applied fields.
  51. // Experimental!
  52. func ExtractRoleBinding(roleBinding *rbacv1alpha1.RoleBinding, fieldManager string) (*RoleBindingApplyConfiguration, error) {
  53. return extractRoleBinding(roleBinding, fieldManager, "")
  54. }
  55. // ExtractRoleBindingStatus is the same as ExtractRoleBinding except
  56. // that it extracts the status subresource applied configuration.
  57. // Experimental!
  58. func ExtractRoleBindingStatus(roleBinding *rbacv1alpha1.RoleBinding, fieldManager string) (*RoleBindingApplyConfiguration, error) {
  59. return extractRoleBinding(roleBinding, fieldManager, "status")
  60. }
  61. func extractRoleBinding(roleBinding *rbacv1alpha1.RoleBinding, fieldManager string, subresource string) (*RoleBindingApplyConfiguration, error) {
  62. b := &RoleBindingApplyConfiguration{}
  63. err := managedfields.ExtractInto(roleBinding, internal.Parser().Type("io.k8s.api.rbac.v1alpha1.RoleBinding"), fieldManager, b, subresource)
  64. if err != nil {
  65. return nil, err
  66. }
  67. b.WithName(roleBinding.Name)
  68. b.WithNamespace(roleBinding.Namespace)
  69. b.WithKind("RoleBinding")
  70. b.WithAPIVersion("rbac.authorization.k8s.io/v1alpha1")
  71. return b, nil
  72. }
  73. // WithKind sets the Kind field in the declarative configuration to the given value
  74. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  75. // If called multiple times, the Kind field is set to the value of the last call.
  76. func (b *RoleBindingApplyConfiguration) WithKind(value string) *RoleBindingApplyConfiguration {
  77. b.Kind = &value
  78. return b
  79. }
  80. // WithAPIVersion sets the APIVersion field in the declarative configuration to the given value
  81. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  82. // If called multiple times, the APIVersion field is set to the value of the last call.
  83. func (b *RoleBindingApplyConfiguration) WithAPIVersion(value string) *RoleBindingApplyConfiguration {
  84. b.APIVersion = &value
  85. return b
  86. }
  87. // WithName sets the Name 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 Name field is set to the value of the last call.
  90. func (b *RoleBindingApplyConfiguration) WithName(value string) *RoleBindingApplyConfiguration {
  91. b.ensureObjectMetaApplyConfigurationExists()
  92. b.Name = &value
  93. return b
  94. }
  95. // WithGenerateName sets the GenerateName 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 GenerateName field is set to the value of the last call.
  98. func (b *RoleBindingApplyConfiguration) WithGenerateName(value string) *RoleBindingApplyConfiguration {
  99. b.ensureObjectMetaApplyConfigurationExists()
  100. b.GenerateName = &value
  101. return b
  102. }
  103. // WithNamespace sets the Namespace 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 Namespace field is set to the value of the last call.
  106. func (b *RoleBindingApplyConfiguration) WithNamespace(value string) *RoleBindingApplyConfiguration {
  107. b.ensureObjectMetaApplyConfigurationExists()
  108. b.Namespace = &value
  109. return b
  110. }
  111. // WithUID sets the UID 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 UID field is set to the value of the last call.
  114. func (b *RoleBindingApplyConfiguration) WithUID(value types.UID) *RoleBindingApplyConfiguration {
  115. b.ensureObjectMetaApplyConfigurationExists()
  116. b.UID = &value
  117. return b
  118. }
  119. // WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value
  120. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  121. // If called multiple times, the ResourceVersion field is set to the value of the last call.
  122. func (b *RoleBindingApplyConfiguration) WithResourceVersion(value string) *RoleBindingApplyConfiguration {
  123. b.ensureObjectMetaApplyConfigurationExists()
  124. b.ResourceVersion = &value
  125. return b
  126. }
  127. // WithGeneration sets the Generation 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 Generation field is set to the value of the last call.
  130. func (b *RoleBindingApplyConfiguration) WithGeneration(value int64) *RoleBindingApplyConfiguration {
  131. b.ensureObjectMetaApplyConfigurationExists()
  132. b.Generation = &value
  133. return b
  134. }
  135. // WithCreationTimestamp sets the CreationTimestamp 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 CreationTimestamp field is set to the value of the last call.
  138. func (b *RoleBindingApplyConfiguration) WithCreationTimestamp(value metav1.Time) *RoleBindingApplyConfiguration {
  139. b.ensureObjectMetaApplyConfigurationExists()
  140. b.CreationTimestamp = &value
  141. return b
  142. }
  143. // WithDeletionTimestamp sets the DeletionTimestamp 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 DeletionTimestamp field is set to the value of the last call.
  146. func (b *RoleBindingApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *RoleBindingApplyConfiguration {
  147. b.ensureObjectMetaApplyConfigurationExists()
  148. b.DeletionTimestamp = &value
  149. return b
  150. }
  151. // WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value
  152. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  153. // If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call.
  154. func (b *RoleBindingApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *RoleBindingApplyConfiguration {
  155. b.ensureObjectMetaApplyConfigurationExists()
  156. b.DeletionGracePeriodSeconds = &value
  157. return b
  158. }
  159. // WithLabels puts the entries into the Labels field in the declarative configuration
  160. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  161. // If called multiple times, the entries provided by each call will be put on the Labels field,
  162. // overwriting an existing map entries in Labels field with the same key.
  163. func (b *RoleBindingApplyConfiguration) WithLabels(entries map[string]string) *RoleBindingApplyConfiguration {
  164. b.ensureObjectMetaApplyConfigurationExists()
  165. if b.Labels == nil && len(entries) > 0 {
  166. b.Labels = make(map[string]string, len(entries))
  167. }
  168. for k, v := range entries {
  169. b.Labels[k] = v
  170. }
  171. return b
  172. }
  173. // WithAnnotations puts the entries into the Annotations field in the declarative configuration
  174. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  175. // If called multiple times, the entries provided by each call will be put on the Annotations field,
  176. // overwriting an existing map entries in Annotations field with the same key.
  177. func (b *RoleBindingApplyConfiguration) WithAnnotations(entries map[string]string) *RoleBindingApplyConfiguration {
  178. b.ensureObjectMetaApplyConfigurationExists()
  179. if b.Annotations == nil && len(entries) > 0 {
  180. b.Annotations = make(map[string]string, len(entries))
  181. }
  182. for k, v := range entries {
  183. b.Annotations[k] = v
  184. }
  185. return b
  186. }
  187. // WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
  188. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  189. // If called multiple times, values provided by each call will be appended to the OwnerReferences field.
  190. func (b *RoleBindingApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *RoleBindingApplyConfiguration {
  191. b.ensureObjectMetaApplyConfigurationExists()
  192. for i := range values {
  193. if values[i] == nil {
  194. panic("nil value passed to WithOwnerReferences")
  195. }
  196. b.OwnerReferences = append(b.OwnerReferences, *values[i])
  197. }
  198. return b
  199. }
  200. // WithFinalizers adds the given value to the Finalizers field in the declarative configuration
  201. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  202. // If called multiple times, values provided by each call will be appended to the Finalizers field.
  203. func (b *RoleBindingApplyConfiguration) WithFinalizers(values ...string) *RoleBindingApplyConfiguration {
  204. b.ensureObjectMetaApplyConfigurationExists()
  205. for i := range values {
  206. b.Finalizers = append(b.Finalizers, values[i])
  207. }
  208. return b
  209. }
  210. func (b *RoleBindingApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
  211. if b.ObjectMetaApplyConfiguration == nil {
  212. b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
  213. }
  214. }
  215. // WithSubjects adds the given value to the Subjects field in the declarative configuration
  216. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  217. // If called multiple times, values provided by each call will be appended to the Subjects field.
  218. func (b *RoleBindingApplyConfiguration) WithSubjects(values ...*SubjectApplyConfiguration) *RoleBindingApplyConfiguration {
  219. for i := range values {
  220. if values[i] == nil {
  221. panic("nil value passed to WithSubjects")
  222. }
  223. b.Subjects = append(b.Subjects, *values[i])
  224. }
  225. return b
  226. }
  227. // WithRoleRef sets the RoleRef field in the declarative configuration to the given value
  228. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  229. // If called multiple times, the RoleRef field is set to the value of the last call.
  230. func (b *RoleBindingApplyConfiguration) WithRoleRef(value *RoleRefApplyConfiguration) *RoleBindingApplyConfiguration {
  231. b.RoleRef = value
  232. return b
  233. }