Skip to content
Snippets Groups Projects
Commit bce9cd9b authored by kayrus's avatar kayrus
Browse files

Add --version flag

Resolves #4
parent f554ce08
No related branches found
No related tags found
No related merge requests found
...@@ -2,15 +2,17 @@ PKG:=github.com/sapcc/nova-password ...@@ -2,15 +2,17 @@ PKG:=github.com/sapcc/nova-password
APP_NAME:=nova-password APP_NAME:=nova-password
PWD:=$(shell pwd) PWD:=$(shell pwd)
UID:=$(shell id -u) UID:=$(shell id -u)
VERSION:=$(shell git describe --tags --always --dirty="-dev")
LDFLAGS:=-X main.Version=$(VERSION)
export GO111MODULE:=off export GO111MODULE:=off
export GOPATH:=$(PWD)/gopath export GOPATH:=$(PWD)/gopath
export CGO_ENABLED:=0 export CGO_ENABLED:=0
build: gopath/src/$(PKG) fmt build: gopath/src/$(PKG) fmt
GOOS=linux go build -o bin/$(APP_NAME) $(PKG) GOOS=linux go build -ldflags="$(LDFLAGS)" -o bin/$(APP_NAME) $(PKG)
GOOS=darwin go build -o bin/$(APP_NAME)_darwin $(PKG) GOOS=darwin go build -ldflags="$(LDFLAGS)" -o bin/$(APP_NAME)_darwin $(PKG)
GOOS=windows go build -o bin/$(APP_NAME).exe $(PKG) GOOS=windows go build -ldflags="$(LDFLAGS)" -o bin/$(APP_NAME).exe $(PKG)
docker: docker:
docker run -ti --rm -e GOCACHE=/tmp -v $(PWD):/$(APP_NAME) -u $(UID):$(UID) --workdir /$(APP_NAME) golang:latest make docker run -ti --rm -e GOCACHE=/tmp -v $(PWD):/$(APP_NAME) -u $(UID):$(UID) --workdir /$(APP_NAME) golang:latest make
......
...@@ -10,6 +10,7 @@ Flags: ...@@ -10,6 +10,7 @@ Flags:
-d, --debug print out request and response objects -d, --debug print out request and response objects
-h, --help help for nova-password -h, --help help for nova-password
-i, --private-key-path string a path to the RSA private key (PuTTY and OpenSSH formats) (default "~/.ssh/id_rsa") -i, --private-key-path string a path to the RSA private key (PuTTY and OpenSSH formats) (default "~/.ssh/id_rsa")
--version version for nova-password
-w, --wait uint wait for the password timeout in seconds -w, --wait uint wait for the password timeout in seconds
``` ```
......
...@@ -24,11 +24,14 @@ import ( ...@@ -24,11 +24,14 @@ import (
const MaxKeySize = 10240 const MaxKeySize = 10240
var Version string
// RootCmd represents the base command when called without any subcommands // RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{ var RootCmd = &cobra.Command{
Use: "nova-password <server-name>|<server-id> [<server-name>|<server-id>...]", Use: "nova-password <server-name>|<server-id> [<server-name>|<server-id>...]",
Short: "Get the admin password for an OpenStack server", Short: "Get the admin password for an OpenStack server",
SilenceUsage: true, SilenceUsage: true,
Version: Version,
PreRunE: func(cmd *cobra.Command, args []string) error { PreRunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 { if len(args) == 0 {
cmd.Usage() cmd.Usage()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment