Debian Codegraph @

auth/rbac/reconciliation/clusterrole_interfaces.go

raw symbols SCIP
1 /*
2 Copyright 2017 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 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 // +k8s:deepcopy-gen=true
29 // +k8s:deepcopy-gen:interfaces=k8s.io/component-helpers/auth/rbac/reconciliation.RuleOwner
30 // +k8s:deepcopy-gen:nonpointer-interfaces=true
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 }