Repository navigation
Expand file tree
/
Copy pathcli.go
More file actions
93 lines (89 loc) · 2.1 KB
/
Copy pathcli.go
File metadata and controls
93 lines (89 loc) · 2.1 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
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/urfave/cli"
)
func setupCli() *cli.App {
app := cli.NewApp()
app.Name = "kube-watch"
setupCommands(app)
return app
}
func setupCommands(app *cli.App) {
app.Commands = []cli.Command{
{
Name: "run",
Description: "Watch from localhost on current-context in ~/.kube/config",
Action: watch,
Before: func(c *cli.Context) error {
path := c.String("kube-config")
dir := os.Getenv("HOME")
if path[:2] == "~/" {
path = filepath.Join(dir, path[2:])
c.Set("kube-config", path)
}
return nil
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "kube-config",
Value: fmt.Sprintf("%s/.kube/config", os.Getenv("HOME")),
},
cli.StringFlag{
Name: "url",
Usage: "Url where to sent the hook",
},
cli.StringFlag{
Name: "slack-channel-url",
Usage: "Sent event to slack channel url",
},
cli.StringFlag{
Name: "watch-type",
Usage: "Type of event to watch on (Warning, Normal)",
Value: "ALL",
},
cli.StringFlag{
Name: "watch-kind",
Usage: "Kind of K8S resource to watch on (Pod, Service). Alias not supported",
Value: "ALL",
},
cli.BoolFlag{
Name: "in-cluster",
Usage: "Run kube-watch from in cluster using service account token",
Hidden: false,
},
},
},
{
Name: "install",
Description: "Instal kube-watch on you cluster",
Action: installInCluster,
Flags: []cli.Flag{
cli.StringFlag{
Name: "kube-config",
Value: fmt.Sprintf("%s/.kube/config", os.Getenv("HOME")),
},
cli.StringFlag{
Name: "url",
Usage: "Url where to sent the hook",
},
cli.StringFlag{
Name: "slack-channel-url",
Usage: "Sent event to slack channel url",
},
cli.StringFlag{
Name: "watch-type",
Usage: "Type of event to watch on (Warning, Normal)",
Value: "ALL",
},
cli.StringFlag{
Name: "watch-kind",
Usage: "Kind of K8S resource to watch on (Pod, Service). Alias not supported",
Value: "ALL",
},
},
},
}
}