From 3d8cfcaf161093bf6791cc1e67e656b6d98d7475 Mon Sep 17 00:00:00 2001 From: Will Boyce Date: Tue, 11 Jul 2017 10:40:01 +0100 Subject: [PATCH 1/2] expose version information to build and add --version flag Change-Type: patch --- Makefile | 4 ++-- resin/README.md | 1 + resin/main.go | 9 +++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 013673c..be8be44 100644 --- a/Makefile +++ b/Makefile @@ -53,10 +53,10 @@ clean: # binary bin/$(EXECUTABLE): dep - go build -o "$@" -v ./$(PACKAGE) + go build -ldflags="-X main.version=$(VERSION)" -o "$@" -v ./$(PACKAGE) # release binaries build/%/$(EXECUTABLE): dep - gox -parallel=1 -osarch=$(subst _,/,$(subst build/,,$(@:/$(EXECUTABLE)=))) -output="build/{{.OS}}_{{.Arch}}/$(EXECUTABLE)" ./$(PACKAGE) + gox -parallel=1 -osarch=$(subst _,/,$(subst build/,,$(@:/$(EXECUTABLE)=))) -ldflags="-X main.version=$(VERSION)" -output="build/{{.OS}}_{{.Arch}}/$(EXECUTABLE)" ./$(PACKAGE) # compressed artifacts build/$(EXECUTABLE)-$(VERSION)_%.tar.gz: build/%/$(EXECUTABLE) tar -zcf "$@" -C "$(dir $<)" $(EXECUTABLE) diff --git a/resin/README.md b/resin/README.md index d2b1dc6..212fbc7 100644 --- a/resin/README.md +++ b/resin/README.md @@ -46,6 +46,7 @@ Usage of sshproxy: -s, --shell string Path to shell to execute post-authentication (default "shell.sh") -g, --shell-gid int Group to run shell as (default: current gid) -u, --shell-uid int User to run shell as (default: current uid) + --version Display version and exit ``` ## Auth Failed Banner/Template diff --git a/resin/main.go b/resin/main.go index 0f158b3..194abba 100644 --- a/resin/main.go +++ b/resin/main.go @@ -26,6 +26,7 @@ import ( "log" "os" "path" + "runtime" "syscall" "github.com/getsentry/raven-go" @@ -35,6 +36,8 @@ import ( "golang.org/x/crypto/ssh" ) +var version string + func init() { pflag.CommandLine.StringP("apihost", "H", "api.resin.io", "Resin API Host") pflag.CommandLine.StringP("apiport", "P", "443", "Resin API Port") @@ -48,6 +51,7 @@ func init() { pflag.CommandLine.IntP("max-auth-tries", "m", 0, "Maximum number of authentication attempts per connection (default 0; unlimited)") pflag.CommandLine.BoolP("allow-env", "E", false, "Pass environment from client to shell (default: false) (warning: security implications)") pflag.CommandLine.StringP("sentry-dsn", "S", "", "Sentry DSN for error reporting") + pflag.CommandLine.BoolP("version", "", false, "Display version and exit") viper.SetConfigName("sshproxy") viper.SetEnvPrefix("SSHPROXY") @@ -105,6 +109,11 @@ func main() { viper.AddConfigPath("/etc") _ = viper.ReadInConfig() + if viper.GetBool("version") { + fmt.Printf("sshproxy %s (%s)\n", version, runtime.Version()) + return + } + // API Key is required if viper.GetString("apikey") == "" { fmt.Fprintln(os.Stderr, "Error: Resin API Key is required.") From 9f20a6948816e2154d4f527bdddc34545f88d109 Mon Sep 17 00:00:00 2001 From: "resin-io-versionbot[bot]" Date: Tue, 11 Jul 2017 14:02:11 +0000 Subject: [PATCH 2/2] v1.4.1 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39d3229..8bb388e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY! This project adheres to [Semantic Versioning](http://semver.org/). +## v1.4.1 - 2017-07-11 + +* Expose version information to build and add --version flag [Will Boyce] + ## v1.4.0 - 2017-07-10 * Add support for running shell with alternative credentials [Will Boyce]