drivermock

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package drivermock implements a mock driver. It should be used only in tests.

In particular, the driver implemented in this package uses mock images, whose status is not stored permanently. Image status, therefore, can vary between tests.

Index

Constants

This section is empty.

Variables

View Source
var DefaultNetCIDR = "192.168.125.0/24"

DefaultNetCIDR is the address range used by NAT networks.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

Driver implements the drivercore.Driver interface

func New

func New(drivername string, description string, usesNAT bool, usesNetworking bool) *Driver

New creates a new mock driver.

func (*Driver) DeleteMachine

func (vd *Driver) DeleteMachine(machinename string, clustername string) error

DeleteMachine deletes the specified machine.

func (*Driver) DeleteNetwork

func (vd *Driver) DeleteNetwork(clustername string) error

DeleteNetwork deletes a network.

func (*Driver) DeleteRemoteImage

func (vd *Driver) DeleteRemoteImage(k8sversion string)

DeleteRemoteImage deletes a mock remote image.

func (*Driver) Description

func (vd *Driver) Description() string

Description returns the driver description.

func (*Driver) Error

func (vd *Driver) Error() string

Error returns the last error returned by the driver, or an empty string.

func (*Driver) GetImage

func (vd *Driver) GetImage(k8sversion string) (drivercore.Image, error)

GetImage returns the image for the specified k8s version, or nil.

func (*Driver) GetMachine

func (vd *Driver) GetMachine(machinename string, clustername string) (drivercore.Machine, error)

GetMachine returns the specified machine, or an error.

func (*Driver) GetNetwork

func (vd *Driver) GetNetwork(clustername string) (drivercore.Network, error)

GetNetwork gets a network.

func (*Driver) K8sVersions

func (vd *Driver) K8sVersions() []string

K8sVersions lists locally available k8s versions.

func (*Driver) ListImages

func (vd *Driver) ListImages() ([]drivercore.Image, error)

ListImages returns the local images.

func (*Driver) ListMachines

func (vd *Driver) ListMachines() ([]drivercore.Machine, error)

ListMachines returns the list of machines.

func (*Driver) ListNetworks

func (vd *Driver) ListNetworks() ([]drivercore.Network, error)

ListNetworks gets a list of networks.

func (*Driver) Name

func (vd *Driver) Name() string

Name returns the driver name.

func (*Driver) NewMachine

func (vd *Driver) NewMachine(machinename string, clustername string, k8sversion string) (drivercore.Machine, error)

NewMachine creates a new machine.

func (*Driver) NewNetwork

func (vd *Driver) NewNetwork(clustername string) (drivercore.Network, error)

NewNetwork creates a network for a cluster.

func (*Driver) QualifiedMachineName

func (vd *Driver) QualifiedMachineName(machinename string, clustername string) string

QualifiedMachineName returns the driver-qualified machine name.

func (*Driver) QualifiedNetworkName

func (vd *Driver) QualifiedNetworkName(clustername string) string

QualifiedNetworkName adds a suffix to the specified cluster name.

func (*Driver) Status

func (vd *Driver) Status() string

Status returns the driver status.

func (*Driver) UpdateImageList

func (vd *Driver) UpdateImageList() error

UpdateImageList updates the image list

func (*Driver) UpdateRemoteImage

func (vd *Driver) UpdateRemoteImage(k8sversion string, deprecated bool)

UpdateRemoteImage adds or updates a mock remote image.

func (*Driver) UsesNATNetworking

func (vd *Driver) UsesNATNetworking() bool

UsesNATNetworking returns if this particular mock driver instance uses NAT networking

func (*Driver) UsesPerClusterNetworking added in v0.2.0

func (vd *Driver) UsesPerClusterNetworking() bool

UsesPerClusterNetworking returns if this particular mock driver instance uses per cluster networking

func (*Driver) ValidK8sVersion

func (vd *Driver) ValidK8sVersion(k8sversion string) bool

ValidK8sVersion returns true if the specified k8s version is available in localimages, false otherwise.

type Image

type Image struct {
	// contains filtered or unexported fields
}

Image implements the drivercore.Image interface.

func (*Image) Deprecated

func (img *Image) Deprecated() bool

Deprecated returns the deprecation status of the image.

func (*Image) Fetch

func (img *Image) Fetch() error

Fetch fetches an image.

func (*Image) FetchWithProgress added in v0.3.0

func (img *Image) FetchWithProgress(progress func(int64, int64)) error

FetchWithProgress downloads the image from the driver repository into the local cache, and reports progress via the supplied callback. The callback reports current and total in bytes.

func (*Image) FromFile

func (img *Image) FromFile(filepath string) error

FromFile fetches an image from a file.

func (*Image) K8sVersion

func (img *Image) K8sVersion() string

K8sVersion returns the k8s version of the image.

func (*Image) PurgeLocal

func (img *Image) PurgeLocal() error

PurgeLocal removes the local copy of an image.

func (*Image) Status

func (img *Image) Status() drivercore.ImageStatus

Status returns the status of the image.

type Machine

type Machine struct {
	// contains filtered or unexported fields
}

Machine implements the drivercore.Machine interface

func (*Machine) Error

func (vh *Machine) Error() string

Error returns the last error message returned by the machine, or an empty string.

func (*Machine) ExecuteCommand

func (vh *Machine) ExecuteCommand(command drivercore.PredefinedCommand, params ...string) error

ExecuteCommand executes a predefined command.

func (*Machine) ForceStop

func (vh *Machine) ForceStop() error

ForceStop forcibly stops the machine.

func (*Machine) ForwardPort

func (vh *Machine) ForwardPort(hostport int, machineport int) error

ForwardPort forwards a port.

func (*Machine) ForwardSSHPort

func (vh *Machine) ForwardSSHPort(hostport int) error

ForwardSSHPort forwards the SSH port.

func (*Machine) IPAddress

func (vh *Machine) IPAddress() string

IPAddress returns the IPv4 address of the machine.

func (*Machine) ImplementsCommand

func (vh *Machine) ImplementsCommand(command drivercore.PredefinedCommand) bool

ImplementsCommand returns true if a predefined command has been implemented, false otherwise.

func (*Machine) Name

func (vh *Machine) Name() string

Name returns the name of the machine.

func (*Machine) SSHAddress

func (vh *Machine) SSHAddress() string

SSHAddress returns the SSH address of the machine.

func (*Machine) Start

func (vh *Machine) Start() error

Start starts the machine.

func (*Machine) Status

func (vh *Machine) Status() drivercore.MachineStatus

Status returns the status of the machine.

func (*Machine) Stop

func (vh *Machine) Stop() error

Stop stops the machine.

func (*Machine) UnforwardPort

func (vh *Machine) UnforwardPort(machineport int) error

UnforwardPort unforwards a port.

func (*Machine) WaitForStateChange

func (vh *Machine) WaitForStateChange(timeoutinseconds int)

WaitForStateChange waits until the status of a machine has changed, or until timeout. In this mock, it just waits till 1/10th of timeout.

type Network

type Network struct {
	// contains filtered or unexported fields
}

Network implements the drivercore.Network interface

func (*Network) CIDR

func (vd *Network) CIDR() string

CIDR returns the CIDR of the network.

func (*Network) Name

func (vd *Network) Name() string

Name returns the driver-qualified name of the network.

func (*Network) SetCIDR

func (vd *Network) SetCIDR(cidr string)

SetCIDR has not been implemented for this mock.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL