Name every held kind of each module the flip takes in the converge preview and its digest (hq ADR 0103)

This commit is contained in:
2026-09-22 18:27:19 +02:00
parent 689c2c6d33
commit bfe4991dd7
2 changed files with 59 additions and 8 deletions
+16 -7
View File
@@ -119,7 +119,7 @@ func take(ctx context.Context, open *stores, node, module string) (string, error
var replaces []string
for _, h := range reported.Held {
if h.Module == module {
replaces = append(replaces, fmt.Sprintf(" %s %s (%s)", h.Kind, h.Target, h.ID))
replaces = append(replaces, " "+heldLine(h))
}
}
if len(replaces) > 0 {
@@ -347,14 +347,18 @@ func previewOf(node string, reported inventory.Adoption, derived derivedFilter,
for _, m := range takes {
fmt.Fprintf(&b, " %s\n", m)
said = append(said, "take "+m)
// Every kind it holds — a directory, a service, an archive, a process, a user as well as a
// file (novox/hq ADR 0103) — each said, and each part of what the flip is asked to act on.
for _, h := range reported.Held {
if h.Module == m && h.Kind == "file" {
fmt.Fprintf(&b, " replacing the found file %s", h.Target)
if h.Kept != "" {
fmt.Fprintf(&b, " (original kept at %s)", h.Kept)
}
b.WriteString("\n")
if h.Module != m {
continue
}
fmt.Fprintf(&b, " replacing the found %s", heldLine(h))
if h.Kept != "" {
fmt.Fprintf(&b, ", original kept at %s", h.Kept)
}
b.WriteString("\n")
said = append(said, "replace "+m+" "+heldLine(h)+" "+h.Kept)
}
}
if !filterAssigned {
@@ -427,6 +431,11 @@ func (d derivedFilter) fate(r inventory.Reach) string {
return "WILL CLOSE — no module assigned here declares it"
}
// heldLine is one thing a node holds as found, as take and the converge preview both say it.
func heldLine(h inventory.Held) string {
return fmt.Sprintf("%s %s (%s)", h.Kind, h.Target, h.ID)
}
// loopback is an address nothing off the machine reaches.
func loopback(address string) bool {
a := strings.Trim(address, "[]")