From 2a738fe5bcf56ddad354dd3854e129174c6d0699 Mon Sep 17 00:00:00 2001 From: caiweidong Date: Tue, 5 Mar 2019 13:00:16 +0800 Subject: [PATCH] add flag version --- cmd/hostpathplugin/main.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/hostpathplugin/main.go b/cmd/hostpathplugin/main.go index d4f443f79..48f5feb78 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,23 @@ 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.") + // Set by the build process + version = "" ) func main() { flag.Parse() + if *showVersion { + baseName := path.Base(os.Args[0]) + fmt.Println(baseName, version) + return + } + handle() os.Exit(0) }