internal/app: do not encode config early
All checks were successful
Test / Create distribution (push) Successful in 36s
Test / Sandbox (push) Successful in 2m11s
Test / Hpkg (push) Successful in 4m10s
Test / Sandbox (race detector) (push) Successful in 4m40s
Test / Hakurei (race detector) (push) Successful in 5m21s
Test / Hakurei (push) Successful in 2m18s
Test / Flake checks (push) Successful in 1m32s

Finalise no longer clobbers hst.Config.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-10-09 04:38:54 +09:00
parent a40d182706
commit df9b77b077
5 changed files with 79 additions and 189 deletions

View File

@@ -3,12 +3,12 @@ package state
import (
"errors"
"io"
"time"
"hakurei.app/hst"
)
// 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
@@ -27,23 +27,23 @@ type Store interface {
Close() error
}
// Cursor provides access to the store
// Cursor provides access to the store of an identity.
type Cursor interface {
Save(state *State, configWriter io.WriterTo) error
Save(state *State) error
Destroy(id ID) error
Load() (Entries, error)
Len() (int, error)
}
// State is an instance state
// State is the on-disk state of a container instance.
type State struct {
// hakurei instance id
// Unique instance id, generated by internal/app.
ID ID `json:"instance"`
// child process PID value
// Shim process pid. This runs as the target user.
PID int `json:"pid"`
// sealed app configuration
// Configuration value used to start the container.
Config *hst.Config `json:"config"`
// process start time
// Exact point in time that the shim process was created.
Time time.Time `json:"time"`
}