Add verbose version flag to list dependencies as well as the version (#34741)

* add verbose version flag to list dependencies as well as the version

* Fix typo in the println message

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Serge Zaitsev 2021-06-03 14:51:51 +02:00 committed by GitHub
parent 32d9b04666
commit 9d33a06b4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@ import (
"os"
"os/signal"
"runtime"
"runtime/debug"
"runtime/trace"
"strconv"
"syscall"
@ -60,6 +61,7 @@ func main() {
packaging = flag.String("packaging", "unknown", "describes the way Grafana was installed")
v = flag.Bool("v", false, "prints current version and exits")
vv = flag.Bool("vv", false, "prints current version, all dependencies and exits")
profile = flag.Bool("profile", false, "Turn on pprof profiling")
profilePort = flag.Uint64("profile-port", 6060, "Define custom port for profiling")
tracing = flag.Bool("tracing", false, "Turn on tracing")
@ -68,8 +70,16 @@ func main() {
flag.Parse()
if *v {
if *v || *vv {
fmt.Printf("Version %s (commit: %s, branch: %s)\n", version, commit, buildBranch)
if *vv {
fmt.Println("Dependencies:")
if info, ok := debug.ReadBuildInfo(); ok {
for _, dep := range info.Deps {
fmt.Println(dep.Path, dep.Version)
}
}
}
os.Exit(0)
}