forked from cnrancher/autok3s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (42 loc) · 1.14 KB
/
main.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
package main
import (
"math/rand"
"os"
"path/filepath"
"time"
"github.com/cnrancher/autok3s/cmd"
"github.com/cnrancher/autok3s/pkg/cli/kubectl"
"github.com/cnrancher/autok3s/pkg/metrics"
"github.com/docker/docker/pkg/reexec"
"github.com/spf13/cobra"
)
var (
gitVersion string
gitCommit string
gitTreeState string
buildDate string
metricsEndpoint = "http://metrics.cnrancher.com:8080/v1/geoIPs"
metricsSourceTag = "AutoK3s"
)
func init() {
reexec.Register("kubectl", kubectl.Main)
}
func main() {
rand.Seed(time.Now().UTC().UnixNano())
args := os.Args[0]
os.Args[0] = filepath.Base(os.Args[0])
if reexec.Init() {
return
}
os.Args[0] = args
rootCmd := cmd.Command()
rootCmd.AddCommand(cmd.CompletionCommand(), cmd.VersionCommand(gitVersion, gitCommit, gitTreeState, buildDate),
cmd.ListCommand(), cmd.CreateCommand(), cmd.JoinCommand(), cmd.KubectlCommand(), cmd.DeleteCommand(),
cmd.SSHCommand(), cmd.DescribeCommand(), cmd.ServeCommand(), cmd.ExplorerCommand())
rootCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
metrics.ReportMetrics()
}
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}