Stars: implement full CRUD operations via legacy service (#110489)
This commit is contained in:
@@ -25,11 +25,11 @@ func (o OwnerReference) AsName() string {
|
||||
if o.Name == "" || o.Owner == NamespaceResourceOwner {
|
||||
return string(o.Owner)
|
||||
}
|
||||
return string(o.Owner) + ":" + o.Name
|
||||
return string(o.Owner) + "-" + o.Name
|
||||
}
|
||||
|
||||
func ParseOwnerFromName(name string) (OwnerReference, bool) {
|
||||
before, after, found := strings.Cut(name, ":")
|
||||
before, after, found := strings.Cut(name, "-")
|
||||
if found && len(after) > 0 {
|
||||
switch before {
|
||||
case "user":
|
||||
|
||||
@@ -17,31 +17,31 @@ func TestLegacyAuthorizer(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "invalid",
|
||||
input: "xxx:yyy",
|
||||
input: "xxx-yyy",
|
||||
output: utils.OwnerReference{},
|
||||
found: false,
|
||||
},
|
||||
{
|
||||
name: "with user",
|
||||
input: "user:a",
|
||||
input: "user-a",
|
||||
output: utils.OwnerReference{Owner: utils.UserResourceOwner, Name: "a"},
|
||||
found: true,
|
||||
},
|
||||
{
|
||||
name: "missing user",
|
||||
input: "user:",
|
||||
input: "user-",
|
||||
output: utils.OwnerReference{},
|
||||
found: false,
|
||||
},
|
||||
{
|
||||
name: "with team",
|
||||
input: "team:b",
|
||||
input: "team-b",
|
||||
output: utils.OwnerReference{Owner: utils.TeamResourceOwner, Name: "b"},
|
||||
found: true,
|
||||
},
|
||||
{
|
||||
name: "missing team",
|
||||
input: "team:",
|
||||
input: "team-",
|
||||
output: utils.OwnerReference{},
|
||||
found: false,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user