2021-02-01 11:06:34 -07:00
//go:generate go run k8s.io/gengo/examples/deepcopy-gen --go-header-file ./scripts/boilerplate.go.txt --input-dirs ./types --input-dirs ./types/kdm --output-file-base zz_generated_deepcopy
2020-02-13 15:55:19 -07:00
//go:generate go run ./codegen/codegen.go
2021-02-01 11:06:34 -07:00
//go:generate go run github.com/go-bindata/go-bindata/go-bindata -o ./data/bindata.go -ignore bindata.go -pkg data -modtime 1557785965 -mode 0644 ./data/
2017-10-25 17:02:49 -07:00
package main
import (
2023-08-04 13:01:50 +02:00
"io"
2017-10-25 17:02:49 -07:00
"os"
2018-07-02 12:29:24 +02:00
"regexp"
2017-10-25 17:02:49 -07:00
2018-09-26 17:16:44 +08:00
"github.com/mattn/go-colorable"
2017-10-29 11:45:21 +02:00
"github.com/rancher/rke/cmd"
2020-02-13 15:55:19 -07:00
"github.com/rancher/rke/metadata"
2017-11-13 23:28:38 +02:00
"github.com/sirupsen/logrus"
2017-10-25 17:02:49 -07:00
"github.com/urfave/cli"
)
2019-09-02 18:30:07 +08:00
// VERSION gets overridden at build time using -X main.VERSION=$VERSION
2019-07-16 16:04:10 +02:00
var VERSION = "dev"
2018-07-02 12:29:24 +02:00
var released = regexp . MustCompile ( ` ^v[0-9]+\.[0-9]+\.[0-9]+$ ` )
2017-10-25 17:02:49 -07:00
func main ( ) {
2018-09-26 17:16:44 +08:00
logrus . SetOutput ( colorable . NewColorableStdout ( ) )
2017-11-02 12:07:10 +02:00
if err := mainErr ( ) ; err != nil {
logrus . Fatal ( err )
}
}
func mainErr ( ) error {
2017-10-25 17:02:49 -07:00
app := cli . NewApp ( )
app . Name = "rke"
app . Version = VERSION
2018-06-23 14:51:48 +02:00
app . Usage = "Rancher Kubernetes Engine, an extremely simple, lightning fast Kubernetes installer that works everywhere"
2017-10-29 11:45:21 +02:00
app . Before = func ( ctx * cli . Context ) error {
2019-08-23 12:51:34 -07:00
if ctx . GlobalBool ( "quiet" ) {
2023-08-04 13:01:50 +02:00
logrus . SetOutput ( io . Discard )
2020-03-03 16:04:05 +01:00
} else {
if ctx . GlobalBool ( "debug" ) {
logrus . SetLevel ( logrus . DebugLevel )
logrus . Debugf ( "Loglevel set to [%v]" , logrus . DebugLevel )
}
if ctx . GlobalBool ( "trace" ) {
logrus . SetLevel ( logrus . TraceLevel )
logrus . Tracef ( "Loglevel set to [%v]" , logrus . TraceLevel )
}
2019-08-23 12:51:34 -07:00
}
2018-07-02 12:29:24 +02:00
if released . MatchString ( app . Version ) {
2019-05-28 11:51:53 -07:00
metadata . RKEVersion = app . Version
2018-07-02 12:29:24 +02:00
return nil
}
2020-11-24 21:01:48 +01:00
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" , app . Version )
2017-10-25 17:02:49 -07:00
return nil
}
2017-10-29 11:45:21 +02:00
app . Author = "Rancher Labs, Inc."
app . Email = ""
app . Commands = [ ] cli . Command {
2017-11-28 13:26:15 +02:00
cmd . UpCommand ( ) ,
cmd . RemoveCommand ( ) ,
cmd . VersionCommand ( ) ,
2017-11-21 00:23:50 +02:00
cmd . ConfigCommand ( ) ,
2018-05-09 19:39:19 +02:00
cmd . EtcdCommand ( ) ,
2018-08-20 06:37:04 +02:00
cmd . CertificateCommand ( ) ,
2019-10-03 03:56:39 +02:00
cmd . EncryptionCommand ( ) ,
2020-09-28 14:59:44 +02:00
cmd . UtilCommand ( ) ,
2017-10-29 11:45:21 +02:00
}
app . Flags = [ ] cli . Flag {
cli . BoolFlag {
Name : "debug,d" ,
Usage : "Debug logging" ,
} ,
2019-08-23 12:51:34 -07:00
cli . BoolFlag {
Name : "quiet,q" ,
Usage : "Quiet mode, disables logging and only critical output will be printed" ,
} ,
2020-03-03 16:04:05 +01:00
cli . BoolFlag {
Name : "trace" ,
Usage : "Trace logging" ,
} ,
2017-10-29 11:45:21 +02:00
}
2017-11-02 12:07:10 +02:00
return app . Run ( os . Args )
2017-10-25 17:02:49 -07:00
}