clusterrole_interfaces.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. Copyright 2017 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. package reconciliation
  14. import (
  15. rbacv1 "k8s.io/api/rbac/v1"
  16. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  17. "k8s.io/apimachinery/pkg/runtime"
  18. rbacv1client "k8s.io/client-go/kubernetes/typed/rbac/v1"
  19. )
  20. // +k8s:deepcopy-gen=true
  21. // +k8s:deepcopy-gen:interfaces=k8s.io/kubernetes/pkg/registry/rbac/reconciliation.RuleOwner
  22. // +k8s:deepcopy-gen:nonpointer-interfaces=true
  23. type ClusterRoleRuleOwner struct {
  24. ClusterRole *rbacv1.ClusterRole
  25. }
  26. func (o ClusterRoleRuleOwner) GetObject() runtime.Object {
  27. return o.ClusterRole
  28. }
  29. func (o ClusterRoleRuleOwner) GetNamespace() string {
  30. return o.ClusterRole.Namespace
  31. }
  32. func (o ClusterRoleRuleOwner) GetName() string {
  33. return o.ClusterRole.Name
  34. }
  35. func (o ClusterRoleRuleOwner) GetLabels() map[string]string {
  36. return o.ClusterRole.Labels
  37. }
  38. func (o ClusterRoleRuleOwner) SetLabels(in map[string]string) {
  39. o.ClusterRole.Labels = in
  40. }
  41. func (o ClusterRoleRuleOwner) GetAnnotations() map[string]string {
  42. return o.ClusterRole.Annotations
  43. }
  44. func (o ClusterRoleRuleOwner) SetAnnotations(in map[string]string) {
  45. o.ClusterRole.Annotations = in
  46. }
  47. func (o ClusterRoleRuleOwner) GetRules() []rbacv1.PolicyRule {
  48. return o.ClusterRole.Rules
  49. }
  50. func (o ClusterRoleRuleOwner) SetRules(in []rbacv1.PolicyRule) {
  51. o.ClusterRole.Rules = in
  52. }
  53. func (o ClusterRoleRuleOwner) GetAggregationRule() *rbacv1.AggregationRule {
  54. return o.ClusterRole.AggregationRule
  55. }
  56. func (o ClusterRoleRuleOwner) SetAggregationRule(in *rbacv1.AggregationRule) {
  57. o.ClusterRole.AggregationRule = in
  58. }
  59. type ClusterRoleModifier struct {
  60. Client rbacv1client.ClusterRoleInterface
  61. }
  62. func (c ClusterRoleModifier) Get(namespace, name string) (RuleOwner, error) {
  63. ret, err := c.Client.Get(name, metav1.GetOptions{})
  64. if err != nil {
  65. return nil, err
  66. }
  67. return ClusterRoleRuleOwner{ClusterRole: ret}, err
  68. }
  69. func (c ClusterRoleModifier) Create(in RuleOwner) (RuleOwner, error) {
  70. ret, err := c.Client.Create(in.(ClusterRoleRuleOwner).ClusterRole)
  71. if err != nil {
  72. return nil, err
  73. }
  74. return ClusterRoleRuleOwner{ClusterRole: ret}, err
  75. }
  76. func (c ClusterRoleModifier) Update(in RuleOwner) (RuleOwner, error) {
  77. ret, err := c.Client.Update(in.(ClusterRoleRuleOwner).ClusterRole)
  78. if err != nil {
  79. return nil, err
  80. }
  81. return ClusterRoleRuleOwner{ClusterRole: ret}, err
  82. }