Added -version flag to watchdog

This changes introduces a new flag -version to watchdog which will
display version and SHA of last git commit.

Version and SHA are injected at build time and passed as a
build-args for Dockerfile.

Fixes: #632

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
This commit is contained in:
Vivek Singh
2018-04-14 15:29:01 +05:30
committed by Alex Ellis
parent f936dcd757
commit c258637d6d
4 changed files with 57 additions and 7 deletions

View File

@ -6,6 +6,7 @@ package main
import (
"bytes"
"context"
"flag"
"fmt"
"io/ioutil"
"log"
@ -309,7 +310,12 @@ func makeRequestHandler(config *WatchdogConfig) func(http.ResponseWriter, *http.
}
}
var (
version = flag.Bool("version", false, "Print the version and Git SHA")
)
func main() {
flag.Parse()
acceptingConnections = false
osEnv := types.OsEnv{}
@ -321,6 +327,12 @@ func main() {
return
}
if *version == true {
fmt.Printf("Commit: %v\n", GitCommit)
fmt.Printf("Version: %v\n", BuildVersion())
return
}
readTimeout := config.readTimeout
writeTimeout := config.writeTimeout