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.

Blame · server/ssh/dispatch.go

Line attribution on main · 57 line(s)

eb07ff56
Keenan Nemetz
8d ago
1 package ssh
2
3 import (
4 "fmt"
5 "strings"
6
7 xssh "golang.org/x/crypto/ssh"
8 )
9
10 // serveWorkflowDispatch queues one manual run.
11 //
12 // vole-workflow-dispatch <repository> <workflow-path> <ref|-> [name=value]...
13 //
14 // The ref "-" means the repository's default branch. The dispatcher on the
15 // instance resolves the workflow, validates the inputs and re-checks the caller's
16 // permission, so this function is only the wire.
17 func (s *Server) serveWorkflowDispatch(ch xssh.Channel, argv []string, user string) int {
18 if len(argv) < 4 {
19 fmt.Fprint(ch, "vole: usage: vole-workflow-dispatch <repository> <workflow> <ref|-> [name=value]...\n")
20 return 129
21 }
22 name, ok := repoName(argv[1])
23 if !ok {
24 fmt.Fprint(ch, "vole: invalid repository name\n")
25 return 129
26 }
27 workflow := strings.TrimSpace(argv[2])
28 if workflow == "" {
29 fmt.Fprint(ch, "vole: a workflow path is required\n")
30 return 129
31 }
32 ref := strings.TrimSpace(argv[3])
33 if ref == "-" {
34 ref = ""
35 }
36 inputs := map[string]string{}
37 for _, pair := range argv[4:] {
38 key, value, ok := strings.Cut(pair, "=")
39 key = strings.TrimSpace(key)
40 if !ok || key == "" {
41 fmt.Fprintf(ch, "vole: input %q is not name=value\n", pair)
42 return 129
43 }
44 inputs[key] = value
45 }
46 if s.cfg.DispatchWorkflow == nil {
47 fmt.Fprint(ch, "vole: manual workflow runs are not configured on this server\n")
48 return 1
49 }
50 n, err := s.cfg.DispatchWorkflow(name, workflow, ref, inputs, user)
51 if err != nil {
52 fmt.Fprintf(ch, "vole: %v\n", err)
53 return 1
54 }
55 fmt.Fprintf(ch, "queued %d run(s)\n", n)
56 return 0
57 }