cmd/hakurei/print: handle nil config
All checks were successful
Test / Create distribution (push) Successful in 26s
Test / Sandbox (race detector) (push) Successful in 40s
Test / Sandbox (push) Successful in 41s
Test / Hakurei (push) Successful in 44s
Test / Hpkg (push) Successful in 42s
Test / Hakurei (race detector) (push) Successful in 45s
Test / Flake checks (push) Successful in 1m37s
All checks were successful
Test / Create distribution (push) Successful in 26s
Test / Sandbox (race detector) (push) Successful in 40s
Test / Sandbox (push) Successful in 41s
Test / Hakurei (push) Successful in 44s
Test / Hpkg (push) Successful in 42s
Test / Hakurei (race detector) (push) Successful in 45s
Test / Flake checks (push) Successful in 1m37s
There is nothing to print in this case, and such a nil check is missing. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -44,7 +44,8 @@ func printShowSystem(output io.Writer, short, flagJSON bool) {
|
||||
func printShowInstance(
|
||||
output io.Writer, now time.Time,
|
||||
instance *hst.State, config *hst.Config,
|
||||
short, flagJSON bool) (valid bool) {
|
||||
short, flagJSON bool,
|
||||
) (valid bool) {
|
||||
valid = true
|
||||
|
||||
if flagJSON {
|
||||
@@ -66,6 +67,11 @@ func printShowInstance(
|
||||
}
|
||||
}
|
||||
|
||||
if config == nil {
|
||||
// nothing to print
|
||||
return
|
||||
}
|
||||
|
||||
if instance != nil {
|
||||
t.Printf("State\n")
|
||||
t.Printf(" Instance:\t%s (%d -> %d)\n", instance.ID.String(), instance.PID, instance.ShimPID)
|
||||
@@ -84,14 +90,13 @@ func printShowInstance(
|
||||
t.Printf(" Groups:\t%s\n", strings.Join(config.Groups, ", "))
|
||||
}
|
||||
if config.Container != nil {
|
||||
params := config.Container
|
||||
if params.Home != nil {
|
||||
t.Printf(" Home:\t%s\n", params.Home)
|
||||
if config.Container.Home != nil {
|
||||
t.Printf(" Home:\t%s\n", config.Container.Home)
|
||||
}
|
||||
if params.Hostname != "" {
|
||||
t.Printf(" Hostname:\t%s\n", params.Hostname)
|
||||
if config.Container.Hostname != "" {
|
||||
t.Printf(" Hostname:\t%s\n", config.Container.Hostname)
|
||||
}
|
||||
flags := params.Flags.String()
|
||||
flags := config.Container.Flags.String()
|
||||
|
||||
// this is included in the upper hst.Config struct but is relevant here
|
||||
const flagDirectWayland = "directwl"
|
||||
@@ -105,11 +110,11 @@ func printShowInstance(
|
||||
}
|
||||
t.Printf(" Flags:\t%s\n", flags)
|
||||
|
||||
if params.Path != nil {
|
||||
t.Printf(" Path:\t%s\n", params.Path)
|
||||
if config.Container.Path != nil {
|
||||
t.Printf(" Path:\t%s\n", config.Container.Path)
|
||||
}
|
||||
if len(params.Args) > 0 {
|
||||
t.Printf(" Arguments:\t%s\n", strings.Join(params.Args, " "))
|
||||
if len(config.Container.Args) > 0 {
|
||||
t.Printf(" Arguments:\t%s\n", strings.Join(config.Container.Args, " "))
|
||||
}
|
||||
}
|
||||
t.Printf("\n")
|
||||
|
||||
@@ -59,6 +59,7 @@ func TestPrintShowInstance(t *testing.T) {
|
||||
want string
|
||||
valid bool
|
||||
}{
|
||||
{"nil", nil, nil, false, false, "Error: invalid configuration!\n\n", false},
|
||||
{"config", nil, hst.Template(), false, false, `App
|
||||
Identity: 9 (org.chromium.Chromium)
|
||||
Enablements: wayland, dbus, pulseaudio
|
||||
|
||||
Reference in New Issue
Block a user