Documentation
¶
Index ¶
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) AssignIPs ¶
func (n *BaseNetworkManager) AssignIPs(serviceList []services.Service) error
AssignIPs sorts services and assigns IPs based on network CIDR. Services are passed explicitly from Workstation to ensure we work with the same instances.
func (*BaseNetworkManager) ConfigureDNS ¶
func (n *BaseNetworkManager) ConfigureDNS() error
ConfigureDNS sets up DNS by modifying system files to route DNS queries. It creates a resolver file for a specified DNS IP. The function ensures that the necessary directories exist, writes the resolver file, and flushes the DNS cache to apply changes. The function maintains idempotency by checking if the resolver file already exists with the correct content, ensuring that no unnecessary changes are made.
func (*BaseNetworkManager) ConfigureGuest ¶
func (n *BaseNetworkManager) ConfigureGuest() error
ConfigureGuest sets up the guest VM network
func (*BaseNetworkManager) ConfigureHostRoute ¶
func (n *BaseNetworkManager) ConfigureHostRoute() error
ConfigureHostRoute ensures that a network route from the host to the VM guest is established. It first checks if a route for the specified network CIDR already exists with the guest IP as the gateway. If the route does not exist, it adds a new route using elevated permissions to facilitate communication between the host and the guest VM.
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, sshClient ssh.Client, secureShell shell.Shell, networkInterfaceProvider NetworkInterfaceProvider) *ColimaNetworkManager
NewColimaNetworkManager creates a new ColimaNetworkManager
func (*ColimaNetworkManager) ConfigureGuest ¶
func (n *ColimaNetworkManager) ConfigureGuest() error
ConfigureGuest sets up forwarding of guest traffic to the container network. It retrieves network CIDR and guest IP from the config, and configures SSH. It identifies the Docker bridge interface and ensures iptables rules are set. If the rule doesn't exist, it adds a new one to allow traffic forwarding.
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
AssignIPsFunc func([]services.Service) error
ConfigureHostRouteFunc func() error
ConfigureGuestFunc func() error
ConfigureDNSFunc func() error
}
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) AssignIPs ¶
func (m *MockNetworkManager) AssignIPs(services []services.Service) error
AssignIPs calls the custom AssignIPsFunc if provided.
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.
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 {
AssignIPs(services []services.Service) error
ConfigureHostRoute() error
ConfigureGuest() error
ConfigureDNS() error
}
NetworkManager handles configuring the local development network
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
}
Shims provides mockable wrappers around system and runtime functions