diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-05 02:42:41 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-05 02:52:50 +0900 |
| commit | eb5ee4fece0327b1183ae823d68e4cf4e3e1ced0 (patch) | |
| tree | 64e1c411e9d0a29637982519b9bd3a5ff6642d1a /internal/app/dispatcher.go | |
| parent | 9462af08f38fefe40d985383d8825258a6d1f0a8 (diff) | |
internal/app: modularise outcome finalise
This is the initial effort of splitting up host and container side of finalisation for params to shim. The new layout also enables much finer grained unit testing of each step, as well as partition access to per-app state for each step.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/dispatcher.go')
| -rw-r--r-- | internal/app/dispatcher.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/app/dispatcher.go b/internal/app/dispatcher.go index 8ab60734..075b2add 100644 --- a/internal/app/dispatcher.go +++ b/internal/app/dispatcher.go @@ -1,6 +1,8 @@ package app import ( + "io" + "io/fs" "log" "os" "os/exec" @@ -11,6 +13,13 @@ import ( "hakurei.app/internal" ) +// osFile represents [os.File]. +type osFile interface { + Name() string + io.Writer + fs.File +} + // syscallDispatcher provides methods that make state-dependent system calls as part of their behaviour. type syscallDispatcher interface { // new starts a goroutine with a new instance of syscallDispatcher. @@ -26,6 +35,8 @@ type syscallDispatcher interface { lookupEnv(key string) (string, bool) // stat provides [os.Stat]. stat(name string) (os.FileInfo, error) + // open provides [os.Open]. + open(name string) (osFile, error) // readdir provides [os.ReadDir]. readdir(name string) ([]os.DirEntry, error) // tempdir provides [os.TempDir]. @@ -64,6 +75,7 @@ func (direct) getuid() int { return os.Getuid() } func (direct) getgid() int { return os.Getgid() } func (direct) lookupEnv(key string) (string, bool) { return os.LookupEnv(key) } func (direct) stat(name string) (os.FileInfo, error) { return os.Stat(name) } +func (direct) open(name string) (osFile, error) { return os.Open(name) } func (direct) readdir(name string) ([]os.DirEntry, error) { return os.ReadDir(name) } func (direct) tempdir() string { return os.TempDir() } |
