mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-05 05:36:50 +08:00
move secret and namespace
This commit is contained in:
@@ -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{}
|
||||
|
Reference in New Issue
Block a user