From 3eda49669c1fa00144fd6499c031bc1b50d63b60 Mon Sep 17 00:00:00 2001 From: Kevin Zhao Date: Fri, 25 Aug 2017 14:00:45 +0800 Subject: [PATCH] Add "--version" parameters to cmd Closes-bug: #1712486 Change-Id: I824bba993fa82eb0c74b53c7b2cb7835c3e53b37 Signed-off-by: Kevin Zhao --- cmd/kubestack/kubestack.go | 4 ++-- cmd/stackube-controller/stackube-controller.go | 7 +++++++ cmd/stackube-proxy/stackube-proxy.go | 8 ++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cmd/kubestack/kubestack.go b/cmd/kubestack/kubestack.go index b563a78..5172e4f 100644 --- a/cmd/kubestack/kubestack.go +++ b/cmd/kubestack/kubestack.go @@ -356,11 +356,11 @@ func AddIgnoreUnknownArgs() error { } func main() { - // Display the version on "-v", otherwise just delegate to the skel code. + // Display the version on "--version", otherwise just delegate to the skel code. // Use a new flag set so as not to conflict with existing libraries which use "flag" flagSet := flag.NewFlagSet("kubestack", flag.ExitOnError) - version := flagSet.Bool("v", false, "Display version") + version := flagSet.Bool("version", false, "Display version") err := flagSet.Parse(os.Args[1:]) if err != nil { fmt.Println(err) diff --git a/cmd/stackube-controller/stackube-controller.go b/cmd/stackube-controller/stackube-controller.go index f8f448c..9216c2b 100644 --- a/cmd/stackube-controller/stackube-controller.go +++ b/cmd/stackube-controller/stackube-controller.go @@ -45,6 +45,8 @@ var ( "path to stackube config file") userCIDR = pflag.String("user-cidr", "10.244.0.0/16", "user Pod network CIDR") userGateway = pflag.String("user-gateway", "10.244.0.1", "user Pod network gateway") + version = pflag.Bool("version", false, "Display version") + VERSION = "0.1" ) func startControllers(kubeClient *kubernetes.Clientset, @@ -133,6 +135,11 @@ func main() { util.InitLogs() defer util.FlushLogs() + if *version { + fmt.Println(VERSION) + os.Exit(0) + } + // Initilize kubernetes and openstack clients. kubeClient, osClient, kubeExtClient, err := initClients() if err != nil { diff --git a/cmd/stackube-proxy/stackube-proxy.go b/cmd/stackube-proxy/stackube-proxy.go index 69e83c3..95b7843 100644 --- a/cmd/stackube-proxy/stackube-proxy.go +++ b/cmd/stackube-proxy/stackube-proxy.go @@ -27,6 +27,7 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" + "os" ) var ( @@ -34,6 +35,8 @@ var ( "path to kubernetes admin config file") cloudconfig = pflag.String("cloudconfig", "/etc/stackube.conf", "path to stackube config file") + version = pflag.Bool("version", false, "Display version") + VERSION = "0.1" ) func verifyClientSetting() error { @@ -60,6 +63,11 @@ func main() { util.InitLogs() defer util.FlushLogs() + if *version { + fmt.Println(VERSION) + os.Exit(0) + } + // Verify client setting at the beginning and fail early if there are errors. err := verifyClientSetting() if err != nil {