move secret and namespace

This commit is contained in:
rushtehrani
2020-02-18 11:31:10 -08:00
parent d14904a894
commit 42f0ff173f
7 changed files with 77 additions and 141 deletions

View File

@@ -6,19 +6,20 @@ import (
"github.com/golang/protobuf/ptypes/empty"
"github.com/onepanelio/core/api"
"github.com/onepanelio/core/manager"
"github.com/onepanelio/core/model"
v1 "github.com/onepanelio/core/pkg"
"github.com/onepanelio/core/util"
"google.golang.org/grpc/codes"
)
type NamespaceServer struct {
resourceManager *manager.ResourceManager
kubeConfig *v1.Config
}
func NewNamespaceServer(resourceManager *manager.ResourceManager) *NamespaceServer {
return &NamespaceServer{resourceManager: resourceManager}
func NewNamespaceServer(kubeConfig *v1.Config) *NamespaceServer {
return &NamespaceServer{kubeConfig: kubeConfig}
}
func apiNamespace(ns *model.Namespace) (namespace *api.Namespace) {
func apiNamespace(ns *v1.Namespace) (namespace *api.Namespace) {
namespace = &api.Namespace{
Name: ns.Name,
}
@@ -27,11 +28,14 @@ func apiNamespace(ns *model.Namespace) (namespace *api.Namespace) {
}
func (s *NamespaceServer) ListNamespaces(ctx context.Context, empty *empty.Empty) (*api.ListNamespacesResponse, error) {
namespaces, err := s.resourceManager.ListNamespaces()
client, err := v1.NewClient(s.kubeConfig, "")
if err != nil {
if errors.As(err, &userError) {
return nil, userError.GRPCError()
}
return nil, util.NewUserError(codes.PermissionDenied, "Permission denied.")
}
namespaces, err := client.ListNamespaces()
if errors.As(err, &userError) {
return nil, userError.GRPCError()
}
apiNamespaces := []*api.Namespace{}