internal/app: relocate ops condition
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m14s
Test / Hpkg (push) Successful in 4m4s
Test / Sandbox (race detector) (push) Successful in 4m26s
Test / Hakurei (race detector) (push) Successful in 5m24s
Test / Hakurei (push) Successful in 2m18s
Test / Flake checks (push) Successful in 1m32s
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m14s
Test / Hpkg (push) Successful in 4m4s
Test / Sandbox (race detector) (push) Successful in 4m26s
Test / Hakurei (race detector) (push) Successful in 5m24s
Test / Hakurei (push) Successful in 2m18s
Test / Flake checks (push) Successful in 1m32s
This allows reuse and finer grained testing of fromConfig. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -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{},
|
||||
ops := fromConfig(config)
|
||||
|
||||
// TODO(ophestra): move this late for #8 and #9
|
||||
spFilesystemOp{},
|
||||
stateSys := outcomeStateSys{sys: sys, outcomeState: &s}
|
||||
for _, op := range ops {
|
||||
if err := op.toSystem(&stateSys, config); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
spRuntimeOp{},
|
||||
spTmpdirOp{},
|
||||
spAccountOp{},
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user