Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion driver/config/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ func TestProviderCookieSameSiteMode(t *testing.T) {

func TestProviderValidates(t *testing.T) {
ctx := t.Context()
c := newProvider(t, configx.WithConfigFiles("../../internal/.hydra.yaml"))
c := newProvider(t,
configx.WithConfigFiles("../../internal/.hydra.yaml"),
configx.DisableFileWatching(),
)

// log
assert.Equal(t, "debug", c.Source(ctx).String(KeyLogLevel))
Expand Down
7 changes: 7 additions & 0 deletions oryx/configx/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ func DisableEnvLoading() OptionModifier {
}
}

// DisableFileWatching loads configured files once without watching them for changes.
func DisableFileWatching() OptionModifier {
return func(p *Provider) {
p.disableFileWatching = true
}
}

func WithValue(key string, value interface{}) OptionModifier {
return func(p *Provider) {
p.forcedValues = append(p.forcedValues, tuple{Key: key, Value: value})
Expand Down
13 changes: 8 additions & 5 deletions oryx/configx/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ type Provider struct {
baseValues []tuple
files []string

skipValidation bool
disableEnvLoading bool
skipValidation bool
disableEnvLoading bool
disableFileWatching bool

logger *logrusx.Logger

Expand Down Expand Up @@ -142,7 +143,7 @@ func (p *Provider) createProviders(ctx context.Context) (providers []koanf.Provi
c := make(watcherx.EventChannel)

defer func() {
if err == nil && len(paths) > 0 {
if err == nil && len(paths) > 0 && !p.disableFileWatching {
go p.watchForFileChanges(ctx, c)
}
}()
Expand All @@ -152,8 +153,10 @@ func (p *Provider) createProviders(ctx context.Context) (providers []koanf.Provi
return nil, err
}

if _, err := fp.WatchChannel(ctx, c); err != nil {
return nil, err
if !p.disableFileWatching {
if _, err := fp.WatchChannel(ctx, c); err != nil {
return nil, err
}
}

providers = append(providers, fp)
Expand Down
Loading