1
0
mirror of https://github.com/rancher/rke.git synced 2025-04-27 19:25:44 +00:00
rke/main.go

71 lines
1.8 KiB
Go
Raw Normal View History

2020-02-13 22:55:19 +00:00
//go:generate go run ./codegen/codegen.go
//go:generate go run ./vendor/github.com/go-bindata/go-bindata/go-bindata -o ./data/bindata.go -ignore bindata.go -pkg data -modtime 1557785965 -mode 0644 ./data/
2017-10-26 00:02:49 +00:00
package main
import (
"io/ioutil"
2017-10-26 00:02:49 +00:00
"os"
"regexp"
2017-10-26 00:02:49 +00:00
"github.com/mattn/go-colorable"
2017-10-29 09:45:21 +00:00
"github.com/rancher/rke/cmd"
2020-02-13 22:55:19 +00:00
"github.com/rancher/rke/metadata"
2017-11-13 21:28:38 +00:00
"github.com/sirupsen/logrus"
2017-10-26 00:02:49 +00:00
"github.com/urfave/cli"
)
// VERSION gets overridden at build time using -X main.VERSION=$VERSION
2019-07-16 14:04:10 +00:00
var VERSION = "dev"
var released = regexp.MustCompile(`^v[0-9]+\.[0-9]+\.[0-9]+$`)
2017-10-26 00:02:49 +00:00
func main() {
logrus.SetOutput(colorable.NewColorableStdout())
if err := mainErr(); err != nil {
logrus.Fatal(err)
}
}
func mainErr() error {
2017-10-26 00:02:49 +00:00
app := cli.NewApp()
app.Name = "rke"
app.Version = VERSION
app.Usage = "Rancher Kubernetes Engine, an extremely simple, lightning fast Kubernetes installer that works everywhere"
2017-10-29 09:45:21 +00:00
app.Before = func(ctx *cli.Context) error {
if ctx.GlobalBool("debug") {
logrus.SetLevel(logrus.DebugLevel)
}
if ctx.GlobalBool("quiet") {
logrus.SetOutput(ioutil.Discard)
}
if released.MatchString(app.Version) {
metadata.RKEVersion = app.Version
return nil
}
logrus.Warnf("This is not an officially supported version (%s) of RKE. Please download the latest official release at https://github.com/rancher/rke/releases/latest", app.Version)
2017-10-26 00:02:49 +00:00
return nil
}
2017-10-29 09:45:21 +00:00
app.Author = "Rancher Labs, Inc."
app.Email = ""
app.Commands = []cli.Command{
cmd.UpCommand(),
cmd.RemoveCommand(),
cmd.VersionCommand(),
cmd.ConfigCommand(),
2018-05-09 17:39:19 +00:00
cmd.EtcdCommand(),
2018-08-20 04:37:04 +00:00
cmd.CertificateCommand(),
2019-10-03 01:56:39 +00:00
cmd.EncryptionCommand(),
2017-10-29 09:45:21 +00:00
}
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug,d",
Usage: "Debug logging",
},
cli.BoolFlag{
Name: "quiet,q",
Usage: "Quiet mode, disables logging and only critical output will be printed",
},
2017-10-29 09:45:21 +00:00
}
return app.Run(os.Args)
2017-10-26 00:02:49 +00:00
}