forked from kyma-project/kyma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
34 lines (27 loc) · 1.09 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package roles
import (
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
)
type RolesClientInterface interface {
GetRole(name string, namespace string) (*rbacv1.Role, error)
GetList(namespace string, opts metav1.ListOptions) (*rbacv1.RoleList, error)
CreateRole(role *rbacv1.Role, namespace string) (*rbacv1.Role, error)
DeleteRole(name string, namespace string) error
}
type RolesClient struct {
Clientset *kubernetes.Clientset
}
func (rc *RolesClient) GetRole(name string, namespace string) (*rbacv1.Role, error) {
return rc.Clientset.Rbac().Roles(namespace).Get(name, metav1.GetOptions{})
}
func (rc *RolesClient) GetList(namespace string, opts metav1.ListOptions) (*rbacv1.RoleList, error) {
return rc.Clientset.Rbac().Roles(namespace).List(opts)
}
func (rc *RolesClient) CreateRole(role *rbacv1.Role, namespace string) (*rbacv1.Role, error) {
return rc.Clientset.Rbac().Roles(namespace).Create(role)
}
func (rc *RolesClient) DeleteRole(name string, namespace string) error {
return rc.Clientset.Rbac().Roles(namespace).Delete(name, nil)
}