diff --git a/server/workspace_server.go b/server/workspace_server.go index 577e239..08050ce 100644 --- a/server/workspace_server.go +++ b/server/workspace_server.go @@ -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