hst/container: flags string representation
All checks were successful
Test / Create distribution (push) Successful in 32s
Test / Sandbox (push) Successful in 2m9s
Test / Sandbox (race detector) (push) Successful in 3m56s
Test / Hpkg (push) Successful in 4m5s
Test / Hakurei (race detector) (push) Successful in 4m42s
Test / Hakurei (push) Successful in 2m9s
Test / Flake checks (push) Successful in 1m28s
All checks were successful
Test / Create distribution (push) Successful in 32s
Test / Sandbox (push) Successful in 2m9s
Test / Sandbox (race detector) (push) Successful in 3m56s
Test / Hpkg (push) Successful in 4m5s
Test / Hakurei (race detector) (push) Successful in 4m42s
Test / Hakurei (push) Successful in 2m9s
Test / Flake checks (push) Successful in 1m28s
This is useful for a user-facing representation other than JSON. This also gets rid of the ugly, outdated flags string builder in cmd/hakurei. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -89,24 +89,19 @@ func printShowInstance(
|
||||
if params.Hostname != "" {
|
||||
t.Printf(" Hostname:\t%s\n", params.Hostname)
|
||||
}
|
||||
flags := make([]string, 0, 7)
|
||||
writeFlag := func(name string, flag uintptr, force bool) {
|
||||
if params.Flags&flag != 0 || force {
|
||||
flags = append(flags, name)
|
||||
flags := params.Flags.String()
|
||||
|
||||
// this is included in the upper hst.Config struct but is relevant here
|
||||
const flagDirectWayland = "directwl"
|
||||
if config.DirectWayland {
|
||||
// hardcoded value when every flag is unset
|
||||
if flags == "none" {
|
||||
flags = flagDirectWayland
|
||||
} else {
|
||||
flags += ", " + flagDirectWayland
|
||||
}
|
||||
}
|
||||
writeFlag("userns", hst.FUserns, false)
|
||||
writeFlag("devel", hst.FDevel, false)
|
||||
writeFlag("net", hst.FHostNet, false)
|
||||
writeFlag("abstract", hst.FHostAbstract, false)
|
||||
writeFlag("device", hst.FDevice, false)
|
||||
writeFlag("tty", hst.FTty, false)
|
||||
writeFlag("mapuid", hst.FMapRealUID, false)
|
||||
writeFlag("directwl", 0, config.DirectWayland)
|
||||
if len(flags) == 0 {
|
||||
flags = append(flags, "none")
|
||||
}
|
||||
t.Printf(" Flags:\t%s\n", strings.Join(flags, " "))
|
||||
t.Printf(" Flags:\t%s\n", flags)
|
||||
|
||||
if params.Path != nil {
|
||||
t.Printf(" Path:\t%s\n", params.Path)
|
||||
|
||||
@@ -43,7 +43,7 @@ func TestPrintShowInstance(t *testing.T) {
|
||||
Groups: video, dialout, plugdev
|
||||
Home: /data/data/org.chromium.Chromium
|
||||
Hostname: localhost
|
||||
Flags: userns devel net abstract device tty mapuid
|
||||
Flags: multiarch, compat, devel, userns, net, abstract, tty, mapuid, device, runtime, tmpdir
|
||||
Path: /run/current-system/sw/bin/chromium
|
||||
Arguments: chromium --ignore-gpu-blocklist --disable-smooth-scrolling --enable-features=UseOzonePlatform --ozone-platform=wayland
|
||||
|
||||
@@ -87,6 +87,22 @@ App
|
||||
Enablements: (no enablements)
|
||||
Flags: none
|
||||
|
||||
`, false},
|
||||
{"config flag none directwl", nil, &hst.Config{DirectWayland: true, Container: new(hst.ContainerConfig)}, false, false, `Error: container configuration missing path to home directory!
|
||||
|
||||
App
|
||||
Identity: 0
|
||||
Enablements: (no enablements)
|
||||
Flags: directwl
|
||||
|
||||
`, false},
|
||||
{"config flag directwl", nil, &hst.Config{DirectWayland: true, Container: &hst.ContainerConfig{Flags: hst.FMultiarch}}, false, false, `Error: container configuration missing path to home directory!
|
||||
|
||||
App
|
||||
Identity: 0
|
||||
Enablements: (no enablements)
|
||||
Flags: multiarch, directwl
|
||||
|
||||
`, false},
|
||||
{"config nil entries", nil, &hst.Config{Container: &hst.ContainerConfig{Filesystem: make([]hst.FilesystemConfigJSON, 1)}, ExtraPerms: make([]hst.ExtraPermConfig, 1)}, false, false, `Error: container configuration missing path to home directory!
|
||||
|
||||
@@ -124,7 +140,7 @@ App
|
||||
Groups: video, dialout, plugdev
|
||||
Home: /data/data/org.chromium.Chromium
|
||||
Hostname: localhost
|
||||
Flags: userns devel net abstract device tty mapuid
|
||||
Flags: multiarch, compat, devel, userns, net, abstract, tty, mapuid, device, runtime, tmpdir
|
||||
Path: /run/current-system/sw/bin/chromium
|
||||
Arguments: chromium --ignore-gpu-blocklist --disable-smooth-scrolling --enable-features=UseOzonePlatform --ozone-platform=wayland
|
||||
|
||||
|
||||
Reference in New Issue
Block a user