-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkick.go
45 lines (39 loc) · 952 Bytes
/
kick.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"context"
"flag"
"fmt"
"io"
"os"
"strings"
"github.com/mjl-/sherpa/client"
)
func kick(args []string) {
fs := flag.NewFlagSet("kick", flag.ExitOnError)
fs.Usage = func() {
fmt.Fprintln(os.Stderr, "usage: ding kick baseURL repoName branch commit < password-file")
fs.PrintDefaults()
}
fs.Parse(args)
args = fs.Args()
if len(args) != 4 {
fs.Usage()
os.Exit(2)
}
baseURL := args[0]
repoName := args[1]
branch := args[2]
commit := args[3]
buf, err := io.ReadAll(os.Stdin)
xcheckf(err, "reading password from stdin")
password := strings.TrimRight(string(buf), "\n")
client, err := client.New(baseURL, []string{"build"})
xcheckf(err, "initializing sherpa client")
var build struct {
ID int64
}
err = client.Call(context.Background(), &build, "CreateBuild", password, repoName, branch, commit, false)
xcheckf(err, "building")
_, err = fmt.Println("buildId", build.ID)
xcheckf(err, "write")
}