|
|
@ -183,14 +183,22 @@ func (n *Node) CreateChild(ident, name, note, cate, creator string, leaf, proxy
|
|
|
|
return nil, fmt.Errorf("tenant node should be root node only")
|
|
|
|
return nil, fmt.Errorf("tenant node should be root node only")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if cate == "project" && (n.Cate != "tenant" && n.Cate != "organization") {
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("project node should be under tenant or organization")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ident == "" {
|
|
|
|
if ident == "" {
|
|
|
|
return nil, fmt.Errorf("ident is blank")
|
|
|
|
return nil, fmt.Errorf("ident is blank")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !str.IsMatch(ident, "^[a-zA-Z0-9\\-\\_]+$") {
|
|
|
|
if !str.IsMatch(ident, "^[a-z0-9\\-\\_]+$") {
|
|
|
|
return nil, fmt.Errorf("ident invalid")
|
|
|
|
return nil, fmt.Errorf("ident invalid")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(ident) >= 32 {
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("ident length should be less than 32")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if creator != "system" {
|
|
|
|
if creator != "system" {
|
|
|
|
// 人为创建的节点,有些保留名字不能使用,是为了给PaaS各个子系统注册资源所用
|
|
|
|
// 人为创建的节点,有些保留名字不能使用,是为了给PaaS各个子系统注册资源所用
|
|
|
|
if (n.Path == "inner" || n.Cate == "project") && slice.ContainsString(protectedNodeIdents, ident) {
|
|
|
|
if (n.Path == "inner" || n.Cate == "project") && slice.ContainsString(protectedNodeIdents, ident) {
|
|
|
|