config: use /var/lib/dnswatcher as default data directory
All checks were successful
check / check (push) Successful in 46s
All checks were successful
check / check (push) Successful in 46s
Change the default DATA_DIR from the relative path './data' to the absolute path '/var/lib/dnswatcher', following the FHS convention for application state data. The default is derived from the application name passed to setupViper, so it will always match /var/lib/<appname>. Updated README environment variable table and .env example to reflect the new default. Tests updated accordingly.
This commit is contained in:
@@ -94,7 +94,7 @@ func setupViper(name string) {
|
||||
|
||||
viper.SetDefault("PORT", defaultPort)
|
||||
viper.SetDefault("DEBUG", false)
|
||||
viper.SetDefault("DATA_DIR", "./data")
|
||||
viper.SetDefault("DATA_DIR", "/var/lib/"+name)
|
||||
viper.SetDefault("TARGETS", "")
|
||||
viper.SetDefault("SLACK_WEBHOOK", "")
|
||||
viper.SetDefault("MATTERMOST_WEBHOOK", "")
|
||||
|
||||
@@ -44,7 +44,7 @@ func TestNew_DefaultValues(t *testing.T) {
|
||||
|
||||
assert.Equal(t, 8080, cfg.Port)
|
||||
assert.False(t, cfg.Debug)
|
||||
assert.Equal(t, "./data", cfg.DataDir)
|
||||
assert.Equal(t, "/var/lib/dnswatcher", cfg.DataDir)
|
||||
assert.Equal(t, time.Hour, cfg.DNSInterval)
|
||||
assert.Equal(t, 12*time.Hour, cfg.TLSInterval)
|
||||
assert.Equal(t, 7, cfg.TLSExpiryWarning)
|
||||
@@ -245,7 +245,7 @@ func TestStatePath(t *testing.T) {
|
||||
dataDir string
|
||||
want string
|
||||
}{
|
||||
{"default", "./data", "./data/state.json"},
|
||||
{"default", "/var/lib/dnswatcher", "/var/lib/dnswatcher/state.json"},
|
||||
{"absolute", "/var/lib/dw", "/var/lib/dw/state.json"},
|
||||
{"nested", "/opt/app/data", "/opt/app/data/state.json"},
|
||||
{"empty", "", "/state.json"},
|
||||
|
||||
Reference in New Issue
Block a user