mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-06 14:16:51 +08:00
update: added reserved workspace names
This commit is contained in:
@@ -5,14 +5,20 @@ import (
|
|||||||
"github.com/golang/protobuf/ptypes/empty"
|
"github.com/golang/protobuf/ptypes/empty"
|
||||||
"github.com/onepanelio/core/api"
|
"github.com/onepanelio/core/api"
|
||||||
v1 "github.com/onepanelio/core/pkg"
|
v1 "github.com/onepanelio/core/pkg"
|
||||||
|
"github.com/onepanelio/core/pkg/util"
|
||||||
"github.com/onepanelio/core/pkg/util/pagination"
|
"github.com/onepanelio/core/pkg/util/pagination"
|
||||||
"github.com/onepanelio/core/pkg/util/ptr"
|
"github.com/onepanelio/core/pkg/util/ptr"
|
||||||
"github.com/onepanelio/core/server/auth"
|
"github.com/onepanelio/core/server/auth"
|
||||||
"github.com/onepanelio/core/server/converter"
|
"github.com/onepanelio/core/server/converter"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var reservedWorkspaceNames = map[string]bool{
|
||||||
|
"modeldb": true,
|
||||||
|
}
|
||||||
|
|
||||||
type WorkspaceServer struct{}
|
type WorkspaceServer struct{}
|
||||||
|
|
||||||
func apiWorkspace(wt *v1.Workspace, config v1.SystemConfig) *api.Workspace {
|
func apiWorkspace(wt *v1.Workspace, config v1.SystemConfig) *api.Workspace {
|
||||||
@@ -106,6 +112,10 @@ func (s *WorkspaceServer) CreateWorkspace(ctx context.Context, req *api.CreateWo
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, isReserved := reservedWorkspaceNames[workspace.Name]; isReserved {
|
||||||
|
return nil, util.NewUserError(codes.AlreadyExists, "That name is reserved, choose a different name for the workspace.")
|
||||||
|
}
|
||||||
|
|
||||||
workspace, err = client.CreateWorkspace(req.Namespace, workspace)
|
workspace, err = client.CreateWorkspace(req.Namespace, workspace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Reference in New Issue
Block a user