aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/outcome.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-10 21:59:16 +0900
committerOphestra <cat@gensokyo.uk>2025-10-10 22:00:49 +0900
commit070e34658766034927ce5deb19369097938c878c (patch)
tree1afee87f7516a81519168e28f8b7241d13c4af2e /internal/app/outcome.go
parent24de7c50a0ea7000c3a49c56b91db9aa72abdd28 (diff)
internal/app: relocate params state initialisation
This is useful for testing. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/outcome.go')
-rw-r--r--internal/app/outcome.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/internal/app/outcome.go b/internal/app/outcome.go
index 4daa8da6..e294d948 100644
--- a/internal/app/outcome.go
+++ b/internal/app/outcome.go
@@ -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 {