From 82168313872c241c558fef858fa2893b35270439 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Mon, 2 May 2016 17:22:28 -0600 Subject: [PATCH] Change Version->version for consistency w/ influxdb --- Makefile | 8 ++++---- cmd/telegraf/telegraf.go | 16 ++++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index c87f78b55..c2bcc121d 100644 --- a/Makefile +++ b/Makefile @@ -14,21 +14,21 @@ windows: prepare-windows build-windows # Only run the build (no dependency grabbing) build: - go install -ldflags "-X main.Version=$(VERSION)" ./... + go install -ldflags "-X main.version=$(VERSION)" ./... build-windows: go build -o telegraf.exe -ldflags \ - "-X main.Version=$(VERSION)" \ + "-X main.version=$(VERSION)" \ ./cmd/telegraf/telegraf.go build-for-docker: CGO_ENABLED=0 GOOS=linux go build -installsuffix cgo -o telegraf -ldflags \ - "-s -X main.Version=$(VERSION)" \ + "-s -X main.version=$(VERSION)" \ ./cmd/telegraf/telegraf.go # Build with race detector dev: prepare - go build -race -ldflags "-X main.Version=$(VERSION)" ./... + go build -race -ldflags "-X main.version=$(VERSION)" ./... # run package script package: diff --git a/cmd/telegraf/telegraf.go b/cmd/telegraf/telegraf.go index ad0174788..6681ad073 100644 --- a/cmd/telegraf/telegraf.go +++ b/cmd/telegraf/telegraf.go @@ -46,9 +46,13 @@ var fOutputFiltersLegacy = flag.String("outputfilter", "", var fConfigDirectoryLegacy = flag.String("configdirectory", "", "directory containing additional *.conf files") -// Telegraf version -// -ldflags "-X main.Version=`git describe --always --tags`" -var Version string +// Telegraf version, populated linker. +// ie, -ldflags "-X main.version=`git describe --always --tags`" +var ( + version string + commit string + branch string +) const usage = `Telegraf, The plugin-driven server agent for collecting and reporting metrics. @@ -132,7 +136,7 @@ func main() { if len(args) > 0 { switch args[0] { case "version": - v := fmt.Sprintf("Telegraf - Version %s", Version) + v := fmt.Sprintf("Telegraf - version %s", version) fmt.Println(v) return case "config": @@ -158,7 +162,7 @@ func main() { } if *fVersion { - v := fmt.Sprintf("Telegraf - Version %s", Version) + v := fmt.Sprintf("Telegraf - version %s", version) fmt.Println(v) return } @@ -251,7 +255,7 @@ func main() { } }() - log.Printf("Starting Telegraf (version %s)\n", Version) + log.Printf("Starting Telegraf (version %s)\n", version) log.Printf("Loaded outputs: %s", strings.Join(c.OutputNames(), " ")) log.Printf("Loaded inputs: %s", strings.Join(c.InputNames(), " ")) log.Printf("Tags enabled: %s", c.ListTags())