fileutil: add directory helpers, atomic file writing (#5477)

This commit is contained in:
Caleb Doxsey 2025-02-19 07:56:38 -07:00 committed by GitHub
parent b9fd926618
commit fbd1f34110
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 133 additions and 27 deletions

View file

@ -6,6 +6,8 @@ import (
"path/filepath"
"github.com/spf13/viper"
"github.com/pomerium/pomerium/internal/fileutil"
)
const (
@ -63,11 +65,7 @@ func getBootstrapConfigFileName() (string, error) {
if filename := os.Getenv(BootstrapConfigFileName); filename != "" {
return filename, nil
}
cacheDir, err := os.UserCacheDir()
if err != nil {
return "", err
}
dir := filepath.Join(cacheDir, "pomerium")
dir := fileutil.CacheDir()
if err := os.MkdirAll(dir, 0o700); err != nil {
return "", fmt.Errorf("error creating cache directory: %w", err)
}