mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-05 13:46: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/onepanelio/core/api"
|
||||
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/ptr"
|
||||
"github.com/onepanelio/core/server/auth"
|
||||
"github.com/onepanelio/core/server/converter"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc/codes"
|
||||
"time"
|
||||
)
|
||||
|
||||
var reservedWorkspaceNames = map[string]bool{
|
||||
"modeldb": true,
|
||||
}
|
||||
|
||||
type WorkspaceServer struct{}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user