-
Notifications
You must be signed in to change notification settings - Fork 59
/
main.go
45 lines (32 loc) · 954 Bytes
/
main.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 (
"encoding/json"
"fmt"
"log"
"os"
"github.com/buildkite/go-buildkite/v3/buildkite"
"gopkg.in/alecthomas/kingpin.v2"
)
var (
apiToken = kingpin.Flag("token", "API token").Required().String()
org = kingpin.Flag("org", "Orginization slug").Required().String()
clusterID = kingpin.Flag("clusterID", "Cluster UUID").Required().String()
debug = kingpin.Flag("debug", "Enable debugging").Bool()
)
func main() {
kingpin.Parse()
config, err := buildkite.NewTokenConfig(*apiToken, *debug)
if err != nil {
log.Fatalf("client config failed: %s", err)
}
client := buildkite.NewClient(config.Client())
queues, _, err := client.ClusterQueues.List(*org, *clusterID, nil)
if err != nil {
log.Fatalf("Listing cluster queues failed: %s", err)
}
data, err := json.MarshalIndent(queues, "", "\t")
if err != nil {
log.Fatalf("json encode failed: %s", err)
}
fmt.Fprintf(os.Stdout, "%s", string(data))
}