Skip to content

Commit 17306cb

Browse files
committed
coordinator: separate store getter with build tag
1 parent 4411687 commit 17306cb

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

coordinator/history/history.go

+4-9
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,11 @@ import (
1313
"fmt"
1414
"hash"
1515
"os"
16-
17-
"github.com/spf13/afero"
1816
)
1917

2018
const (
2119
// HashSize is the number of octets in hashes used by this package.
2220
HashSize = sha256.Size
23-
24-
histPath = "/mnt/state/history"
2521
)
2622

2723
// History is the history of the Coordinator.
@@ -30,13 +26,12 @@ type History struct {
3026
hashFun func() hash.Hash
3127
}
3228

33-
// New creates a new History backed by the default filesystem store.
29+
// New creates a new History backed by the configured store.
3430
func New() (*History, error) {
35-
osFS := afero.NewOsFs()
36-
if err := osFS.MkdirAll(histPath, 0o755); err != nil {
37-
return nil, fmt.Errorf("creating history directory: %w", err)
31+
store, err := NewStore()
32+
if err != nil {
33+
return nil, fmt.Errorf("creating history store: %w", err)
3834
}
39-
store := NewAferoStore(&afero.Afero{Fs: afero.NewBasePathFs(osFS, histPath)})
4035
return NewWithStore(store), nil
4136
}
4237

coordinator/history/store.go

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2025 Edgeless Systems GmbH
2+
// SPDX-License-Identifier: AGPL-3.0-only
3+
4+
//go:build !enterprise
5+
6+
package history
7+
8+
import (
9+
"fmt"
10+
11+
"github.com/spf13/afero"
12+
)
13+
14+
const (
15+
histPath = "/mnt/state/history"
16+
)
17+
18+
// NewStore creates a new AferoStore backed by the default filesystem store.
19+
func NewStore() (*AferoStore, error) {
20+
osFS := afero.NewOsFs()
21+
if err := osFS.MkdirAll(histPath, 0o755); err != nil {
22+
return nil, fmt.Errorf("creating history directory: %w", err)
23+
}
24+
return NewAferoStore(&afero.Afero{Fs: afero.NewBasePathFs(osFS, histPath)}), nil
25+
}

0 commit comments

Comments
 (0)