forked from security/hakurei
app: separate interface from implementation
Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user