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

server/ssh/admin.go +27−12

@@ -478,22 +478,27 @@ func (s *Server) adminRepo(action string, args []string, actor string) (any, adm
478 478
479 479 case "create":
480 480 f, err := parseAdminFlags(args,
481 adminFlagSpec{long: "owner", short: "o"},
481 adminFlagSpec{long: "visibility"},
482 482 adminFlagSpec{long: "description", short: "d"})
483 483 if err != nil {
484 484 return nil, nil, err
485 485 }
486 if len(f.rest) != 1 || f.one("owner") == "" {
487 return nil, nil, &adminUsageError{msg: "usage: vole-admin repo create --owner <account> <name> [--description <text>]"}
486 if len(f.rest) != 1 {
487 return nil, nil, &adminUsageError{msg: "usage: vole-admin repo create <name> [--description <text>] [--visibility private|public]"}
488 488 }
489 owner, err := s.cfg.Identity.Find(f.one("owner"))
490 if err != nil {
491 return nil, nil, err
489 visibilityName := f.one("visibility")
490 if visibilityName == "" {
491 visibilityName = string(repo.Private)
492 492 }
493 if !owner.Active() {
494 return nil, nil, fmt.Errorf("owner %q is retired", owner.Name)
493 visibility, err := repo.ParseVisibility(visibilityName)
494 if err != nil {
495 return nil, nil, &adminUsageError{msg: err.Error()}
495 496 }
496 m, err := s.cfg.Instance.Repos.Create(f.rest[0], owner.Name, f.one("description"))
497 m, err := s.cfg.Instance.Repos.Create(f.rest[0], repo.CreateOptions{
498 Description: f.one("description"),
499 Visibility: visibility,
500 Actor: actor,
501 })
497 502 if err != nil {
498 503 return nil, nil, err
499 504 }
@@ -505,8 +510,13 @@ func (s *Server) adminRepo(action string, args []string, actor string) (any, adm
505 510 return nil, nil, err
506 511 }
507 512 return data, func(out, errOut io.Writer) {
508 fmt.Fprintf(out, "created %s (id %s)\n", m.Name, m.ID)
509 fmt.Fprintf(errOut, "new repositories are private; publish with: vole admin acl set-default-role %s read\n", m.Name)
513 fmt.Fprintf(out, "created %s (id %s, %s)\n", m.Name, m.ID, visibility)
514 if visibility == repo.Public {
515 fmt.Fprintf(errOut, "anyone may read it; grant access with: vole admin acl set-role %s <account> contribute\n", m.Name)
516 return
517 }
518 fmt.Fprintf(errOut, "new repositories are private; grant access with: vole admin acl set-role %s <account> admin\n", m.Name)
519 fmt.Fprintf(errOut, "publish for anonymous reads with: vole admin acl set-default-role %s read\n", m.Name)
510 520 }, nil
511 521
512 522 case "rename":
@@ -807,12 +817,17 @@ func (s *Server) repoData(m *repo.Meta) (map[string]any, *access.ACL, error) {
807 817 if err != nil {
808 818 return nil, nil, err
809 819 }
820 visibility := repo.Private
821 if a.Can("", access.Read) {
822 visibility = repo.Public
823 }
810 824 return map[string]any{
811 825 "id": m.ID,
812 826 "name": m.Name,
813 827 "description": m.Description,
814 828 "default_branch": m.DefaultBranch,
815 "public": a.Can("", access.Read),
829 "visibility": visibility,
830 "public": visibility == repo.Public,
816 831 "principals": len(a.Entries),
817 832 "created": m.Created,
818 833 }, a, nil