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.

Let repo create choose visibility, not an owner

d74e7e231de16fa00366dc8ccc392fc9c637b52d · Keenan Nemetz · 3d ago · parent 3455902a

Let repo create choose visibility, not an owner

A repository has no owner: the argument only seeded one admin entry in the
ACL store, and instance admins can already administer every repository. The
create command therefore asked for a fact the repository does not keep.

Replace --owner with --visibility private|public on `vole admin repo create`,
the remote admin command, and the web form. The initial rule set is written
once, inside the store, so a public repository is never briefly private. An
admin who wants to hand a repository to someone grants a role with the acl
commands, exactly as for any later access change.

closes: 01M82CC7G9W46PRP89GQ5CNMDE

cmd/vole/repo.go +22−17

@@ -6,6 +6,7 @@ import (
6 6
7 7 "rodent.software/vole/forge"
8 8 "rodent.software/vole/forge/access"
9 "rodent.software/vole/forge/repo"
9 10 )
10 11
11 12 // ---------- repo ----------
@@ -16,17 +17,17 @@ var repoGroup = &group{
16 17 Summary: "create, inspect, rename, and delete repositories",
17 18 Flags: []flagSpec{
18 19 configFlag(),
19 {long: "owner", short: "o", arg: "<account>", desc: "the account that owns the new repository and becomes its first admin"},
20 {long: "visibility", arg: "<private|public>", desc: "who may read the new repository; private unless this is public"},
20 21 {long: "description", short: "d", arg: "<text>", desc: "one line shown beside the repository"},
21 22 },
22 23 Subs: []subcommand{
23 {Name: "create", Synopsis: "admin repo create --owner <account> <name> [--description <text>]", Flags: []string{"config", "owner", "description"}},
24 {Name: "create", Synopsis: "admin repo create <name> [--description <text>] [--visibility private|public]", Flags: []string{"config", "visibility", "description"}},
24 25 {Name: "list", Synopsis: "admin repo list", Flags: []string{"config"}},
25 26 {Name: "show", Synopsis: "admin repo show <name>", Flags: []string{"config"}},
26 27 {Name: "rename", Synopsis: "admin repo rename <old> <new>", Flags: []string{"config"}},
27 28 {Name: "delete", Synopsis: "admin repo delete <name>", Flags: []string{"config"}, Notes: []string{"Deleting a repository removes its refs, its metadata branch, its LFS objects and its CI history. It is audited, and there is no undo."}},
28 29 },
29 Notes: []string{"New repositories are private. The owner becomes the first admin."},
30 Notes: []string{"New repositories are private unless --visibility public is given. Access is granted afterwards with the acl commands; an instance admin can administer any repository."},
30 31 See: []seeAlso{{"Accounts and access", "accounts-and-access.md"}},
31 32 }
32 33
@@ -71,30 +72,34 @@ func cmdRepo(args []string) error {
71 72 switch sub {
72 73 case "create":
73 74 if len(f.rest) != 1 {
74 return usageErr{msg: "usage: vole admin repo create --owner <account> <name>"}
75 return usageErr{msg: "usage: vole admin repo create <name> [--description <text>] [--visibility private|public]"}
75 76 }
76 owner := f.one("owner")
77 if owner == "" {
78 return usageErr{msg: "--owner is required: it becomes the repository's first admin"}
77 visibilityName := f.one("visibility")
78 if visibilityName == "" {
79 visibilityName = string(repo.Private)
79 80 }
80 // ACLs are keyed by account name, so the owner is resolved once here and
81 // the name is what gets stored.
82 ownerAccount, err := st.Identity.Find(owner)
81 visibility, err := repo.ParseVisibility(visibilityName)
83 82 if err != nil {
84 return err
85 }
86 if !ownerAccount.Active() {
87 return fmt.Errorf("owner %q is retired", ownerAccount.Name)
83 return usageErr{msg: err.Error()}
88 84 }
89 m, err := st.Repos.Create(f.rest[0], ownerAccount.Name, f.one("description"))
85 m, err := st.Repos.Create(f.rest[0], repo.CreateOptions{
86 Description: f.one("description"),
87 Visibility: visibility,
88 Actor: os.Getenv("USER"),
89 })
90 90 if err != nil {
91 91 return err
92 92 }
93 93 if err := st.Index.Upsert(m); err != nil {
94 94 return err
95 95 }
96 fmt.Printf("created %s (id %s)\n", m.Name, m.ID)
97 fmt.Printf(" new repos are private; publish with: vole admin acl set-default-role %s read\n", m.Name)
96 fmt.Printf("created %s (id %s, %s)\n", m.Name, m.ID, visibility)
97 if visibility == repo.Public {
98 fmt.Printf(" anyone may read it; grant access with: vole admin acl set-role %s <account> contribute\n", m.Name)
99 } else {
100 fmt.Printf(" grant access with: vole admin acl set-role %s <account> admin\n", m.Name)
101 fmt.Printf(" publish for anonymous reads with: vole admin acl set-default-role %s read\n", m.Name)
102 }
98 103 return nil
99 104
100 105 case "list":