Skip to content

Commit

Permalink
Add version flag to promxy
Browse files Browse the repository at this point in the history
Fixes #40
  • Loading branch information
jacksontj committed Sep 27, 2018
1 parent 9d199ab commit 008b3a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

VERSION=`git describe --tags`
VERSION=`git describe --tags --dirty`

package=$1
destination=$2
Expand All @@ -23,7 +23,7 @@ do
output_name+='.exe'
fi

env GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=0 go build -o $destination/$output_name $package
env GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=0 go build -x -ldflags="-X main.Version=$VERSION" -o $destination/$output_name $package
if [ $? -ne 0 ]; then
echo 'An error has occurred! Aborting the script execution...'
exit 1
Expand Down
10 changes: 9 additions & 1 deletion cmd/promxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ var (
Name: "process_reload_time_seconds",
Help: "Last reload (SIGHUP) time of the process since unix epoch in seconds.",
})
Version = "<version>"
)

type CLIOpts struct {
Version bool `long:"version" short:"v" description:"print out version and exit"`

BindAddr string `long:"bind-addr" description:"address for promxy to listen on" default:":8082"`
ConfigFile string `long:"config" description:"path to the config file" required:"true"`
ConfigFile string `long:"config" description:"path to the config file" default:"config.yaml"`
LogLevel string `long:"log-level" description:"Log level" default:"info"`

ExternalURL string `long:"web.external-url" description:"The URL under which Prometheus is externally reachable (for example, if Prometheus is served via a reverse proxy). Used for generating relative and absolute links back to Prometheus itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Prometheus. If omitted, relevant URL components will be derived automatically."`
Expand Down Expand Up @@ -118,6 +121,11 @@ func main() {
logrus.Fatalf("Error parsing flags: %v", err)
}

if opts.Version {
fmt.Println("Version", Version)
os.Exit(0)
}

// Use log level
level := logrus.InfoLevel
switch strings.ToLower(opts.LogLevel) {
Expand Down

0 comments on commit 008b3a1

Please sign in to comment.