-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (30 loc) · 832 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
package main
import (
"flag"
stdlog "log"
"net/http"
"os"
"github.com/dombott/updog/github"
"github.com/go-logr/logr"
"github.com/go-logr/stdr"
)
type updog struct {
log logr.Logger
client *github.Client
}
func main() {
addr := flag.String("addr", ":8080", "address to listen on")
owner := flag.String("owner", "", "github repo owner")
repo := flag.String("repo", "", "github repo name")
token := os.Getenv("GH_TOKEN")
flag.Parse()
log := stdr.NewWithOptions(stdlog.New(os.Stderr, "", stdlog.LstdFlags), stdr.Options{LogCaller: stdr.All})
log = log.WithName("updog")
updog := &updog{
log: log,
client: github.NewClient(token, *owner, *repo),
}
http.HandleFunc("/healthz", healthz)
http.HandleFunc("/webhook", updog.webhook)
log.Error(http.ListenAndServe(*addr, nil), "failed to serve http")
}