mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 08:50:42 +02:00
config: detect underlying file changes (#1775)
* wip * cleanup * add test * use uuid for temp dir, derive root CA path from filemgr for tests * fix comment * fix double close * use latest notify
This commit is contained in:
parent
c99994bed8
commit
10912add67
16 changed files with 500 additions and 99 deletions
35
internal/controlplane/filemgr/config.go
Normal file
35
internal/controlplane/filemgr/config.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package filemgr
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
cacheDir string
|
||||
}
|
||||
|
||||
// An Option updates the config.
|
||||
type Option = func(*config)
|
||||
|
||||
// WithCacheDir returns an Option that sets the cache dir.
|
||||
func WithCacheDir(cacheDir string) Option {
|
||||
return func(cfg *config) {
|
||||
cfg.cacheDir = cacheDir
|
||||
}
|
||||
}
|
||||
|
||||
func newConfig(options ...Option) *config {
|
||||
cfg := new(config)
|
||||
cacheDir, err := os.UserCacheDir()
|
||||
if err != nil {
|
||||
cacheDir = filepath.Join(os.TempDir(), uuid.New().String())
|
||||
}
|
||||
WithCacheDir(filepath.Join(cacheDir, "pomerium", "envoy", "files"))(cfg)
|
||||
for _, o := range options {
|
||||
o(cfg)
|
||||
}
|
||||
return cfg
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue