Skip to content

Commit

Permalink
Add -version command line flag and populate version information
Browse files Browse the repository at this point in the history
  • Loading branch information
hansmi committed Oct 10, 2021
1 parent 9c5bfe2 commit fdc23ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ builds:
- linux
flags:
- -trimpath
ldflags: |
-s -w
-X github.com/prometheus/common/version.Version={{.Version}}
-X github.com/prometheus/common/version.Revision={{.FullCommit}}
-X github.com/prometheus/common/version.Branch={{.Branch}}
-X github.com/prometheus/common/version.BuildDate={{.Date}}
nfpms:
- description: Prometheus exporter for LVM metrics
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"flag"
"fmt"
"log"
"net/http"

Expand All @@ -17,6 +18,7 @@ import (
const metricPrefix = "lvm_"

func main() {
showVersion := flag.Bool("version", false, "Output version information and exit")
listenAddress := flag.String("web.listen-address", ":9845", "The address to listen on for HTTP requests")
configFile := flag.String("web.config", "", "Path to config yaml file that can enable TLS or authentication")
metricsPath := flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics")
Expand All @@ -25,6 +27,11 @@ func main() {

flag.Parse()

if *showVersion {
fmt.Println(version.Print("prometheus-lvm-exporter"))
return
}

cmdParts, err := shellquote.Split(*cmd)
if err != nil {
log.Fatalf("Parsing command failed: %v", err)
Expand Down

0 comments on commit fdc23ed

Please sign in to comment.