diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-08 19:39:00 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-08 19:39:00 +0900 |
| commit | ee6c471fe6e183d78e396a23b2a92fd26bb31143 (patch) | |
| tree | 6d7eb6a6d7d057a840936e435150f30b57a8a2f3 /internal/app/finalise.go | |
| parent | 16bf3178d358f72ce9605352364809b42229af5f (diff) | |
internal/app: relocate ops condition
This allows reuse and finer grained testing of fromConfig.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/finalise.go')
| -rw-r--r-- | internal/app/finalise.go | 63 |
1 files changed, 18 insertions, 45 deletions
diff --git a/internal/app/finalise.go b/internal/app/finalise.go index bd9cf2b6..491a775b 100644 --- a/internal/app/finalise.go +++ b/internal/app/finalise.go @@ -47,8 +47,6 @@ func (k *outcome) finalise(ctx context.Context, msg container.Msg, id *state.ID, // only used for a nil configured env map const envAllocSize = 1 << 6 - var kp finaliseProcess - if ctx == nil || id == nil { // unreachable panic("invalid call to finalise") @@ -73,6 +71,8 @@ func (k *outcome) finalise(ctx context.Context, msg container.Msg, id *state.ID, k.ct = ct } + var kp finaliseProcess + // hsu expects numerical group ids kp.supp = make([]string, len(config.Groups)) for i, name := range config.Groups { @@ -105,52 +105,25 @@ func (k *outcome) finalise(ctx context.Context, msg container.Msg, id *state.ID, kp.runDirPath, kp.identity, kp.id = s.sc.RunDirPath, s.identity, s.id sys := system.New(k.ctx, msg, s.uid.unwrap()) - { - ops := []outcomeOp{ - // must run first - &spParamsOp{}, - - // TODO(ophestra): move this late for #8 and #9 - spFilesystemOp{}, - - spRuntimeOp{}, - spTmpdirOp{}, - spAccountOp{}, - } + ops := fromConfig(config) - et := config.Enablements.Unwrap() - if et&hst.EWayland != 0 { - ops = append(ops, &spWaylandOp{}) - } - if et&hst.EX11 != 0 { - ops = append(ops, &spX11Op{}) - } - if et&hst.EPulse != 0 { - ops = append(ops, &spPulseOp{}) - } - if et&hst.EDBus != 0 { - ops = append(ops, &spDBusOp{}) - } - ops = append(ops, spFinal{}) - - stateSys := outcomeStateSys{sys: sys, outcomeState: &s} - for _, op := range ops { - if err := op.toSystem(&stateSys, config); err != nil { - return err - } + stateSys := outcomeStateSys{sys: sys, outcomeState: &s} + for _, op := range ops { + if err := op.toSystem(&stateSys, config); err != nil { + return err } + } - // TODO(ophestra): move to shim - stateParams := outcomeStateParams{params: &k.container, outcomeState: &s} - if s.Container.Env == nil { - stateParams.env = make(map[string]string, envAllocSize) - } else { - stateParams.env = maps.Clone(s.Container.Env) - } - for _, op := range ops { - if err := op.toContainer(&stateParams); err != nil { - return err - } + // TODO(ophestra): move to shim + stateParams := outcomeStateParams{params: &k.container, outcomeState: &s} + if s.Container.Env == nil { + stateParams.env = make(map[string]string, envAllocSize) + } else { + stateParams.env = maps.Clone(s.Container.Env) + } + for _, op := range ops { + if err := op.toContainer(&stateParams); err != nil { + return err } } |
