Sign in

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

vole
Clone

Read only, no credentials:

https://rodent.software/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

A free and open-source forge that lives in your Git repo.

Code

392 commit(s) on main

Merge change request 01M70WES5ZZDJ6RP226WB11BBZ: Let people rename and remove their own passkeys keenan · 1h ago 4b8c9e1d
history blame raw 1.2 KiB
1// Package role is the ordered access role shared by a repository's rules and by
2// workflow event filters. It lives in core because both the access store and the
3// workflow schema need to name a role without one importing the other.
4package role
5
6import (
7 "fmt"
8 "strings"
9)
10
11type Role int
12
13const (
14 None Role = iota
15 Read
16 Contribute
17 Maintain
18 Admin
19)
20
21// Parse accepts the canonical names and the historical spellings used by ACL rows
22// and scripts, so a workflow can say "write" or "maintain" and mean the same thing.
23func Parse(s string) (Role, error) {
24 switch strings.ToLower(strings.TrimSpace(s)) {
25 case "", "none":
26 return None, nil
27 case "read":
28 return Read, nil
29 case "contribute", "contributor", "contrib":
30 return Contribute, nil
31 case "maintain", "maintainer", "write":
32 return Maintain, nil
33 case "admin", "owner":
34 return Admin, nil
35 }
36 return None, fmt.Errorf("unknown role %q (want none, read, contribute, maintain or admin)", s)
37}
38
39func (r Role) String() string {
40 switch r {
41 case Read:
42 return "read"
43 case Contribute:
44 return "contribute"
45 case Maintain:
46 return "maintain"
47 case Admin:
48 return "admin"
49 }
50 return "none"
51}
52
53func (r Role) AtLeast(need Role) bool { return r >= need }
54