From 648e1d641a8b0ae7c5bc4899f84b884d4335c97f Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 18 Feb 2025 23:05:37 +0900 Subject: app: separate interface from implementation Signed-off-by: Ophestra --- internal/app/app.go | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) (limited to 'internal/app/app.go') diff --git a/internal/app/app.go b/internal/app/app.go index 2a96c544..cf21ac71 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -1,7 +1,6 @@ package app import ( - "context" "sync" "git.gensokyo.uk/security/fortify/fst" @@ -9,23 +8,11 @@ import ( "git.gensokyo.uk/security/fortify/internal/sys" ) -type App interface { - // ID returns a copy of App's unique ID. - ID() fst.ID - // Run sets up the system and runs the App. - Run(ctx context.Context, rs *RunState) error - - Seal(config *fst.Config) error - String() string -} - -type RunState struct { - // Start is true if fsu is successfully started. - Start bool - // ExitCode is the value returned by shim. - ExitCode int - // WaitErr is error returned by the underlying wait syscall. - WaitErr error +func New(os sys.State) (fst.App, error) { + a := new(app) + a.id = new(fst.ID) + a.os = os + return a, fst.NewAppID(a.id) } type app struct { @@ -63,10 +50,3 @@ func (a *app) String() string { return "(unsealed fortified app)" } - -func New(os sys.State) (App, error) { - a := new(app) - a.id = new(fst.ID) - a.os = os - return a, fst.NewAppID(a.id) -} -- cgit v1.3.1