aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/state
diff options
context:
space:
mode:
Diffstat (limited to 'internal/state')
-rw-r--r--internal/state/multi.go9
-rw-r--r--internal/state/state.go7
-rw-r--r--internal/state/state_test.go3
3 files changed, 11 insertions, 8 deletions
diff --git a/internal/state/multi.go b/internal/state/multi.go
index 58b223c1..f4436112 100644
--- a/internal/state/multi.go
+++ b/internal/state/multi.go
@@ -14,6 +14,7 @@ import (
"syscall"
"git.gensokyo.uk/security/fortify/fst"
+ "git.gensokyo.uk/security/fortify/internal/app"
"git.gensokyo.uk/security/fortify/internal/fmsg"
)
@@ -129,7 +130,7 @@ type multiBackend struct {
lock sync.RWMutex
}
-func (b *multiBackend) filename(id *fst.ID) string {
+func (b *multiBackend) filename(id *app.ID) string {
return path.Join(b.path, id.String())
}
@@ -189,8 +190,8 @@ func (b *multiBackend) load(decode bool) (Entries, error) {
return nil, fmt.Errorf("unexpected directory %q in store", e.Name())
}
- id := new(fst.ID)
- if err := fst.ParseAppID(id, e.Name()); err != nil {
+ id := new(app.ID)
+ if err := app.ParseAppID(id, e.Name()); err != nil {
return nil, err
}
@@ -335,7 +336,7 @@ func (b *multiBackend) encodeState(w io.WriteSeeker, state *State, configWriter
return err
}
-func (b *multiBackend) Destroy(id fst.ID) error {
+func (b *multiBackend) Destroy(id app.ID) error {
b.lock.Lock()
defer b.lock.Unlock()
diff --git a/internal/state/state.go b/internal/state/state.go
index 6e76d517..609b4e92 100644
--- a/internal/state/state.go
+++ b/internal/state/state.go
@@ -6,11 +6,12 @@ import (
"time"
"git.gensokyo.uk/security/fortify/fst"
+ "git.gensokyo.uk/security/fortify/internal/app"
)
var ErrNoConfig = errors.New("state does not contain config")
-type Entries map[fst.ID]*State
+type Entries map[app.ID]*State
type Store interface {
// Do calls f exactly once and ensures store exclusivity until f returns.
@@ -29,7 +30,7 @@ type Store interface {
// Cursor provides access to the store
type Cursor interface {
Save(state *State, configWriter io.WriterTo) error
- Destroy(id fst.ID) error
+ Destroy(id app.ID) error
Load() (Entries, error)
Len() (int, error)
}
@@ -37,7 +38,7 @@ type Cursor interface {
// State is a fortify process's state
type State struct {
// fortify instance id
- ID fst.ID `json:"instance"`
+ ID app.ID `json:"instance"`
// child process PID value
PID int `json:"pid"`
// sealed app configuration
diff --git a/internal/state/state_test.go b/internal/state/state_test.go
index 22fd3cd6..fe7a6cc6 100644
--- a/internal/state/state_test.go
+++ b/internal/state/state_test.go
@@ -11,6 +11,7 @@ import (
"time"
"git.gensokyo.uk/security/fortify/fst"
+ "git.gensokyo.uk/security/fortify/internal/app"
"git.gensokyo.uk/security/fortify/internal/state"
)
@@ -133,7 +134,7 @@ func testStore(t *testing.T, s state.Store) {
}
func makeState(t *testing.T, s *state.State, ct io.Writer) {
- if err := fst.NewAppID(&s.ID); err != nil {
+ if err := app.NewAppID(&s.ID); err != nil {
t.Fatalf("cannot create dummy state: %v", err)
}
if err := gob.NewEncoder(ct).Encode(fst.Template()); err != nil {