Documentation
¶
Overview ¶
Package network manages user-defined named networks: VM-independent records that workspaces can join so multiple workspaces share a subnet and address each other by name. This package owns the registry and address allocation only — a backend-neutral data model persisted under the state directory. Live realization (host bridge, cross-VM connectivity, name resolution) is a separate supervisor-side concern layered on top of these records.
Index ¶
- func IndexPath(stateDir string) string
- func Join(stateDir, name, workspace string) (string, error)
- func Leave(stateDir, name, workspace string) error
- func LeaveAll(stateDir, workspace string) error
- func Remove(stateDir, name string, force bool) error
- func ValidName(name string) bool
- func WriteIndex(stateDir string, idx Index) error
- type Index
- type Member
- type Record
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Join ¶
Join allocates a stable member IP for workspace on the named network and persists it. If the workspace is already a member, its existing IP is returned unchanged so an address survives stop/start. It fails closed when the subnet has no free host address.
func Leave ¶
Leave removes a workspace's membership from a network, freeing its IP. It is idempotent and never errors on an unknown network or non-member.
func LeaveAll ¶
LeaveAll removes a workspace from every network it belongs to. Use it when a workspace is deleted so no network keeps a member that no longer exists.
func Remove ¶
Remove deletes a network. It fails closed while the network still has members unless force is set.
func ValidName ¶
ValidName reports whether name is a usable network name: a DNS-label-like token (lowercase letters, digits, hyphens; must start alphanumeric).
func WriteIndex ¶
WriteIndex persists the registry.
Types ¶
type Index ¶
type Index struct {
Networks []Record `json:"networks"`
}
Index is the persisted set of named networks.
type Record ¶
type Record struct {
Name string `json:"name"`
Subnet string `json:"subnet"` // CIDR, e.g. 10.44.1.0/24
Gateway string `json:"gateway"` // first usable host, e.g. 10.44.1.1
CreatedAt string `json:"created_at,omitempty"`
Members []Member `json:"members,omitempty"`
}
Record is one named network.