Skip to content

Commit

Permalink
refactor: move path logic to loadFromEnv
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-zarrad committed Aug 20, 2021
1 parent 7ddddcd commit e6fc152
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@ func loadEnvFromFile(envFile string) error {

// Update the storage paths to ensure they have the proper
// value after loading a specified env file.
caddy.UpdateStoragePaths()
caddy.ConfigAutosavePath = filepath.Join(caddy.AppConfigDir(), "autosave.json")
caddy.DefaultStorage = &certmagic.FileStorage{Path: caddy.AppDataDir()}

return nil
}
Expand Down
10 changes: 0 additions & 10 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,6 @@ func AppDataDir() string {
return "./caddy"
}

// UpdateStoragePaths sets the config auto save and default storage path
// again. This ensures that env files that overwrite the paths
// have the expected effect.
// If used, this function must be called before ConfigAutosavePath and
// DefaultStorage are being used.
func UpdateStoragePaths() {
ConfigAutosavePath = filepath.Join(AppConfigDir(), "autosave.json")
DefaultStorage = &certmagic.FileStorage{Path: AppDataDir()}
}

// ConfigAutosavePath is the default path to which the last config will be persisted.
var ConfigAutosavePath = filepath.Join(AppConfigDir(), "autosave.json")

Expand Down

0 comments on commit e6fc152

Please sign in to comment.