From e18d8b631b4e202b8ecaf2e7e2d271bfc6829916 Mon Sep 17 00:00:00 2001 From: caiweidong Date: Wed, 27 Feb 2019 16:20:12 +0800 Subject: [PATCH] Add flag version --- cmd/hostpathplugin/main.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/hostpathplugin/main.go b/cmd/hostpathplugin/main.go index d4f443f79..f75aa5d4c 100644 --- a/cmd/hostpathplugin/main.go +++ b/cmd/hostpathplugin/main.go @@ -20,6 +20,7 @@ import ( "flag" "fmt" "os" + "path" "github.com/kubernetes-csi/csi-driver-host-path/pkg/hostpath" ) @@ -29,14 +30,22 @@ func init() { } var ( - endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI endpoint") - driverName = flag.String("drivername", "csi-hostpath", "name of the driver") - nodeID = flag.String("nodeid", "", "node id") + endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI endpoint") + driverName = flag.String("drivername", "csi-hostpath", "name of the driver") + nodeID = flag.String("nodeid", "", "node id") + showVersion = flag.Bool("version", false, "Show version.") + version = "" ) func main() { flag.Parse() + if *showVersion { + baseName := path.Base(os.Args[0]) + fmt.Println(baseName, version) + return + } + handle() os.Exit(0) }