Change Version->version for consistency w/ influxdb

This commit is contained in:
Cameron Sparr 2016-05-02 17:22:28 -06:00
parent 677dd7ad53
commit 775daba8f5
2 changed files with 14 additions and 10 deletions

View File

@ -14,21 +14,21 @@ windows: prepare-windows build-windows
# Only run the build (no dependency grabbing) # Only run the build (no dependency grabbing)
build: build:
go install -ldflags "-X main.Version=$(VERSION)" ./... go install -ldflags "-X main.version=$(VERSION)" ./...
build-windows: build-windows:
go build -o telegraf.exe -ldflags \ go build -o telegraf.exe -ldflags \
"-X main.Version=$(VERSION)" \ "-X main.version=$(VERSION)" \
./cmd/telegraf/telegraf.go ./cmd/telegraf/telegraf.go
build-for-docker: build-for-docker:
CGO_ENABLED=0 GOOS=linux go build -installsuffix cgo -o telegraf -ldflags \ 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 ./cmd/telegraf/telegraf.go
# Build with race detector # Build with race detector
dev: prepare dev: prepare
go build -race -ldflags "-X main.Version=$(VERSION)" ./... go build -race -ldflags "-X main.version=$(VERSION)" ./...
# run package script # run package script
package: package:

View File

@ -46,9 +46,13 @@ var fOutputFiltersLegacy = flag.String("outputfilter", "",
var fConfigDirectoryLegacy = flag.String("configdirectory", "", var fConfigDirectoryLegacy = flag.String("configdirectory", "",
"directory containing additional *.conf files") "directory containing additional *.conf files")
// Telegraf version // Telegraf version, populated linker.
// -ldflags "-X main.Version=`git describe --always --tags`" // ie, -ldflags "-X main.version=`git describe --always --tags`"
var Version string var (
version string
commit string
branch string
)
const usage = `Telegraf, The plugin-driven server agent for collecting and reporting metrics. const usage = `Telegraf, The plugin-driven server agent for collecting and reporting metrics.
@ -132,7 +136,7 @@ func main() {
if len(args) > 0 { if len(args) > 0 {
switch args[0] { switch args[0] {
case "version": case "version":
v := fmt.Sprintf("Telegraf - Version %s", Version) v := fmt.Sprintf("Telegraf - version %s", version)
fmt.Println(v) fmt.Println(v)
return return
case "config": case "config":
@ -158,7 +162,7 @@ func main() {
} }
if *fVersion { if *fVersion {
v := fmt.Sprintf("Telegraf - Version %s", Version) v := fmt.Sprintf("Telegraf - version %s", version)
fmt.Println(v) fmt.Println(v)
return 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 outputs: %s", strings.Join(c.OutputNames(), " "))
log.Printf("Loaded inputs: %s", strings.Join(c.InputNames(), " ")) log.Printf("Loaded inputs: %s", strings.Join(c.InputNames(), " "))
log.Printf("Tags enabled: %s", c.ListTags()) log.Printf("Tags enabled: %s", c.ListTags())