From 51df97119cf68b80dee7295793ce44482a20e5aa Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Wed, 6 Mar 2019 21:56:22 -0500 Subject: [PATCH] Add version flag --- cmd/csi-resizer/main.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/csi-resizer/main.go b/cmd/csi-resizer/main.go index af12fa81f..6b37b9246 100644 --- a/cmd/csi-resizer/main.go +++ b/cmd/csi-resizer/main.go @@ -18,6 +18,8 @@ package main import ( "flag" + "fmt" + "os" "time" "github.com/kubernetes-csi/external-resizer/pkg/controller" @@ -35,8 +37,9 @@ var ( resyncPeriod = flag.Duration("resync-period", time.Minute*10, "Resync period for cache") workers = flag.Int("workers", 10, "Concurrency to process multiple resize requests") - csiAddress = flag.String("csi-address", "/run/csi/socket", "Address of the CSI driver socket.") - csiTimeout = flag.Duration("csiTimeout", 15*time.Second, "Timeout for waiting for CSI driver socket.") + csiAddress = flag.String("csi-address", "/run/csi/socket", "Address of the CSI driver socket.") + csiTimeout = flag.Duration("csiTimeout", 15*time.Second, "Timeout for waiting for CSI driver socket.") + showVersion = flag.Bool("version", false, "Show version") enableLeaderElection = flag.Bool("leader-election", false, "Enable leader election.") leaderElectionIdentity = flag.String("leader-election-identity", "", "Unique identity of this resizer. Typically name of the pod where the resizer runs.") @@ -56,6 +59,7 @@ var ( "slot. This is effectively the maximum duration that a leader can be stopped "+ "before it is replaced by another candidate. This is only applicable if leader "+ "election is enabled.") + version = "unknown" ) func main() { @@ -63,6 +67,12 @@ func main() { flag.Set("logtostderr", "true") flag.Parse() + if *showVersion { + fmt.Println(os.Args[0], version) + os.Exit(0) + } + klog.Infof("Version : %s", version) + kubeClient, err := util.NewK8sClient(*master, *kubeConfig) if err != nil { klog.Fatal(err.Error())