Documentation ¶
Index ¶
Constants ¶
const ( DomainRunning = "running" DomainNoState = "unknown" DomainBlocked = "blocked" DomainPaused = "paused" DomainShutdown = "shutdown" DomainCrashed = "crashed" DomainPMSuspended = "pmsuspended" DomainShutOff = "shutoff" )
Variables ¶
var ( ErrDomainExists = errors.New("the domain exists already") ErrDomainNotFound = errors.New("the domain does not exist") )
Functions ¶
Types ¶
type CloudInit ¶
TODO: Add function to test for correct cloudinit userdata syntax, and dont use it if it fails, throw a warning!
type ConnectMock ¶
type ConnectMock struct{}
ConnectMock is the primary mock interface that has default values for testing. It implements the ConnectShim interface.
func (*ConnectMock) ListNetworks ¶
func (cm *ConnectMock) ListNetworks() ([]string, error)
func (*ConnectMock) LookupNetworkByName ¶
func (cm *ConnectMock) LookupNetworkByName(name string) (ConnectNetworkShim, error)
type ConnectMockEmpty ¶
type ConnectMockEmpty struct{}
ConnectMockEmpty is a secondary mock that can be used to mimic a host where no libvirt networks or other resources are available. It implements the ConnectShim interface.
func (*ConnectMockEmpty) ListNetworks ¶
func (cme *ConnectMockEmpty) ListNetworks() ([]string, error)
func (*ConnectMockEmpty) LookupNetworkByName ¶
func (cme *ConnectMockEmpty) LookupNetworkByName(name string) (ConnectNetworkShim, error)
type ConnectNetworkMock ¶
type ConnectNetworkMock struct {
// contains filtered or unexported fields
}
ConnectNetworkMock implements the shim.Network interface for testing.
func (*ConnectNetworkMock) GetBridgeName ¶
func (cnm *ConnectNetworkMock) GetBridgeName() (string, error)
func (*ConnectNetworkMock) GetDHCPLeases ¶
func (cnm *ConnectNetworkMock) GetDHCPLeases() ([]libvirt.NetworkDHCPLease, error)
func (*ConnectNetworkMock) IsActive ¶
func (cnm *ConnectNetworkMock) IsActive() (bool, error)
type ConnectNetworkShim ¶
type ConnectNetworkShim interface { // IsActive returns whether the named network is active. // // Also see: // https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkIsActive IsActive() (bool, error) // GetBridgeName returns the bridge interface name assigned to the named // network. // // Also see: // https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetBridgeName GetBridgeName() (string, error) // GetDHCPLeases returns an array of DHCP leases for the named network. // // Also see: // https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetDHCPLeases GetDHCPLeases() ([]libvirt.NetworkDHCPLease, error) }
ConnectNetworkShim is the shim interface that wraps libvirt connectivity specific to a named network. This allows us to create a mock implementation for testing, as we cannot assume we will always have expensive bare-metal hosts to run CI, especially on a public repository. Functions should be added as required and match only those provided by libvirt.Network.
type ConnectShim ¶
type ConnectShim interface { // ListNetworks returns an array of network names. // // Also see: // https://libvirt.org/html/libvirt-libvirt-network.html#virConnectListNetworks ListNetworks() ([]string, error) // LookupNetworkByName returns a handle to the network object as defined by // the name argument. If the network is not found, an error will be // returned. // // Also see: // https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkLookupByName LookupNetworkByName(name string) (ConnectNetworkShim, error) }
ConnectShim is the shim interface that wraps libvirt connectivity. This allows us to create a mock implementation for testing, as we cannot assume we will always have expensive bare-metal hosts to run CI, especially on a public repository. Functions should be added as required and match only those provided by libvirt.Connect.
Each implementation should be lightweight and not include any business logic. This allows us to have more confidence in the mock behaving like the libvirt backend and avoid bugs due to differences.