Documentation
¶
Index ¶
- type BaseNetworkManager
- func (n *BaseNetworkManager) ConfigureDNS() error
- func (n *BaseNetworkManager) ConfigureGuest() error
- func (n *BaseNetworkManager) ConfigureHostRoute() error
- func (n *BaseNetworkManager) DNSChanged() bool
- func (n *BaseNetworkManager) FlushDNS() error
- func (n *BaseNetworkManager) IsHostRouteInstalled() bool
- func (n *BaseNetworkManager) IsResolverInstalled() bool
- func (n *BaseNetworkManager) NeedsPrivilegeForCluster() bool
- func (n *BaseNetworkManager) NeedsPrivilegeForDNS() bool
- func (n *BaseNetworkManager) RevertDNS() error
- func (n *BaseNetworkManager) RevertGuest() error
- func (n *BaseNetworkManager) RevertHostRoute() error
- type ColimaNetworkManager
- type MockNetworkInterfaceProvider
- type MockNetworkManager
- func (m *MockNetworkManager) ConfigureDNS() error
- func (m *MockNetworkManager) ConfigureGuest() error
- func (m *MockNetworkManager) ConfigureHostRoute() error
- func (m *MockNetworkManager) DNSChanged() bool
- func (m *MockNetworkManager) FlushDNS() error
- func (m *MockNetworkManager) IsHostRouteInstalled() bool
- func (m *MockNetworkManager) IsResolverInstalled() bool
- func (m *MockNetworkManager) NeedsPrivilegeForCluster() bool
- func (m *MockNetworkManager) NeedsPrivilegeForDNS() bool
- func (m *MockNetworkManager) RevertDNS() error
- func (m *MockNetworkManager) RevertGuest() error
- func (m *MockNetworkManager) RevertHostRoute() error
- type NetworkInterfaceProvider
- type NetworkManager
- type RealNetworkInterfaceProvider
- type Shims
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseNetworkManager ¶
type BaseNetworkManager struct {
// contains filtered or unexported fields
}
BaseNetworkManager is a concrete implementation of NetworkManager.
func NewBaseNetworkManager ¶
func NewBaseNetworkManager(rt *runtime.Runtime) *BaseNetworkManager
NewNetworkManager creates a new NetworkManager
func (*BaseNetworkManager) ConfigureDNS ¶
func (n *BaseNetworkManager) ConfigureDNS() error
ConfigureDNS sets up DNS by modifying system files to route DNS queries. Resolver IP is read from config via effectiveResolverIP (dns.address, or 127.0.0.1 in localhost mode when unset).
func (*BaseNetworkManager) ConfigureGuest ¶
func (n *BaseNetworkManager) ConfigureGuest() error
ConfigureGuest sets up the guest VM network. Base implementation is a no-op; Colima overrides and reads guest address from config.
func (*BaseNetworkManager) ConfigureHostRoute ¶
func (n *BaseNetworkManager) ConfigureHostRoute() error
ConfigureHostRoute ensures that a network route from the host to the VM guest is established. Guest address is read from config (workstation.address). Installs the route in the live routing table via `route add` when missing, then registers it as an additional route via `networksetup -setadditionalroutes` so it survives reboots. The persistence step is best-effort: if no primary network service can be detected, the live route is left in place and a warning is printed.
func (*BaseNetworkManager) DNSChanged ¶ added in v0.9.0
func (n *BaseNetworkManager) DNSChanged() bool
DNSChanged reports whether ConfigureDNS wrote a new configuration during this run.
func (*BaseNetworkManager) FlushDNS ¶ added in v0.9.0
func (n *BaseNetworkManager) FlushDNS() error
FlushDNS flushes the macOS DNS cache by running dscacheutil and restarting mDNSResponder.
func (*BaseNetworkManager) IsHostRouteInstalled ¶ added in v0.9.0
func (n *BaseNetworkManager) IsHostRouteInstalled() bool
IsHostRouteInstalled reports whether the host route this NetworkManager would install (for the configured CIDR via the configured guest) is currently present and matches. Always false on runtimes that don't use host routes (anything other than colima). Used by 'windsor down' to detect orphaned cluster-reachability state when the operator can't elevate non-interactively.
func (*BaseNetworkManager) IsResolverInstalled ¶ added in v0.9.0
func (n *BaseNetworkManager) IsResolverInstalled() bool
IsResolverInstalled reports whether the per-domain DNS resolver entry this NetworkManager would install is currently present and matches the configured resolver IP. False when no dns.domain is configured or when no resolver address is derivable. Used by 'windsor down' to detect orphaned DNS-resolver state. The "matches" semantic means a stale entry with a different IP will not be detected as installed — operators with that edge case can run 'configure network --revert' explicitly.
func (*BaseNetworkManager) NeedsPrivilegeForCluster ¶ added in v0.9.0
func (n *BaseNetworkManager) NeedsPrivilegeForCluster() bool
NeedsPrivilegeForCluster reports whether the host needs elevated configuration before the rest of the blueprint can reach the cluster — host route + in-VM forwarding on VM-backed runtimes whose cluster IP is not on loopback. Returns true only on colima today; docker-desktop has the cluster on 127.0.0.1 and never needs a host route. Failures of underlying probes are treated as false (the privileged work is also gated by the actual ConfigureHostRoute call, which will surface its own error if invoked when it shouldn't have been).
func (*BaseNetworkManager) NeedsPrivilegeForDNS ¶ added in v0.9.0
func (n *BaseNetworkManager) NeedsPrivilegeForDNS() bool
NeedsPrivilegeForDNS reports whether the host's DNS resolver needs elevated configuration to point *.dns.domain at the cluster resolver. Returns true when a configurable DNS service is available (dns.domain set; resolver IP derivable via effectiveResolverIP) and the host's current resolver entry does not already match. Failures of underlying probes are treated as false.
func (*BaseNetworkManager) RevertDNS ¶ added in v0.9.0
func (n *BaseNetworkManager) RevertDNS() error
RevertDNS removes the per-domain resolver file installed by ConfigureDNS on macOS. Idempotent: no-op when dns.domain is unset; rm -f tolerates a missing file silently.
func (*BaseNetworkManager) RevertGuest ¶ added in v0.9.0
func (n *BaseNetworkManager) RevertGuest() error
RevertGuest removes guest-VM forwarding installed by ConfigureGuest. Base implementation is a no-op (nothing to revert when ConfigureGuest was a no-op); Colima overrides to remove the iptables FORWARD rule it installed in the VM.
func (*BaseNetworkManager) RevertHostRoute ¶ added in v0.9.0
func (n *BaseNetworkManager) RevertHostRoute() error
RevertHostRoute removes the host-to-guest route previously added by ConfigureHostRoute on macOS. Idempotent: no-op when the network CIDR is unset, tolerates "not in table" for the live route delete, and removes the matching networksetup additional-route entry when present.
type ColimaNetworkManager ¶
type ColimaNetworkManager struct {
BaseNetworkManager
// contains filtered or unexported fields
}
colimaNetworkManager is a concrete implementation of NetworkManager
func NewColimaNetworkManager ¶
func NewColimaNetworkManager(rt *runtime.Runtime, networkInterfaceProvider NetworkInterfaceProvider) *ColimaNetworkManager
NewColimaNetworkManager creates a new ColimaNetworkManager
func (*ColimaNetworkManager) ConfigureGuest ¶
func (n *ColimaNetworkManager) ConfigureGuest() error
ConfigureGuest sets up guest traffic forwarding in a Colima environment. Reads guest address from config (workstation.address). For Docker, configures iptables for the Docker bridge; for Incus, Incus network. No-op when guest address is empty.
func (*ColimaNetworkManager) RevertGuest ¶ added in v0.9.0
func (n *ColimaNetworkManager) RevertGuest() error
RevertGuest removes the in-VM iptables FORWARD rule that ConfigureGuest installed. Probes the VM for the docker bridge interface the same way ConfigureGuest does, then runs iptables -D (delete) inside the VM. Idempotent: tolerates a missing rule (iptables -D returns non-zero with "No chain/target/match by that name" or "does a matching rule exist") and a missing bridge (revert is a no-op if the VM has been torn down and the bridge no longer exists). No-op when guest address is unset.
type MockNetworkInterfaceProvider ¶
type MockNetworkInterfaceProvider struct {
InterfacesFunc func() ([]net.Interface, error)
InterfaceAddrsFunc func(iface net.Interface) ([]net.Addr, error)
}
MockNetworkInterfaceProvider is a struct that simulates a network interface provider for testing purposes.
func NewMockNetworkInterfaceProvider ¶
func NewMockNetworkInterfaceProvider() *MockNetworkInterfaceProvider
NewMockNetworkInterfaceProvider creates a new instance of MockNetworkInterfaceProvider with default implementations.
func (*MockNetworkInterfaceProvider) InterfaceAddrs ¶
InterfaceAddrs calls the custom InterfaceAddrsFunc if provided.
func (*MockNetworkInterfaceProvider) Interfaces ¶
func (m *MockNetworkInterfaceProvider) Interfaces() ([]net.Interface, error)
Interfaces calls the custom InterfacesFunc if provided.
type MockNetworkManager ¶
type MockNetworkManager struct {
NetworkManager
ConfigureHostRouteFunc func() error
ConfigureGuestFunc func() error
ConfigureDNSFunc func() error
RevertHostRouteFunc func() error
RevertGuestFunc func() error
RevertDNSFunc func() error
FlushDNSFunc func() error
NeedsPrivilegeForClusterFunc func() bool
NeedsPrivilegeForDNSFunc func() bool
IsHostRouteInstalledFunc func() bool
IsResolverInstalledFunc func() bool
DNSChangedFunc func() bool
}
MockNetworkManager is a struct that simulates a network manager for testing purposes.
func NewMockNetworkManager ¶
func NewMockNetworkManager() *MockNetworkManager
NewMockNetworkManager creates a new instance of MockNetworkManager.
func (*MockNetworkManager) ConfigureDNS ¶
func (m *MockNetworkManager) ConfigureDNS() error
ConfigureDNS calls the custom ConfigureDNSFunc if provided.
func (*MockNetworkManager) ConfigureGuest ¶
func (m *MockNetworkManager) ConfigureGuest() error
ConfigureGuest calls the custom ConfigureGuestFunc if provided.
func (*MockNetworkManager) ConfigureHostRoute ¶
func (m *MockNetworkManager) ConfigureHostRoute() error
ConfigureHostRoute calls the custom ConfigureHostRouteFunc if provided.
func (*MockNetworkManager) DNSChanged ¶ added in v0.9.0
func (m *MockNetworkManager) DNSChanged() bool
DNSChanged calls the custom DNSChangedFunc if provided.
func (*MockNetworkManager) FlushDNS ¶ added in v0.9.0
func (m *MockNetworkManager) FlushDNS() error
FlushDNS calls the custom FlushDNSFunc if provided.
func (*MockNetworkManager) IsHostRouteInstalled ¶ added in v0.9.0
func (m *MockNetworkManager) IsHostRouteInstalled() bool
IsHostRouteInstalled calls the custom IsHostRouteInstalledFunc if provided.
func (*MockNetworkManager) IsResolverInstalled ¶ added in v0.9.0
func (m *MockNetworkManager) IsResolverInstalled() bool
IsResolverInstalled calls the custom IsResolverInstalledFunc if provided.
func (*MockNetworkManager) NeedsPrivilegeForCluster ¶ added in v0.9.0
func (m *MockNetworkManager) NeedsPrivilegeForCluster() bool
NeedsPrivilegeForCluster calls the custom NeedsPrivilegeForClusterFunc if provided.
func (*MockNetworkManager) NeedsPrivilegeForDNS ¶ added in v0.9.0
func (m *MockNetworkManager) NeedsPrivilegeForDNS() bool
NeedsPrivilegeForDNS calls the custom NeedsPrivilegeForDNSFunc if provided.
func (*MockNetworkManager) RevertDNS ¶ added in v0.9.0
func (m *MockNetworkManager) RevertDNS() error
RevertDNS calls the custom RevertDNSFunc if provided.
func (*MockNetworkManager) RevertGuest ¶ added in v0.9.0
func (m *MockNetworkManager) RevertGuest() error
RevertGuest calls the custom RevertGuestFunc if provided.
func (*MockNetworkManager) RevertHostRoute ¶ added in v0.9.0
func (m *MockNetworkManager) RevertHostRoute() error
RevertHostRoute calls the custom RevertHostRouteFunc if provided.
type NetworkInterfaceProvider ¶
type NetworkInterfaceProvider interface {
Interfaces() ([]net.Interface, error)
InterfaceAddrs(iface net.Interface) ([]net.Addr, error)
}
NetworkInterfaceProvider abstracts the system's network interface operations
func NewNetworkInterfaceProvider ¶
func NewNetworkInterfaceProvider() NetworkInterfaceProvider
NewNetworkInterfaceProvider creates a new real implementation of NetworkInterfaceProvider
type NetworkManager ¶
type NetworkManager interface {
ConfigureHostRoute() error
ConfigureGuest() error
ConfigureDNS() error
RevertHostRoute() error
RevertGuest() error
RevertDNS() error
FlushDNS() error
NeedsPrivilegeForCluster() bool
NeedsPrivilegeForDNS() bool
IsHostRouteInstalled() bool
IsResolverInstalled() bool
DNSChanged() bool
}
NetworkManager handles configuring the local development network. Guest address is read from config (workstation.address) where needed. Revert* counterparts undo Configure*, are idempotent (no-op when the resource is absent), and are invoked by 'windsor configure network --revert' and 'windsor down'. IsHostRouteInstalled / IsResolverInstalled answer the question "is the host state this manager would install currently present?" — used by 'windsor down' to detect orphaned host configuration when the operator can't elevate non-interactively, so a hint can point them at 'configure network --revert'.
type RealNetworkInterfaceProvider ¶
type RealNetworkInterfaceProvider struct{}
RealNetworkInterfaceProvider is the real implementation of NetworkInterfaceProvider
func (*RealNetworkInterfaceProvider) InterfaceAddrs ¶
InterfaceAddrs returns the addresses of a network interface
func (*RealNetworkInterfaceProvider) Interfaces ¶
func (p *RealNetworkInterfaceProvider) Interfaces() ([]net.Interface, error)
Interfaces returns the system's network interfaces
type Shims ¶
type Shims struct {
Goos func() string
Stat func(string) (os.FileInfo, error)
WriteFile func(string, []byte, os.FileMode) error
ReadFile func(string) ([]byte, error)
ReadLink func(string) (string, error)
MkdirAll func(string, os.FileMode) error
MkdirTemp func(dir, pattern string) (string, error)
RemoveAll func(string) error
Glob func(pattern string) ([]string, error)
}
Shims provides mockable wrappers around system and runtime functions