mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-30 10:56:28 +02:00
zero: use os.UserCacheDir for boostrap config path (#4744)
This commit is contained in:
parent
6810091d38
commit
14b13bb791
3 changed files with 24 additions and 1 deletions
|
@ -39,6 +39,9 @@ func (svc *Source) Run(
|
||||||
api *sdk.API,
|
api *sdk.API,
|
||||||
fileCachePath string,
|
fileCachePath string,
|
||||||
) error {
|
) error {
|
||||||
|
log.Ctx(ctx).Info().Str("bootstrap-config-path", fileCachePath).
|
||||||
|
Msg("initializing bootstrap config source")
|
||||||
|
|
||||||
svc.api = api
|
svc.api = api
|
||||||
svc.fileCachePath = fileCachePath
|
svc.fileCachePath = fileCachePath
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"path/filepath"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/mattn/go-isatty"
|
"github.com/mattn/go-isatty"
|
||||||
|
@ -28,11 +29,17 @@ func Run(ctx context.Context, configFile string) error {
|
||||||
return errors.New("no token provided")
|
return errors.New("no token provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bootstrapConfigFileName, err := getBootstrapConfigFileName()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error getting bootstrap config path: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
return controller.Run(
|
return controller.Run(
|
||||||
withInterrupt(ctx),
|
withInterrupt(ctx),
|
||||||
controller.WithAPIToken(token),
|
controller.WithAPIToken(token),
|
||||||
controller.WithClusterAPIEndpoint(getClusterAPIEndpoint()),
|
controller.WithClusterAPIEndpoint(getClusterAPIEndpoint()),
|
||||||
controller.WithConnectAPIEndpoint(getConnectAPIEndpoint()),
|
controller.WithConnectAPIEndpoint(getConnectAPIEndpoint()),
|
||||||
|
controller.WithBootstrapConfigFileName(bootstrapConfigFileName),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,3 +88,17 @@ func setupLogger() error {
|
||||||
zerolog.DefaultContextLogger = &log.Logger
|
zerolog.DefaultContextLogger = &log.Logger
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getBootstrapConfigFileName() (string, error) {
|
||||||
|
cacheDir, err := os.UserCacheDir()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
dir := filepath.Join(cacheDir, "pomerium")
|
||||||
|
if err := os.MkdirAll(dir, 0644); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return filepath.Join(dir, "bootstrap.dat"), nil
|
||||||
|
}
|
||||||
|
|
|
@ -72,7 +72,6 @@ func newControllerConfig(opts ...Option) *controllerConfig {
|
||||||
for _, opt := range []Option{
|
for _, opt := range []Option{
|
||||||
WithClusterAPIEndpoint("https://console.pomerium.com/cluster/v1"),
|
WithClusterAPIEndpoint("https://console.pomerium.com/cluster/v1"),
|
||||||
WithConnectAPIEndpoint("https://connect.pomerium.com"),
|
WithConnectAPIEndpoint("https://connect.pomerium.com"),
|
||||||
WithBootstrapConfigFileName("/var/cache/pomerium-bootstrap.dat"),
|
|
||||||
WithDatabrokerLeaseDuration(time.Second * 30),
|
WithDatabrokerLeaseDuration(time.Second * 30),
|
||||||
WithDatabrokerRequestTimeout(time.Second * 30),
|
WithDatabrokerRequestTimeout(time.Second * 30),
|
||||||
} {
|
} {
|
||||||
|
|
Loading…
Add table
Reference in a new issue