node shows what a machine said it is made of, with its age (issue 160) #269

Merged
mesh-admin merged 2 commits from fix/160-node-shows-what-a-machine-is into main 2026-10-12 20:37:06 +00:00
2 changed files with 14 additions and 1 deletions
Showing only changes of commit 67d54d9d09 - Show all commits
+6 -1
View File
@@ -24,7 +24,12 @@ func machineLines(a inventory.MachineAccount, had bool, now time.Time) []string
" " + factLine("kernel", orUnsaid(a.Kernel)),
}
}
out := []string{fmt.Sprintf(" what it is made of, as it said %s ago:", roughly(now.Sub(m.ObservedAt)))}
age := roughly(now.Sub(m.ObservedAt)) + " ago"
if m.ObservedAt.IsZero() {
// Said with no time: its age is not known, and is never read as two thousand years.
age = "at a time it did not say (age unknown)"
}
out := []string{fmt.Sprintf(" what it is made of, as it said %s:", age)}
add := func(name, value string) { out = append(out, " "+factLine(name, value)) }
unknown := map[string]string{}
for k, v := range m.Unknown {
@@ -78,3 +78,11 @@ func TestAnOlderNodeEngineStillShowsArchitectureAndKernel(t *testing.T) {
t.Errorf("%s", got)
}
}
func TestAnAccountWithoutItsTimeSaysAgeUnknown(t *testing.T) {
got := machineLines(inventory.MachineAccount{Architecture: "amd64", Kernel: "linux",
Machine: &inventory.MadeOf{KernelRelease: "7.2"}}, true, time.Now())[0]
if !strings.Contains(got, "age unknown") || strings.Contains(got, "d ago") {
t.Errorf("%s", got)
}
}