MCPcopy Index your code
hub / github.com/coder/coder / applyOrgResourceActions

Function applyOrgResourceActions

cli/organizationroles.go:441–464  ·  view source on GitHub ↗
(role *codersdk.Role, resource string, actions []string)

Source from the content-addressed store, hash-verified

439}
440
441func 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
466func defaultActions(role *codersdk.Role, resource string) []string {
467 if role.OrganizationPermissions == nil {

Callers 1

interactiveOrgRoleEditFunction · 0.85

Calls 2

RBACResourceTypeAlias · 0.92
RBACActionTypeAlias · 0.92

Tested by

no test coverage detected