Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Name role capabilities consistently

cc5123a549d8d0991e74a88fff8208b5071d1192 · Keenan Nemetz · 1d ago · parent 648cd81b

core/role/role.go +13−10

@@ -24,36 +24,39 @@ const (
24 24 Admin
25 25 )
26 26
27 // Parse accepts the canonical names and the historical spellings used by ACL rows
28 // and scripts, so a workflow can say "write" or "maintain" and mean the same thing.
27 // Parse accepts the canonical noun names and the older verb spellings used by
28 // existing ACL rows, workflow files, and scripts, so a repository keeps working
29 // across the rename.
29 30 func Parse(s string) (Role, error) {
30 31 switch strings.ToLower(strings.TrimSpace(s)) {
31 32 case "", "none":
32 33 return None, nil
33 case "read":
34 case "reader", "read":
34 35 return Read, nil
35 case "contribute", "contributor", "contrib":
36 case "contributor", "contribute", "contrib":
36 37 return Contribute, nil
37 38 case "runner":
38 39 return Runner, nil
39 case "maintain", "maintainer", "write":
40 case "maintainer", "maintain", "write":
40 41 return Maintain, nil
41 case "admin", "owner":
42 case "admin", "administrator", "owner":
42 43 return Admin, nil
43 44 }
44 return None, fmt.Errorf("unknown role %q (want none, read, contribute, runner, maintain or admin)", s)
45 return None, fmt.Errorf("unknown role %q (want none, reader, contributor, runner, maintainer or admin)", s)
45 46 }
46 47
48 // String returns the canonical noun name. Reading a rule set written with the old
49 // verb spellings normalizes it to these names without a separate migration.
47 50 func (r Role) String() string {
48 51 switch r {
49 52 case Read:
50 return "read"
53 return "reader"
51 54 case Contribute:
52 return "contribute"
55 return "contributor"
53 56 case Runner:
54 57 return "runner"
55 58 case Maintain:
56 return "maintain"
59 return "maintainer"
57 60 case Admin:
58 61 return "admin"
59 62 }