/
main.go
67 lines (53 loc) · 1.28 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"log"
"encoding/json"
"os"
"flag"
"github.com/samilton/bouncer/engine"
)
type webhook struct {
After string `json:"after"`
HeadCommit headCommit `json:"head_commit"`
Repository repo `json:"repository"`
}
type headCommit struct {
Added []string `json:"added"`
Modified []string `json:"modified"`
Removed []string `json:"removed"`
Author author `json:"author"`
Committer committer `json:"committer"`
Message string `json:"message"`
}
type author struct {
Email string `json:"email"`
Name string `json:"name"`
UserName string `json:"username"`
}
type committer struct {
Email string `json:"email"`
Name string `json:"name"`
UserName string `json:"username"`
}
type repo struct {
CreatedAt int64 `json:"created_at"`
Name string `json:"name"`
Description string `json:"description"`
MasterBranch string `json:"master_branch"`
Url string `json:"url"`
}
func main() {
var configFile string
flag.StringVar(&configFile, "configFile", "bouncer.json", "Configuration File")
flag.Parse()
config, err := os.Open(configFile)
log.Println("Starting Web Bouncer Daemon")
if err == nil {
decoder := json.NewDecoder(config)
var configuration engine.Configuration
decoder.Decode(&configuration)
engine.Start(&configuration)
} else {
panic(err)
}
}