internal/app: relocate params state initialisation
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m13s
Test / Hakurei (push) Successful in 3m5s
Test / Hpkg (push) Successful in 4m9s
Test / Hakurei (race detector) (push) Successful in 5m18s
Test / Sandbox (race detector) (push) Successful in 2m9s
Test / Flake checks (push) Successful in 1m40s

This is useful for testing.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-10-10 21:59:16 +09:00
parent 24de7c50a0
commit 070e346587
3 changed files with 24 additions and 24 deletions

View File

@@ -2,6 +2,7 @@ package app
import (
"errors"
"maps"
"strconv"
"hakurei.app/container"
@@ -163,7 +164,7 @@ type outcomeStateSys struct {
*outcomeState
}
// outcomeState returns the address of a new outcomeStateSys embedding the current outcomeState.
// newSys returns the address of a new outcomeStateSys embedding the current outcomeState.
func (s *outcomeState) newSys(config *hst.Config, sys *system.I) *outcomeStateSys {
return &outcomeStateSys{
appId: config.ID, et: config.Enablements.Unwrap(),
@@ -173,6 +174,17 @@ func (s *outcomeState) newSys(config *hst.Config, sys *system.I) *outcomeStateSy
}
}
// newParams returns the address of a new outcomeStateParams embedding the current outcomeState.
func (s *outcomeState) newParams() *outcomeStateParams {
stateParams := outcomeStateParams{params: new(container.Params), outcomeState: s}
if s.Container.Env == nil {
stateParams.env = make(map[string]string, envAllocSize)
} else {
stateParams.env = maps.Clone(s.Container.Env)
}
return &stateParams
}
// ensureRuntimeDir must be called if access to paths within XDG_RUNTIME_DIR is required.
func (state *outcomeStateSys) ensureRuntimeDir() {
if state.useRuntimeDir {