Skip to content

Commit dfc6442

Browse files
committed
Refactor PR prometheus-community#157 to fit the new repository format.
This didn't actually need all that much change, it fits perfectly.
1 parent 2ab8f10 commit dfc6442

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

main.go renamed to cmd/postgres_exporter/main.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,28 @@ import (
55
"net/http"
66
"runtime"
77

8+
"gopkg.in/alecthomas/kingpin.v2"
9+
810
_ "github.com/lib/pq"
911
"github.com/prometheus/client_golang/prometheus"
1012
"github.com/prometheus/client_golang/prometheus/promhttp"
1113
"github.com/prometheus/common/log"
14+
1215
"github.com/wrouesnel/postgres_exporter/collector"
13-
"gopkg.in/alecthomas/kingpin.v2"
1416
)
1517

1618
// Version is set during build to the git describe version
1719
// (semantic version)-(commitish) form.
1820
var Version = "0.0.1"
1921

2022
var (
21-
listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9187").OverrideDefaultFromEnvar("PG_EXPORTER_WEB_LISTEN_ADDRESS").String()
22-
metricPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").OverrideDefaultFromEnvar("PG_EXPORTER_WEB_TELEMETRY_PATH").String()
23-
queriesPath = kingpin.Flag("extend.query-path", "Path to custom queries to run.").Default("").OverrideDefaultFromEnvar("PG_EXPORTER_EXTEND_QUERY_PATH").String()
24-
onlyDumpMaps = kingpin.Flag("dumpmaps", "Do not run, simply dump the maps.").Bool()
23+
listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").
24+
Default(":9187").Envar("PG_EXPORTER_WEB_LISTEN_ADDRESS").String()
25+
metricPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").
26+
Default("/metrics").Envar("PG_EXPORTER_WEB_TELEMETRY_PATH").String()
27+
queriesPath = kingpin.Flag("extend.query-path", "Path to custom queries to run.").
28+
Default("").Envar("PG_EXPORTER_EXTEND_QUERY_PATH").String()
29+
onlyDumpMaps = kingpin.Flag("dumpmaps", "Do not run, simply dump the maps.").Bool()
2530
)
2631

2732
func main() {

collector/postgres_exporter_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
package collector
44

55
import (
6-
. "gopkg.in/check.v1"
76
"testing"
87

9-
"github.com/blang/semver"
8+
. "gopkg.in/check.v1"
9+
1010
"os"
11+
12+
"github.com/blang/semver"
1113
)
1214

1315
// Hook up gocheck into the "go test" runner.
@@ -89,11 +91,11 @@ func (s *FunctionalSuite) TestSemanticVersionColumnDiscard(c *C) {
8991
// test read username and password from file
9092
func (s *FunctionalSuite) TestEnvironmentSettingWithSecretsFiles(c *C) {
9193

92-
err := os.Setenv("DATA_SOURCE_USER_FILE", "../tests/username_file")
94+
err := os.Setenv("DATA_SOURCE_USER_FILE", "../cmd/postgres_exporter/tests/username_file")
9395
c.Assert(err, IsNil)
9496
defer UnsetEnvironment(c, "DATA_SOURCE_USER_FILE")
9597

96-
err = os.Setenv("DATA_SOURCE_PASS_FILE", "../tests/userpass_file")
98+
err = os.Setenv("DATA_SOURCE_PASS_FILE", "../cmd/postgres_exporter/tests/userpass_file")
9799
c.Assert(err, IsNil)
98100
defer UnsetEnvironment(c, "DATA_SOURCE_PASS_FILE")
99101

0 commit comments

Comments
 (0)