update: added reserved workspace names

This commit is contained in:
Andrey Melnikov
2020-07-21 14:37:51 -07:00
parent 7af3c9dd7c
commit e66c095500

View File

@@ -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