refactor: clean up client code

This commit is contained in:
rushtehrani
2020-06-08 15:25:02 -07:00
parent facbed59bc
commit 5f6bda8838
11 changed files with 72 additions and 60 deletions

View File

@@ -25,7 +25,7 @@ func apiNamespace(ns *v1.Namespace) (namespace *api.Namespace) {
}
func (s *NamespaceServer) ListNamespaces(ctx context.Context, req *api.ListNamespacesRequest) (*api.ListNamespacesResponse, error) {
client := ctx.Value("kubeClient").(*v1.Client)
client := getClient(ctx)
allowed, err := auth.IsAuthorized(client, "", "list", "", "namespaces", "")
if err != nil || !allowed {
return nil, err
@@ -72,7 +72,7 @@ func (s *NamespaceServer) ListNamespaces(ctx context.Context, req *api.ListNames
}
func (s *NamespaceServer) CreateNamespace(ctx context.Context, createNamespace *api.CreateNamespaceRequest) (*api.Namespace, error) {
client := ctx.Value("kubeClient").(*v1.Client)
client := getClient(ctx)
allowed, err := auth.IsAuthorized(client, "", "create", "", "namespaces", "")
if err != nil || !allowed {
return nil, err