-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelp.go
More file actions
89 lines (84 loc) · 3.29 KB
/
help.go
File metadata and controls
89 lines (84 loc) · 3.29 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
package main
import (
"fmt"
)
var GitTag string
var GitCommit string
var GoVersion string
var BuildTimestamp string
var BuildOS string
var BuildArch string
var BuildTainted string
func PrintVersion() {
if GitTag != "" {
if BuildTainted == "true" {
fmt.Printf("Version: %s (tainted)\n", GitTag)
} else {
fmt.Printf("Version: %s\n", GitTag)
}
}
fmt.Printf("Commit SHA: %s\n", GitCommit)
fmt.Printf("Go Version: %s\n", GoVersion)
fmt.Printf("Built: %s\n", BuildTimestamp)
fmt.Printf("OS/Arch: %s/%s\n", BuildOS, BuildArch)
}
func PrintUsage() {
fmt.Println("connectivity is a tool for validating network connectivity requirements.")
fmt.Println("")
fmt.Println("Usage: connectivity <command>")
fmt.Println("")
fmt.Println("Commands:")
fmt.Println(" check Check all connectivity once and exit")
fmt.Println(" wait Wait for all connectivity to be validated successfully")
fmt.Println(" monitor Continuously monitor all connectivity forever")
fmt.Println(" validate-config Load config without making any network requests")
fmt.Println(" version Show version information")
fmt.Println(" help Show this help text")
fmt.Println("")
fmt.Println("Use \"connectivity help <command>\" for more information about that command.")
}
func PrintCommandUsage(command string) bool {
if command == "check" {
fmt.Println("Validate specified connectivity once and exit.")
fmt.Println("")
fmt.Println("Usage: connectivity check [urls]")
fmt.Println("")
fmt.Println("This is useful when you want to externally orchestrate other processes by")
fmt.Println("quickly validating connectivity.")
} else if command == "wait" || command == "waitfor" {
fmt.Println("Wait for all specified connectivity to be validated successfully at least once.")
fmt.Println("")
fmt.Println("Usage: connectivity [wait|waitfor] [urls]")
fmt.Println("")
fmt.Println("This is useful when you need to wait for DNS propogation, a process to start")
fmt.Println("listening, configuration to be applied, etc, before doing something else. The")
fmt.Println("results of each check are emitted via statsd.")
} else if command == "monitor" {
fmt.Println("Continuously monitor all connectivity forever.")
fmt.Println("")
fmt.Println("Usage: connectivity monitor [urls]")
fmt.Println("")
fmt.Println("This is useful to run as a daemon for continuously monitoring network")
fmt.Println("dependencies. The results of each check are emitted via statsd.")
} else if command == "version" {
fmt.Println("Show version information about this build")
fmt.Println("")
fmt.Println("Usage: connectivity version")
} else if command == "validate-config" {
fmt.Println("Load config without making any network requests.")
fmt.Println("")
fmt.Println("Usage: connectivity validate-config [config-path]")
fmt.Println("")
fmt.Println("Any validation errors will produce a non-zero return code (1). Only the config")
fmt.Println("file at the specified path is validated. If no config file is specified, then")
fmt.Println("the first config file discovered in order order of precedence is validated:")
fmt.Println("")
fmt.Println("- ./connectivity.yml")
fmt.Println("- ~/.connectivity.yml")
fmt.Println("- /etc/connectivity.yml")
} else {
PrintUsage()
return false
}
return true
}