Skip to content

Commit 005c7a9

Browse files
committed
Switch to kingpin for flag parsing
Newer versions of github.com/prometheus/exporter-toolkit require a more complex type as the configuration given to `web.ListenAndServe`. The upstream package only provides a kingpin implementation of the flag code.
1 parent dd763e0 commit 005c7a9

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ require (
1414
)
1515

1616
require (
17+
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
18+
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
1719
github.com/beorn7/perks v1.0.1 // indirect
1820
github.com/cespare/xxhash/v2 v2.1.2 // indirect
1921
github.com/davecgh/go-spew v1.1.1 // indirect
@@ -38,6 +40,7 @@ require (
3840
golang.org/x/text v0.3.7 // indirect
3941
google.golang.org/appengine v1.6.7 // indirect
4042
google.golang.org/protobuf v1.28.1 // indirect
43+
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
4144
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
4245
gopkg.in/yaml.v2 v2.4.0 // indirect
4346
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect

go.sum

+3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/
6767
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
6868
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
6969
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
70+
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
7071
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
7172
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
7273
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
74+
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
7375
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
7476
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
7577
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
@@ -958,6 +960,7 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
958960
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
959961
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
960962
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
963+
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
961964
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
962965
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
963966
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

main.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package main
22

33
import (
4-
"flag"
54
"fmt"
65
"log"
76
"net/http"
@@ -11,21 +10,22 @@ import (
1110
"github.com/prometheus/client_golang/prometheus/promhttp"
1211
"github.com/prometheus/common/version"
1312
"github.com/prometheus/exporter-toolkit/web"
13+
"gopkg.in/alecthomas/kingpin.v2"
1414

1515
kitlog "github.com/go-kit/kit/log"
1616
)
1717

1818
const metricPrefix = "lvm_"
1919

2020
func main() {
21-
showVersion := flag.Bool("version", false, "Output version information and exit")
22-
listenAddress := flag.String("web.listen-address", ":9845", "The address to listen on for HTTP requests")
23-
configFile := flag.String("web.config", "", "Path to config yaml file that can enable TLS or authentication")
24-
metricsPath := flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics")
25-
disableExporterMetrics := flag.Bool("web.disable-exporter-metrics", false, "Exclude metrics about the exporter itself")
26-
cmd := flag.String("command", "/usr/sbin/lvm", "Path to the LVM binary")
21+
showVersion := kingpin.Flag("version", "Output version information and exit").Bool()
22+
listenAddress := kingpin.Flag("web.listen-address", "The address to listen on for HTTP requests").Default(":9845").String()
23+
configFile := kingpin.Flag("web.config", "Path to config yaml file that can enable TLS or authentication").String()
24+
metricsPath := kingpin.Flag("web.telemetry-path", "Path under which to expose metrics").Default("/metrics").String()
25+
disableExporterMetrics := kingpin.Flag("web.disable-exporter-metrics", "Exclude metrics about the exporter itself").Bool()
26+
cmd := kingpin.Flag("command", "Path to the LVM binary").Default("/usr/sbin/lvm").String()
2727

28-
flag.Parse()
28+
kingpin.Parse()
2929

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

0 commit comments

Comments
 (0)