Skip to content

Commit

Permalink
Auto-merge for PR #25 via VersionBot
Browse files Browse the repository at this point in the history
expose version information to build and add --version flag
  • Loading branch information
resin-io-versionbot[bot] authored Jul 11, 2017
2 parents 8e4be1c + 9f20a69 commit eac7c03
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions resin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions resin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"log"
"os"
"path"
"runtime"
"syscall"

"github.com/getsentry/raven-go"
Expand All @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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.")
Expand Down

0 comments on commit eac7c03

Please sign in to comment.