-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathmain.go
More file actions
130 lines (115 loc) · 3.28 KB
/
main.go
File metadata and controls
130 lines (115 loc) · 3.28 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package main
import (
"net/http"
"os"
"github.com/codegangsta/cli"
"github.com/supergiant/supergiant/api"
"github.com/supergiant/supergiant/core"
)
func main() {
app := cli.NewApp()
app.Name = "supergiant-api"
app.Usage = "The Supergiant api server."
c := new(core.Core)
app.Action = func(ctx *cli.Context) {
core.SetLogLevel(ctx.String("log-level"))
// Check the args. The ones we don't have default values for...
if c.K8sUser == "" {
core.Log.Error("Kubernetes HTTP basic username required")
cli.ShowCommandHelp(ctx, "")
os.Exit(5)
}
if c.K8sPass == "" {
core.Log.Error("Kubernetes HTTP basic password required")
cli.ShowCommandHelp(ctx, "")
os.Exit(5)
}
c.EtcdEndpoints = ctx.StringSlice("etcd-hosts")
if len(c.EtcdEndpoints) < 0 {
c.EtcdEndpoints = []string{"http://etcd:2379"}
}
// Log args that have default values.
core.Log.Info("ETCD hosts,", c.EtcdEndpoints)
core.Log.Info("Kubernetes Host,", c.K8sHost)
c.Initialize()
router := api.NewRouter(c)
core.Log.Info("Serving API on port :8080")
core.Log.Info(http.ListenAndServe(":8080", router))
}
app.Flags = []cli.Flag{
cli.StringSliceFlag{
Name: "etcd-hosts",
Usage: "Array of etcd hosts.",
EnvVar: "ETCD_ENDPOINT",
},
cli.StringFlag{
Name: "k8s-host, kh",
Value: "kubernetes", // TODO is this working?
Usage: "IP of a Kuberntes api.",
EnvVar: "K8S_HOST",
Destination: &c.K8sHost,
},
cli.StringFlag{
Name: "k8s-user, ku",
Usage: "Username used to connect to your Kubernetes api.",
EnvVar: "K8S_USER",
Destination: &c.K8sUser,
},
cli.StringFlag{
Name: "k8s-pass, kp",
Usage: "Password used to connect to your Kubernetes api.",
EnvVar: "K8S_PASS",
Destination: &c.K8sPass,
},
cli.StringFlag{
Name: "aws-region, ar",
Usage: "AWS Region in which your kubernetes cluster resides.",
EnvVar: "AWS_REGION",
Destination: &c.AwsRegion,
},
cli.StringFlag{
Name: "aws-az, az",
Usage: "AWS Availability Zone in which your kubernetes cluster resides.",
EnvVar: "AWS_AZ",
Destination: &c.AwsAZ,
},
cli.StringFlag{
Name: "aws-sg-id, sg",
Usage: "AWS Security Group in which your kubernetes cluster resides.",
EnvVar: "AWS_SG_ID",
Destination: &c.AwsSgID,
},
cli.StringFlag{
Name: "aws-subnet-id, sid",
Usage: "AWS Subnet ID in which your kubernetes cluster resides.",
EnvVar: "AWS_SUBNET_ID",
Destination: &c.AwsSubnetID,
},
cli.StringFlag{
Name: "aws-access-key",
Usage: "AWS Access key.",
Destination: &c.AwsAccessKey,
},
cli.StringFlag{
Name: "aws-secret-key",
Usage: "AWS Secret key.",
Destination: &c.AwsSecretKey,
},
cli.BoolFlag{
Name: "k8s-insecure-https",
Usage: "Skip verification if HTTPS mode when connecting to Kubernetes.",
Destination: &c.K8sInsecureHTTPS,
},
cli.BoolFlag{
Name: "enable-capacity-service",
Usage: "Enable the automatic creation/deletion of servers to meet requested capacity.",
Destination: &c.CapacityServiceEnabled,
},
cli.StringFlag{
Name: "log-level",
Value: "info",
Usage: "Set the API log level",
},
}
app.Run(os.Args)
}