Merge pull request #11569 from ywk253100/200410_replication

Add "delete" into the action map if the action in token is "*"
This commit is contained in:
Wenkai Yin(尹文开) 2020-04-10 18:06:47 +08:00 committed by GitHub
commit 81a4e7d468
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -94,13 +94,16 @@ func New(ctx context.Context, name string, access []*registry_token.ResourceActi
}
actionMap := make(map[types.Action]struct{})
for _, a := range ac.Actions {
if a == "pull" || a == "*" {
switch a {
case "pull":
actionMap[rbac.ActionPull] = struct{}{}
}
if a == "push" || a == "*" {
case "push":
actionMap[rbac.ActionPush] = struct{}{}
}
if a == "scanner-pull" {
case "*":
actionMap[rbac.ActionPull] = struct{}{}
actionMap[rbac.ActionPush] = struct{}{}
actionMap[rbac.ActionDelete] = struct{}{}
case "scanner-pull":
actionMap[rbac.ActionScannerPull] = struct{}{}
}
}

View File

@ -69,6 +69,11 @@ func TestAll(t *testing.T) {
action: rbac.ActionPush,
expect: true,
},
{
resource: rbac.NewProjectNamespace(2).Resource(rbac.ResourceRepository),
action: rbac.ActionDelete,
expect: true,
},
{
resource: rbac.NewProjectNamespace(2).Resource(rbac.ResourceRepository),
action: rbac.ActionScannerPull,