-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
49 lines (40 loc) · 1.08 KB
/
main.go
File metadata and controls
49 lines (40 loc) · 1.08 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
package main
import (
"fmt"
"os"
"runtime/debug"
"github.com/eth-p/kubesel/internal/cli"
"github.com/shirou/gopsutil/v4/host"
)
// THIS FILE IS ONLY A PROGRAM ENTRYPOINT.
//
// The kubesel command-line is implemented by the `internal/cli` package.
// We can't implement it here as part of `main` because we need to be able
// to access the cobra.Command structs for manpage generation.
func main() {
host.EnableBootTimeCache(true)
cli.DetectTerminal()
exitcode, _ := cli.Run(os.Args[1:])
os.Exit(exitcode)
}
func init() {
cli.RootCommand.Version = getVersion()
}
// VERSION is the most recent git tag.
var VERSION string = "v0.0.1"
// GIT_REVISION is defined by a go build flag.
// If empty, this will be read from the build info instead.
var GIT_REVISION string
func getVersion() string {
if GIT_REVISION == "" {
if buildinfo, ok := debug.ReadBuildInfo(); ok {
for _, buildsetting := range buildinfo.Settings {
switch buildsetting.Key {
case "vcs.revision":
GIT_REVISION = buildsetting.Value
}
}
}
}
return fmt.Sprintf("%s (%s)", VERSION, GIT_REVISION)
}