internal/outcome: rename from app
All checks were successful
Test / Sandbox (race detector) (push) Successful in 4m7s
Test / Hakurei (race detector) (push) Successful in 4m55s
Test / Flake checks (push) Successful in 1m27s
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m11s
Test / Hakurei (push) Successful in 3m9s
Test / Hpkg (push) Successful in 4m1s

This is less ambiguous, and more accurately describes the purpose of the package.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2025-10-29 04:32:43 +09:00
parent a52f7038e5
commit a0b4e47acc
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
45 changed files with 65 additions and 64 deletions

View File

@ -18,9 +18,9 @@ import (
"hakurei.app/container/fhs" "hakurei.app/container/fhs"
"hakurei.app/hst" "hakurei.app/hst"
"hakurei.app/internal" "hakurei.app/internal"
"hakurei.app/internal/app"
"hakurei.app/internal/app/state"
"hakurei.app/internal/env" "hakurei.app/internal/env"
"hakurei.app/internal/outcome"
"hakurei.app/internal/state"
"hakurei.app/message" "hakurei.app/message"
"hakurei.app/system/dbus" "hakurei.app/system/dbus"
) )
@ -51,7 +51,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
Flag(&flagVerbose, "v", command.BoolFlag(false), "Increase log verbosity"). Flag(&flagVerbose, "v", command.BoolFlag(false), "Increase log verbosity").
Flag(&flagJSON, "json", command.BoolFlag(false), "Serialise output in JSON when applicable") Flag(&flagJSON, "json", command.BoolFlag(false), "Serialise output in JSON when applicable")
c.Command("shim", command.UsageInternal, func([]string) error { app.Shim(msg); return errSuccess }) c.Command("shim", command.UsageInternal, func([]string) error { outcome.Shim(msg); return errSuccess })
c.Command("app", "Load and start container from configuration file", func(args []string) error { c.Command("app", "Load and start container from configuration file", func(args []string) error {
if len(args) < 1 { if len(args) < 1 {
@ -64,7 +64,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
config.Container.Args = append(config.Container.Args, args[1:]...) config.Container.Args = append(config.Container.Args, args[1:]...)
} }
app.Main(ctx, msg, config) outcome.Main(ctx, msg, config)
panic("unreachable") panic("unreachable")
}) })
@ -96,7 +96,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
passwd *user.User passwd *user.User
passwdOnce sync.Once passwdOnce sync.Once
passwdFunc = func() { passwdFunc = func() {
us := strconv.Itoa(app.HsuUid(new(app.Hsu).MustID(msg), flagIdentity)) us := strconv.Itoa(outcome.HsuUid(new(outcome.Hsu).MustID(msg), flagIdentity))
if u, err := user.LookupId(us); err != nil { if u, err := user.LookupId(us); err != nil {
msg.Verbosef("cannot look up uid %s", us) msg.Verbosef("cannot look up uid %s", us)
passwd = &user.User{ passwd = &user.User{
@ -258,7 +258,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
} }
} }
app.Main(ctx, msg, config) outcome.Main(ctx, msg, config)
panic("unreachable") panic("unreachable")
}). }).
Flag(&flagDBusConfigSession, "dbus-config", command.StringFlag("builtin"), Flag(&flagDBusConfigSession, "dbus-config", command.StringFlag("builtin"),
@ -321,7 +321,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
var flagShort bool var flagShort bool
c.NewCommand("ps", "List active instances", func(args []string) error { c.NewCommand("ps", "List active instances", func(args []string) error {
var sc hst.Paths var sc hst.Paths
env.CopyPaths().Copy(&sc, new(app.Hsu).MustID(nil)) env.CopyPaths().Copy(&sc, new(outcome.Hsu).MustID(nil))
printPs(os.Stdout, time.Now().UTC(), state.NewMulti(msg, sc.RunDirPath), flagShort, flagJSON) printPs(os.Stdout, time.Now().UTC(), state.NewMulti(msg, sc.RunDirPath), flagShort, flagJSON)
return errSuccess return errSuccess
}).Flag(&flagShort, "short", command.BoolFlag(false), "Print instance id") }).Flag(&flagShort, "short", command.BoolFlag(false), "Print instance id")

View File

@ -11,9 +11,9 @@ import (
"syscall" "syscall"
"hakurei.app/hst" "hakurei.app/hst"
"hakurei.app/internal/app"
"hakurei.app/internal/app/state"
"hakurei.app/internal/env" "hakurei.app/internal/env"
"hakurei.app/internal/outcome"
"hakurei.app/internal/state"
"hakurei.app/message" "hakurei.app/message"
) )
@ -84,7 +84,7 @@ func shortIdentifierString(s string) string {
func tryIdentifier(msg message.Msg, name string) (config *hst.Config, entry *hst.State) { func tryIdentifier(msg message.Msg, name string) (config *hst.Config, entry *hst.State) {
return tryIdentifierEntries(msg, name, func() map[hst.ID]*hst.State { return tryIdentifierEntries(msg, name, func() map[hst.ID]*hst.State {
var sc hst.Paths var sc hst.Paths
env.CopyPaths().Copy(&sc, new(app.Hsu).MustID(nil)) env.CopyPaths().Copy(&sc, new(outcome.Hsu).MustID(nil))
s := state.NewMulti(msg, sc.RunDirPath) s := state.NewMulti(msg, sc.RunDirPath)
if entries, err := state.Join(s); err != nil { if entries, err := state.Join(s); err != nil {
msg.GetLogger().Printf("cannot join store: %v", err) // not fatal msg.GetLogger().Printf("cannot join store: %v", err) // not fatal

View File

@ -12,9 +12,9 @@ import (
"hakurei.app/hst" "hakurei.app/hst"
"hakurei.app/internal" "hakurei.app/internal"
"hakurei.app/internal/app"
"hakurei.app/internal/app/state"
"hakurei.app/internal/env" "hakurei.app/internal/env"
"hakurei.app/internal/outcome"
"hakurei.app/internal/state"
"hakurei.app/message" "hakurei.app/message"
) )
@ -23,7 +23,7 @@ func printShowSystem(output io.Writer, short, flagJSON bool) {
t := newPrinter(output) t := newPrinter(output)
defer t.MustFlush() defer t.MustFlush()
info := &hst.Info{Version: internal.Version(), User: new(app.Hsu).MustID(nil)} info := &hst.Info{Version: internal.Version(), User: new(outcome.Hsu).MustID(nil)}
env.CopyPaths().Copy(&info.Paths, info.User) env.CopyPaths().Copy(&info.Paths, info.User)
if flagJSON { if flagJSON {

View File

@ -6,7 +6,7 @@ import (
"time" "time"
"hakurei.app/hst" "hakurei.app/hst"
"hakurei.app/internal/app/state" "hakurei.app/internal/state"
) )
var ( var (

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"context" "context"

View File

@ -1,8 +1,9 @@
package app package outcome
import ( import (
"bytes" "bytes"
"context" "context"
"encoding/json"
"io" "io"
"io/fs" "io/fs"
"log" "log"
@ -585,6 +586,23 @@ type errorReader struct{ val error }
func (r errorReader) Read([]byte) (int, error) { return -1, r.val } func (r errorReader) Read([]byte) (int, error) { return -1, r.val }
// mustMarshal returns the result of [json.Marshal] as a string and panics on error.
func mustMarshal(v any) string {
if b, err := json.Marshal(v); err != nil {
panic(err.Error())
} else {
return string(b)
}
}
// m is a shortcut for [check.MustAbs].
func m(pathname string) *check.Absolute { return check.MustAbs(pathname) }
// f returns [hst.FilesystemConfig] wrapped in its [json] adapter.
func f(c hst.FilesystemConfig) hst.FilesystemConfigJSON {
return hst.FilesystemConfigJSON{FilesystemConfig: c}
}
// panicMsgContext implements [message.Msg] and [context.Context] with methods wrapping panic. // panicMsgContext implements [message.Msg] and [context.Context] with methods wrapping panic.
// This should be assigned to test cases to be checked against. // This should be assigned to test cases to be checked against.
type panicMsgContext struct{} type panicMsgContext struct{}

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"context" "context"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"os" "os"

View File

@ -1,5 +1,4 @@
// Package app implements high-level hakurei container behaviour. package outcome
package app
import ( import (
"context" "context"

View File

@ -1,9 +1,8 @@
package app package outcome
import ( import (
"bytes" "bytes"
"encoding/gob" "encoding/gob"
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"io" "io"
@ -28,7 +27,7 @@ import (
"hakurei.app/system/dbus" "hakurei.app/system/dbus"
) )
func TestApp(t *testing.T) { func TestOutcomeMain(t *testing.T) {
t.Parallel() t.Parallel()
msg := message.NewMsg(nil) msg := message.NewMsg(nil)
msg.SwapVerbose(testing.Verbose()) msg.SwapVerbose(testing.Verbose())
@ -653,14 +652,6 @@ func TestApp(t *testing.T) {
} }
} }
func mustMarshal(v any) string {
if b, err := json.Marshal(v); err != nil {
panic(err.Error())
} else {
return string(b)
}
}
func stubDirEntries(names ...string) (e []fs.DirEntry, err error) { func stubDirEntries(names ...string) (e []fs.DirEntry, err error) {
e = make([]fs.DirEntry, len(names)) e = make([]fs.DirEntry, len(names))
for i, name := range names { for i, name := range names {
@ -930,11 +921,3 @@ func (k *stubNixOS) fatalf(format string, v ...any) { panic(fmt.Sprintf(format,
func (k *stubNixOS) isVerbose() bool { return true } func (k *stubNixOS) isVerbose() bool { return true }
func (k *stubNixOS) verbose(v ...any) { log.Print(v...) } func (k *stubNixOS) verbose(v ...any) { log.Print(v...) }
func (k *stubNixOS) verbosef(format string, v ...any) { log.Printf(format, v...) } func (k *stubNixOS) verbosef(format string, v ...any) { log.Printf(format, v...) }
func m(pathname string) *check.Absolute {
return check.MustAbs(pathname)
}
func f(c hst.FilesystemConfig) hst.FilesystemConfigJSON {
return hst.FilesystemConfigJSON{FilesystemConfig: c}
}

View File

@ -1,4 +1,5 @@
package app // Package outcome implements the outcome of the privileged and container sides of a hakurei container.
package outcome
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"testing" "testing"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"context" "context"
@ -16,7 +16,7 @@ import (
"hakurei.app/container/fhs" "hakurei.app/container/fhs"
"hakurei.app/hst" "hakurei.app/hst"
"hakurei.app/internal" "hakurei.app/internal"
"hakurei.app/internal/app/state" "hakurei.app/internal/state"
"hakurei.app/message" "hakurei.app/message"
"hakurei.app/system" "hakurei.app/system"
) )

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"context" "context"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"bytes" "bytes"
@ -118,7 +118,7 @@ func TestShimEntrypoint(t *testing.T) {
spTmpdirOp{}, spTmpdirOp{},
spAccountOp{}, spAccountOp{},
&spWaylandOp{}, &spWaylandOp{},
&spPulseOp{(*[256]byte)(bytes.Repeat([]byte{0}, pulseCookieSizeMax)), pulseCookieSizeMax}, &spPulseOp{(*[pulseCookieSizeMax]byte)(bytes.Repeat([]byte{0}, pulseCookieSizeMax)), pulseCookieSizeMax},
&spDBusOp{true}, &spDBusOp{true},
&spFilesystemOp{}, &spFilesystemOp{},
}}, }},

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"encoding/gob" "encoding/gob"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"os" "os"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"encoding/gob" "encoding/gob"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"encoding/gob" "encoding/gob"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"syscall" "syscall"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"encoding/gob" "encoding/gob"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"bytes" "bytes"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"encoding/gob" "encoding/gob"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"testing" "testing"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"encoding/gob" "encoding/gob"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"testing" "testing"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"encoding/gob" "encoding/gob"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"testing" "testing"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"encoding/gob" "encoding/gob"

View File

@ -1,4 +1,4 @@
package app package outcome
import ( import (
"os" "os"

View File

@ -10,7 +10,7 @@ import (
"hakurei.app/container/check" "hakurei.app/container/check"
"hakurei.app/hst" "hakurei.app/hst"
"hakurei.app/internal/app/state" "hakurei.app/internal/state"
"hakurei.app/message" "hakurei.app/message"
) )