-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
79 lines (73 loc) · 1.62 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
import (
"os"
"github.com/Sirupsen/logrus"
_ "github.com/go-sql-driver/mysql"
"github.com/rancher/pipeline/config"
"github.com/rancher/pipeline/provider/jenkins"
"github.com/rancher/pipeline/server"
"github.com/urfave/cli"
)
var VERSION = "v0.0.0-dev"
func main() {
app := cli.NewApp()
app.Name = "pipeline"
app.Version = VERSION
app.Usage = "You need help!"
app.Action = checkAndRun
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "jenkins_user",
Usage: "User of jenkins admin",
EnvVar: "JENKINS_USER",
},
cli.StringFlag{
Name: "jenkins_token",
Usage: "token of jenkins admin",
EnvVar: "JENKINS_TOKEN",
},
cli.StringFlag{
Name: "jenkins_address",
Usage: "token of jenkins admin",
EnvVar: "JENKINS_ADDRESS",
Value: "http://jenkins:8080",
},
cli.StringFlag{
Name: "cattle_url",
Usage: "rancher server api address",
EnvVar: "CATTLE_URL",
Value: "",
},
cli.StringFlag{
Name: "cattle_access_key",
Usage: "cattle access key",
EnvVar: "CATTLE_ACCESS_KEY",
Value: "",
},
cli.StringFlag{
Name: "cattle_secret_key",
Usage: "cattle secret key",
EnvVar: "CATTLE_SECRET_KEY",
Value: "",
},
cli.BoolFlag{
Name: "debug",
Usage: "enable debug mode",
EnvVar: "DEBUG",
},
}
app.Run(os.Args)
}
func checkAndRun(c *cli.Context) (rtnerr error) {
if c.GlobalBool("debug") {
logrus.SetLevel(logrus.DebugLevel)
}
config.Parse(c)
jenkins.InitJenkins()
provider := jenkins.JenkinsProvider{}
errChan := make(chan bool)
go server.ListenAndServe(provider, errChan)
<-errChan
logrus.Info("Going down")
return nil
}