Skip to content

Commit 8275f91

Browse files
authored
simplify config search (#12)
* dep cleanup * simplify config locations
1 parent 5abcb56 commit 8275f91

4 files changed

Lines changed: 3 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ Template:
1212
### Fixed
1313
```
1414

15-
## v0.4.0 - 18 December 2019
15+
## v0.4.1 - 18 December 2019
1616
### Changed
1717
- build with golang 1.13.5
1818
- use azure event hubs sdk v3
1919
- bump project dependencies
2020
### Removed
2121
- dead code getCounterValue, part of throughput calc
22+
- search for config in home directory
2223
### Fixed
2324
- linting simplify sample.Metric[]
2425

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ The adapter will search for a TOML formatted file with the name `prometheus-even
108108
1. Directory where executable is located
109109
2. On unix-like systems: */etc/prometheus-eventhubs-adapter/prometheus-eventhubs-adapter.toml*
110110
3. Current working directory
111-
4. OS-specific home directory
112111

113112
Example TOML file: [`prometheus-eventhubs-adapter.toml`](./prometheus-eventhubs-adapter.toml)
114113

config.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"runtime"
2424
"time"
2525

26-
homedir "github.com/mitchellh/go-homedir"
2726
"github.com/spf13/pflag"
2827
"github.com/spf13/viper"
2928

@@ -125,7 +124,7 @@ func initConfig() {
125124

126125
// Config file search: Unix-like system configuration directory
127126
if runtime.GOOS != "windows" {
128-
viper.AddConfigPath("/etc/" + AppName + "/")
127+
viper.AddConfigPath("/etc/" + AppName)
129128
}
130129

131130
// Config file search: current working directory
@@ -135,13 +134,6 @@ func initConfig() {
135134
viper.AddConfigPath(workingpath)
136135
}
137136

138-
// Config file search: OS-specific home directory
139-
if homepath, err := homedir.Dir(); err != nil {
140-
log.Debug().Err(err).Msg("failed to detect home directory")
141-
} else {
142-
viper.AddConfigPath(homepath)
143-
}
144-
145137
// Read config file
146138
if err := viper.ReadInConfig(); err != nil {
147139
if _, ok := err.(viper.ConfigFileNotFoundError); ok {

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ require (
1818
github.com/leodido/go-urn v1.2.0 // indirect
1919
github.com/linkedin/goavro/v2 v2.9.7
2020
github.com/mattn/go-isatty v0.0.11 // indirect
21-
github.com/mitchellh/go-homedir v1.1.0
2221
github.com/pelletier/go-toml v1.6.0 // indirect
2322
github.com/prometheus/client_golang v1.2.1
2423
github.com/prometheus/client_model v0.0.0-20191202183732-d1d2010b5bee // indirect

0 commit comments

Comments
 (0)