| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package reconciliation |
| 18 |
|
| 19 |
import ( |
| 20 |
"context" |
| 21 |
|
| 22 |
rbacv1 "k8s.io/api/rbac/v1" |
| 23 |
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 24 |
"k8s.io/apimachinery/pkg/runtime" |
| 25 |
rbacv1client "k8s.io/client-go/kubernetes/typed/rbac/v1" |
| 26 |
) |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
type ClusterRoleRuleOwner struct { |
| 32 |
ClusterRole *rbacv1.ClusterRole |
| 33 |
} |
| 34 |
|
| 35 |
func (o ClusterRoleRuleOwner) GetObject() runtime.Object { |
| 36 |
return o.ClusterRole |
| 37 |
} |
| 38 |
|
| 39 |
func (o ClusterRoleRuleOwner) GetNamespace() string { |
| 40 |
return o.ClusterRole.Namespace |
| 41 |
} |
| 42 |
|
| 43 |
func (o ClusterRoleRuleOwner) GetName() string { |
| 44 |
return o.ClusterRole.Name |
| 45 |
} |
| 46 |
|
| 47 |
func (o ClusterRoleRuleOwner) GetLabels() map[string]string { |
| 48 |
return o.ClusterRole.Labels |
| 49 |
} |
| 50 |
|
| 51 |
func (o ClusterRoleRuleOwner) SetLabels(in map[string]string) { |
| 52 |
o.ClusterRole.Labels = in |
| 53 |
} |
| 54 |
|
| 55 |
func (o ClusterRoleRuleOwner) GetAnnotations() map[string]string { |
| 56 |
return o.ClusterRole.Annotations |
| 57 |
} |
| 58 |
|
| 59 |
func (o ClusterRoleRuleOwner) SetAnnotations(in map[string]string) { |
| 60 |
o.ClusterRole.Annotations = in |
| 61 |
} |
| 62 |
|
| 63 |
func (o ClusterRoleRuleOwner) GetRules() []rbacv1.PolicyRule { |
| 64 |
return o.ClusterRole.Rules |
| 65 |
} |
| 66 |
|
| 67 |
func (o ClusterRoleRuleOwner) SetRules(in []rbacv1.PolicyRule) { |
| 68 |
o.ClusterRole.Rules = in |
| 69 |
} |
| 70 |
|
| 71 |
func (o ClusterRoleRuleOwner) GetAggregationRule() *rbacv1.AggregationRule { |
| 72 |
return o.ClusterRole.AggregationRule |
| 73 |
} |
| 74 |
|
| 75 |
func (o ClusterRoleRuleOwner) SetAggregationRule(in *rbacv1.AggregationRule) { |
| 76 |
o.ClusterRole.AggregationRule = in |
| 77 |
} |
| 78 |
|
| 79 |
type ClusterRoleModifier struct { |
| 80 |
Client rbacv1client.ClusterRoleInterface |
| 81 |
} |
| 82 |
|
| 83 |
func (c ClusterRoleModifier) Get(namespace, name string) (RuleOwner, error) { |
| 84 |
ret, err := c.Client.Get(context.TODO(), name, metav1.GetOptions{}) |
| 85 |
if err != nil { |
| 86 |
return nil, err |
| 87 |
} |
| 88 |
return ClusterRoleRuleOwner{ClusterRole: ret}, err |
| 89 |
} |
| 90 |
|
| 91 |
func (c ClusterRoleModifier) Create(in RuleOwner) (RuleOwner, error) { |
| 92 |
ret, err := c.Client.Create(context.TODO(), in.(ClusterRoleRuleOwner).ClusterRole, metav1.CreateOptions{}) |
| 93 |
if err != nil { |
| 94 |
return nil, err |
| 95 |
} |
| 96 |
return ClusterRoleRuleOwner{ClusterRole: ret}, err |
| 97 |
} |
| 98 |
|
| 99 |
func (c ClusterRoleModifier) Update(in RuleOwner) (RuleOwner, error) { |
| 100 |
ret, err := c.Client.Update(context.TODO(), in.(ClusterRoleRuleOwner).ClusterRole, metav1.UpdateOptions{}) |
| 101 |
if err != nil { |
| 102 |
return nil, err |
| 103 |
} |
| 104 |
return ClusterRoleRuleOwner{ClusterRole: ret}, err |
| 105 |
|
| 106 |
} |