forked from security/hakurei
hst/instance: define instance state
This is now part of the hst API. This change also improves identifier generation and serialisation. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -3,7 +3,6 @@ package state
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"hakurei.app/hst"
|
||||
)
|
||||
@@ -11,8 +10,6 @@ import (
|
||||
// ErrNoConfig is returned by [Cursor] when used with a nil [hst.Config].
|
||||
var ErrNoConfig = errors.New("state does not contain config")
|
||||
|
||||
type Entries map[ID]*State
|
||||
|
||||
type Store interface {
|
||||
// Do calls f exactly once and ensures store exclusivity until f returns.
|
||||
// Returns whether f is called and any errors during the locking process.
|
||||
@@ -29,21 +26,8 @@ type Store interface {
|
||||
|
||||
// Cursor provides access to the store of an identity.
|
||||
type Cursor interface {
|
||||
Save(state *State) error
|
||||
Destroy(id ID) error
|
||||
Load() (Entries, error)
|
||||
Save(state *hst.State) error
|
||||
Destroy(id hst.ID) error
|
||||
Load() (map[hst.ID]*hst.State, error)
|
||||
Len() (int, error)
|
||||
}
|
||||
|
||||
// State is the on-disk state of a container instance.
|
||||
type State struct {
|
||||
// Unique instance id, generated by internal/app.
|
||||
ID ID `json:"instance"`
|
||||
// Shim process pid. This runs as the target user.
|
||||
PID int `json:"pid"`
|
||||
// Configuration value used to start the container.
|
||||
Config *hst.Config `json:"config"`
|
||||
|
||||
// Exact point in time that the shim process was created.
|
||||
Time time.Time `json:"time"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user