2017-10-25 17:02:49 -07:00
package main
import (
"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"
2017-11-13 23:28:38 +02:00
"github.com/sirupsen/logrus"
2017-10-25 17:02:49 -07:00
"github.com/urfave/cli"
)
2018-01-15 23:35:31 +02:00
var VERSION = "v0.0.12-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 {
if ctx . GlobalBool ( "debug" ) {
logrus . SetLevel ( logrus . DebugLevel )
}
2018-06-23 14:51:48 +02:00
logrus . Debugf ( "RKE version %s" , app . Version )
2018-07-02 12:29:24 +02:00
if released . MatchString ( 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-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 ( ) ,
2017-10-29 11:45:21 +02:00
}
app . Flags = [ ] cli . Flag {
cli . BoolFlag {
Name : "debug,d" ,
Usage : "Debug logging" ,
} ,
}
2017-11-02 12:07:10 +02:00
return app . Run ( os . Args )
2017-10-25 17:02:49 -07:00
}