-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.go
104 lines (100 loc) · 2.33 KB
/
commands.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
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
package cli
import (
"time"
cli "github.com/urfave/cli"
)
var defaultEndpointFlags = []cli.Flag{
cli.IntFlag{
Name: "attempts, a",
Value: 5,
Usage: "how many times to check endpoint",
},
cli.Int64Flag{
Name: "thresholdrtt, rtt",
Value: 0,
Usage: "Threshold Rtt to define a degraded endpoint",
},
}
// Commands is a list of commands that will be used in main function of cli app
var Commands = cli.Commands{
{
Name: "add-http",
Usage: "Add endpoints to checkup",
Action: addHTTPEndpoint,
UsageText: "checklist add-http [command options] name url",
Flags: append(
defaultEndpointFlags,
cli.StringFlag{
Name: "mustcontain",
Value: "",
Usage: "HTML content that a page should contain to determine whether a page is up or down",
},
cli.StringFlag{
Name: "mustnotcontain",
Value: "",
Usage: "HTML content that a page should not contain to determine whether a page is up or down",
},
cli.StringFlag{
Name: "headers",
Value: "",
Usage: "Http Headers to send along the check request",
},
cli.IntFlag{
Name: "upstatus",
Value: 200,
Usage: "Http status code to define a healthy page",
},
),
},
{
Name: "add-tcp",
Usage: "Add tcp endpoints to checkup",
Action: addTCPEndpoint,
UsageText: "checklist add-http [command options] name url",
Flags: append(
defaultEndpointFlags,
cli.BoolFlag{
Name: "tls-enabled",
Usage: "Enable TLS connection to endpoint",
},
cli.StringFlag{
Name: "tls-ca",
Value: "",
Usage: "Certificate file to established tls connection",
},
cli.BoolFlag{
Name: "tls-skip-verify",
Usage: "Skip verify tls certificate",
},
cli.Int64Flag{
Name: "timeout",
Value: int64(3 * time.Second),
Usage: "Timeout to established a tls connection",
},
),
},
{
Name: "add-dns",
Usage: "Add dns endpoints to checkup",
Action: addDNSEndpoint,
UsageText: "checklist add-dns [command options] name url host",
Flags: append(
defaultEndpointFlags,
cli.Int64Flag{
Name: "timeout",
Value: int64(3 * time.Second),
Usage: "Timeout to established a tls connection",
},
),
},
{
Name: "list",
Usage: "list endpoint",
Action: listEndpoint,
},
{
Name: "delete",
Usage: "delete endpoint",
Action: deleteEndpoint,
},
}