diff --git a/cmd/mesh-control/nodes.go b/cmd/mesh-control/nodes.go index 3907138..587f147 100644 --- a/cmd/mesh-control/nodes.go +++ b/cmd/mesh-control/nodes.go @@ -22,7 +22,7 @@ import ( func nodeCommand(ctx context.Context, args []string) error { if len(args) == 0 { - return errors.New("node add , node list, or node show ") + return errors.New("node add , node list, node show , or node public-domain [domain]") } open, err := openStores(ctx) if err != nil { @@ -65,8 +65,30 @@ func nodeCommand(ctx context.Context, args []string) error { } return nil + case "public-domain": + // The domain this node composes its routed names under (novox/hq ADR 0056). Given a domain, + // it is set; given nothing, it is cleared — a node that stops facing the outside composes no + // names. Lab-versus-production is this one setting and nothing else (see the ADR). + if len(args) < 2 || len(args) > 3 { + return errors.New( + "node public-domain [domain] — a domain sets it, nothing clears it") + } + domain := "" + if len(args) == 3 { + domain = args[2] + } + if err := inv.SetPublicDomain(ctx, args[1], domain); err != nil { + return err + } + if domain == "" { + fmt.Printf("%s has no public domain, so it composes no routed names\n", args[1]) + } else { + fmt.Printf("%s composes its routed names under %s\n", args[1], domain) + } + return nil + default: - return fmt.Errorf("node has no %q; it has add and list", args[0]) + return fmt.Errorf("node has no %q; it has add, list, show and public-domain", args[0]) } } @@ -261,6 +283,17 @@ func showNode(ctx context.Context, inv *inventory.Inventory, name string) error fmt.Printf("%s\n", node.Name) fmt.Printf(" last heard from %s\n", heardFrom(node)) + // The domain its routed names are composed under, when it has one (novox/hq ADR 0056). Shown + // only when set: a machine that serves nothing to the outside has no domain, and saying so of + // every internal node would be noise. + domain, err := inv.PublicDomainOf(ctx, name) + if err != nil { + return err + } + if domain != "" { + fmt.Printf(" public domain %s\n", domain) + } + held, err := inv.Profile(ctx, name) if err != nil { return err diff --git a/cmd/mesh-control/plan.go b/cmd/mesh-control/plan.go index b93dd16..9cc6cdf 100644 --- a/cmd/mesh-control/plan.go +++ b/cmd/mesh-control/plan.go @@ -69,9 +69,18 @@ func planFor(ctx context.Context, open *stores, nodeName string) (catalogue.Reso return catalogue.Resolution{}, nil, err } + // The domain this node composes its routed names under (novox/hq ADR 0056). A route + // contribution carries only a label; the resolver joins