From 9d33a06b4e49331942f19d8fc4e733216d8ec4d8 Mon Sep 17 00:00:00 2001 From: Serge Zaitsev Date: Thu, 3 Jun 2021 14:51:51 +0200 Subject: [PATCH] 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 Co-authored-by: Arve Knudsen --- pkg/cmd/grafana-server/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/grafana-server/main.go b/pkg/cmd/grafana-server/main.go index 22ce254773a..bdf0de65298 100644 --- a/pkg/cmd/grafana-server/main.go +++ b/pkg/cmd/grafana-server/main.go @@ -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) }