Add GetOwnerAndNameFromIdNoCheck() to fix bug.

This commit is contained in:
Yang Luo 2021-09-05 23:38:37 +08:00
parent ea8971ff29
commit 90ec8ec787
2 changed files with 8 additions and 3 deletions

View File

@ -57,17 +57,17 @@ func getResource(owner string, name string) *Resource {
if existed {
return &resource
}
return nil
}
func GetResource(id string) *Resource {
owner, name := util.GetOwnerAndNameFromId(id)
owner, name := util.GetOwnerAndNameFromIdNoCheck(id)
return getResource(owner, name)
}
func UpdateResource(id string, resource *Resource) bool {
owner, name := util.GetOwnerAndNameFromId(id)
owner, name := util.GetOwnerAndNameFromIdNoCheck(id)
if getResource(owner, name) == nil {
return false
}

View File

@ -43,6 +43,11 @@ func GetOwnerAndNameFromId(id string) (string, string) {
return tokens[0], tokens[1]
}
func GetOwnerAndNameFromIdNoCheck(id string) (string, string) {
tokens := strings.SplitN(id, "/", 2)
return tokens[0], tokens[1]
}
func GenerateId() string {
return uuid.NewString()
}