diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2016-04-08 15:56:47 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2016-04-08 15:56:47 +0300 |
commit | cdc785b6b65e8cb811c9ea67616381ad95285745 (patch) | |
tree | 85bffe7b07eac8dea730b8e46eb97ef7efe12b30 | |
parent | b0ac2a7d3f7c48702120de4910cde34b7aee7bdd (diff) | |
parent | c76f6213d42efb310c4af4db0ec74de5cbdbd95c (diff) |
Merge branch 'add_show_version' into 'master'
v0.2.3
Add version flag.
It is handy to have only the version with revision printed out.
Also useful for gitlab-org/omnibus-gitlab#1213
See merge request !5
-rw-r--r-- | 404.go | 2 | ||||
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | domain_test.go | 6 | ||||
-rw-r--r-- | main.go | 14 |
4 files changed, 18 insertions, 7 deletions
@@ -1,8 +1,8 @@ package main import ( - "net/http" "fmt" + "net/http" ) const predefined404 = ` @@ -27,8 +27,7 @@ fmt: go fmt ./... | awk '{ print "Please run go fmt"; exit 1 }' vet: - go get golang.org/x/tools/cmd/vet - go vet + go tool vet *.go lint: go get github.com/golang/lint/golint diff --git a/domain_test.go b/domain_test.go index 56e032a4..f10009c3 100644 --- a/domain_test.go +++ b/domain_test.go @@ -2,12 +2,12 @@ package main import ( "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "mime" "net/http" + "net/http/httptest" "net/url" "testing" - "net/http/httptest" - "github.com/stretchr/testify/require" - "mime" ) func TestGroupServeHTTP(t *testing.T) { @@ -15,6 +15,7 @@ var VERSION = "dev" var REVISION = "HEAD" func appMain() { + var showVersion = flag.Bool("version", false, "Show version") var listenHTTP = flag.String("listen-http", "", "The address to listen for HTTP requests") var listenHTTPS = flag.String("listen-https", "", "The address to listen for HTTPS requests") var listenProxy = flag.String("listen-proxy", "", "The address to listen for proxy requests") @@ -27,9 +28,12 @@ func appMain() { var daemonUID = flag.Uint("daemon-uid", 0, "Drop privileges to this user") var daemonGID = flag.Uint("daemon-gid", 0, "Drop privileges to this group") + flag.Parse() + + printVersion(*showVersion, VERSION) + log.Printf("GitLab Pages Daemon %s (%s)", VERSION, REVISION) log.Printf("URL: https://gitlab.com/gitlab-org/gitlab-pages\n") - flag.Parse() err := os.Chdir(*pagesRoot) if err != nil { @@ -75,6 +79,14 @@ func appMain() { runApp(config) } +func printVersion(showVersion bool, version string) { + if showVersion { + log.SetFlags(0) + log.Printf(version) + os.Exit(0) + } +} + func main() { log.SetOutput(os.Stderr) |