(role *codersdk.Role, resource string, actions []string)
| 439 | } |
| 440 | |
| 441 | func applyOrgResourceActions(role *codersdk.Role, resource string, actions []string) { |
| 442 | if role.OrganizationPermissions == nil { |
| 443 | role.OrganizationPermissions = make([]codersdk.Permission, 0) |
| 444 | } |
| 445 | |
| 446 | // Construct new site perms with only new perms for the resource |
| 447 | keep := make([]codersdk.Permission, 0) |
| 448 | for _, perm := range role.OrganizationPermissions { |
| 449 | if string(perm.ResourceType) != resource { |
| 450 | keep = append(keep, perm) |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | // Add new perms |
| 455 | for _, action := range actions { |
| 456 | keep = append(keep, codersdk.Permission{ |
| 457 | Negate: false, |
| 458 | ResourceType: codersdk.RBACResource(resource), |
| 459 | Action: codersdk.RBACAction(action), |
| 460 | }) |
| 461 | } |
| 462 | |
| 463 | role.OrganizationPermissions = keep |
| 464 | } |
| 465 | |
| 466 | func defaultActions(role *codersdk.Role, resource string) []string { |
| 467 | if role.OrganizationPermissions == nil { |
no test coverage detected