Documentation
¶
Overview ¶
Package groups resolves fleet group membership. Membership is computed from a group's explicit Members list unioned with the nodes matched by its optional dynamic Selector. The union is policy-relevant: group-policy planning expands from this resolved membership and must surface selector impact to operators.
This package is intentionally pure and side-effect free so it can be table tested without a store or server: every function is a deterministic transformation over in-memory model values. The selector semantics here agree with the dashboard's lib/fleet.ts bucketing (tags / role / country / region) so the server-computed Node.GroupIDs and the client's grouping never diverge.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GroupIDsForNode ¶
GroupIDsForNode is the reverse lookup over a ResolveAll result: it returns the sorted IDs of every group whose resolved membership contains nodeID. This is what populates the read-only Node.GroupIDs convenience field.
func ResolveAll ¶
ResolveAll resolves every group against the same node set, returning a map of group ID to its resolved (deduped, sorted) node IDs.
func ResolveMembers ¶
ResolveMembers returns the resolved node IDs for a single group: explicit g.Members unioned with every node matched by g.Selector. The result is deduplicated and stably sorted by node ID. When Selector is nil, the result is just the deduped, sorted explicit Members.
Explicit Members are returned verbatim (deduped) even if a listed node no longer exists in allNodes — the authored list is canonical and stale-entry cleanup is a separate Phase-1 concern. Only selector matches are drawn from allNodes.
Membership is flat, so no cycle guard is needed here. Parent-cycle and nesting-depth validation over Group.ParentID is enforced by the group CRUD layer; this resolver never walks ParentID.
Types ¶
This section is empty.