Skip to content

Commit

Permalink
fix: Give Overlay interface precendence in storage switch on server…
Browse files Browse the repository at this point in the history
… startup (#1573)

Signed-off-by: Sam Lock <sam@swlock.co.uk>
  • Loading branch information
Sambigeara committed May 10, 2023
1 parent 60ff224 commit 7870db5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions internal/server/server.go
Expand Up @@ -143,6 +143,15 @@ func Start(ctx context.Context, zpagesEnabled bool) error {

var policyLoader engine.PolicyLoader
switch st := store.(type) {
// Overlay needs to take precedence over BinaryStore in this type switch,
// as our overlay store implements BinaryStore also
case overlay.Overlay:
// create wrapped policy loader
pl, err := st.GetOverlayPolicyLoader(ctx, schemaMgr)
if err != nil {
return fmt.Errorf("failed to create overlay policy loader: %w", err)
}
policyLoader = pl
case storage.BinaryStore:
policyLoader = st
case storage.SourceStore:
Expand All @@ -152,13 +161,6 @@ func Start(ctx context.Context, zpagesEnabled bool) error {
return fmt.Errorf("failed to create compile manager: %w", err)
}
policyLoader = compileMgr
case overlay.Overlay:
// create wrapped policy loader
pl, err := st.GetOverlayPolicyLoader(ctx, schemaMgr)
if err != nil {
return fmt.Errorf("failed to create overlay policy loader: %w", err)
}
policyLoader = pl
default:
return ErrInvalidStore
}
Expand Down

0 comments on commit 7870db5

Please sign in to comment.