vcmock

package
v0.0.0-...-5cef3e7 Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: Apache-2.0, Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMockError

func IsMockError(err error) bool

IsMockError returns true if the specified error was generated by this package.

Types

type Container

type Container struct {
	MockID          string
	MockURL         string
	MockToken       string
	MockProcess     vc.Process
	MockPid         int
	MockSandbox     *Sandbox
	MockAnnotations map[string]string
}

Container is a fake Container type used for testing

func (*Container) GetAnnotations

func (c *Container) GetAnnotations() map[string]string

GetAnnotations implements the VCContainer function of the same name.

func (*Container) GetPid

func (c *Container) GetPid() int

GetPid implements the VCContainer function of the same name.

func (*Container) GetToken

func (c *Container) GetToken() string

GetToken implements the VCContainer function of the same name.

func (*Container) ID

func (c *Container) ID() string

ID implements the VCContainer function of the same name.

func (*Container) Process

func (c *Container) Process() vc.Process

Process implements the VCContainer function of the same name.

func (*Container) Sandbox

func (c *Container) Sandbox() vc.VCSandbox

Sandbox implements the VCContainer function of the same name.

type Sandbox

type Sandbox struct {
	MockID          string
	MockURL         string
	MockAnnotations map[string]string
	MockContainers  []*Container
	MockNetNs       string
}

Sandbox is a fake Sandbox type used for testing

func (*Sandbox) AddDevice

func (s *Sandbox) AddDevice(info config.DeviceInfo) (api.Device, error)

AddDevice adds a device to sandbox

func (*Sandbox) AddInterface

func (s *Sandbox) AddInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error)

AddInterface implements the VCSandbox function of the same name.

func (*Sandbox) Annotations

func (s *Sandbox) Annotations(key string) (string, error)

Annotations implements the VCSandbox function of the same name.

func (*Sandbox) CreateContainer

func (s *Sandbox) CreateContainer(conf vc.ContainerConfig) (vc.VCContainer, error)

CreateContainer implements the VCSandbox function of the same name.

func (*Sandbox) Delete

func (s *Sandbox) Delete() error

Delete implements the VCSandbox function of the same name.

func (*Sandbox) DeleteContainer

func (s *Sandbox) DeleteContainer(contID string) (vc.VCContainer, error)

DeleteContainer implements the VCSandbox function of the same name.

func (*Sandbox) EnterContainer

func (s *Sandbox) EnterContainer(containerID string, cmd types.Cmd) (vc.VCContainer, *vc.Process, error)

EnterContainer implements the VCSandbox function of the same name.

func (*Sandbox) GetAllContainers

func (s *Sandbox) GetAllContainers() []vc.VCContainer

GetAllContainers implements the VCSandbox function of the same name.

func (*Sandbox) GetAnnotations

func (s *Sandbox) GetAnnotations() map[string]string

GetAnnotations implements the VCSandbox function of the same name.

func (*Sandbox) GetContainer

func (s *Sandbox) GetContainer(containerID string) vc.VCContainer

GetContainer implements the VCSandbox function of the same name.

func (*Sandbox) GetNetNs

func (s *Sandbox) GetNetNs() string

GetNetNs returns the network namespace of the current sandbox.

func (*Sandbox) GetOOMEvent

func (s *Sandbox) GetOOMEvent() (string, error)

func (*Sandbox) ID

func (s *Sandbox) ID() string

ID implements the VCSandbox function of the same name.

func (*Sandbox) IOStream

func (s *Sandbox) IOStream(containerID, processID string) (io.WriteCloser, io.Reader, io.Reader, error)

IOStream implements the VCSandbox function of the same name.

func (*Sandbox) KillContainer

func (s *Sandbox) KillContainer(contID string, signal syscall.Signal, all bool) error

KillContainer implements the VCSandbox function of the same name.

func (*Sandbox) ListInterfaces

func (s *Sandbox) ListInterfaces() ([]*vcTypes.Interface, error)

ListInterfaces implements the VCSandbox function of the same name.

func (*Sandbox) ListRoutes

func (s *Sandbox) ListRoutes() ([]*vcTypes.Route, error)

ListRoutes implements the VCSandbox function of the same name.

func (*Sandbox) Monitor

func (s *Sandbox) Monitor() (chan error, error)

Monitor implements the VCSandbox function of the same name.

func (*Sandbox) Pause

func (s *Sandbox) Pause() error

Pause implements the VCSandbox function of the same name.

func (*Sandbox) PauseContainer

func (s *Sandbox) PauseContainer(contID string) error

PauseContainer implements the VCSandbox function of the same name.

func (*Sandbox) ProcessListContainer

func (s *Sandbox) ProcessListContainer(containerID string, options vc.ProcessListOptions) (vc.ProcessList, error)

ProcessListContainer implements the VCSandbox function of the same name.

func (*Sandbox) Release

func (s *Sandbox) Release() error

Release implements the VCSandbox function of the same name.

func (*Sandbox) RemoveInterface

func (s *Sandbox) RemoveInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error)

RemoveInterface implements the VCSandbox function of the same name.

func (*Sandbox) Resume

func (s *Sandbox) Resume() error

Resume implements the VCSandbox function of the same name.

func (*Sandbox) ResumeContainer

func (s *Sandbox) ResumeContainer(contID string) error

ResumeContainer implements the VCSandbox function of the same name.

func (*Sandbox) SetAnnotations

func (s *Sandbox) SetAnnotations(annotations map[string]string) error

SetAnnotations implements the VCSandbox function of the same name.

func (*Sandbox) SignalProcess

func (s *Sandbox) SignalProcess(containerID, processID string, signal syscall.Signal, all bool) error

SignalProcess implements the VCSandbox function of the same name.

func (*Sandbox) Start

func (s *Sandbox) Start() error

Start implements the VCSandbox function of the same name.

func (*Sandbox) StartContainer

func (s *Sandbox) StartContainer(contID string) (vc.VCContainer, error)

StartContainer implements the VCSandbox function of the same name.

func (*Sandbox) StatsContainer

func (s *Sandbox) StatsContainer(contID string) (vc.ContainerStats, error)

StatsContainer implements the VCSandbox function of the same name.

func (*Sandbox) Status

func (s *Sandbox) Status() vc.SandboxStatus

Status implements the VCSandbox function of the same name.

func (*Sandbox) StatusContainer

func (s *Sandbox) StatusContainer(contID string) (vc.ContainerStatus, error)

StatusContainer implements the VCSandbox function of the same name.

func (*Sandbox) Stop

func (s *Sandbox) Stop(force bool) error

Stop implements the VCSandbox function of the same name.

func (*Sandbox) StopContainer

func (s *Sandbox) StopContainer(contID string, force bool) (vc.VCContainer, error)

StopContainer implements the VCSandbox function of the same name.

func (*Sandbox) UpdateContainer

func (s *Sandbox) UpdateContainer(containerID string, resources specs.LinuxResources) error

UpdateContainer implements the VCSandbox function of the same name.

func (*Sandbox) UpdateRoutes

func (s *Sandbox) UpdateRoutes(routes []*vcTypes.Route) ([]*vcTypes.Route, error)

UpdateRoutes implements the VCSandbox function of the same name.

func (*Sandbox) WaitProcess

func (s *Sandbox) WaitProcess(containerID, processID string) (int32, error)

WaitProcess implements the VCSandbox function of the same name.

func (*Sandbox) WinsizeProcess

func (s *Sandbox) WinsizeProcess(containerID, processID string, height, width uint32) error

WinsizeProcess implements the VCSandbox function of the same name.

type VCMock

type VCMock struct {
	SetLoggerFunc  func(ctx context.Context, logger *logrus.Entry)
	SetFactoryFunc func(ctx context.Context, factory vc.Factory)

	CreateSandboxFunc  func(ctx context.Context, sandboxConfig vc.SandboxConfig) (vc.VCSandbox, error)
	DeleteSandboxFunc  func(ctx context.Context, sandboxID string) (vc.VCSandbox, error)
	ListSandboxFunc    func(ctx context.Context) ([]vc.SandboxStatus, error)
	FetchSandboxFunc   func(ctx context.Context, sandboxID string) (vc.VCSandbox, error)
	RunSandboxFunc     func(ctx context.Context, sandboxConfig vc.SandboxConfig) (vc.VCSandbox, error)
	StartSandboxFunc   func(ctx context.Context, sandboxID string) (vc.VCSandbox, error)
	StatusSandboxFunc  func(ctx context.Context, sandboxID string) (vc.SandboxStatus, error)
	StatsContainerFunc func(ctx context.Context, sandboxID, containerID string) (vc.ContainerStats, error)
	StatsSandboxFunc   func(ctx context.Context, sandboxID string) (vc.SandboxStats, []vc.ContainerStats, error)
	StopSandboxFunc    func(ctx context.Context, sandboxID string, force bool) (vc.VCSandbox, error)

	CreateContainerFunc      func(ctx context.Context, sandboxID string, containerConfig vc.ContainerConfig) (vc.VCSandbox, vc.VCContainer, error)
	DeleteContainerFunc      func(ctx context.Context, sandboxID, containerID string) (vc.VCContainer, error)
	EnterContainerFunc       func(ctx context.Context, sandboxID, containerID string, cmd types.Cmd) (vc.VCSandbox, vc.VCContainer, *vc.Process, error)
	KillContainerFunc        func(ctx context.Context, sandboxID, containerID string, signal syscall.Signal, all bool) error
	StartContainerFunc       func(ctx context.Context, sandboxID, containerID string) (vc.VCContainer, error)
	StatusContainerFunc      func(ctx context.Context, sandboxID, containerID string) (vc.ContainerStatus, error)
	StopContainerFunc        func(ctx context.Context, sandboxID, containerID string) (vc.VCContainer, error)
	ProcessListContainerFunc func(ctx context.Context, sandboxID, containerID string, options vc.ProcessListOptions) (vc.ProcessList, error)
	UpdateContainerFunc      func(ctx context.Context, sandboxID, containerID string, resources specs.LinuxResources) error
	PauseContainerFunc       func(ctx context.Context, sandboxID, containerID string) error
	ResumeContainerFunc      func(ctx context.Context, sandboxID, containerID string) error

	AddDeviceFunc func(ctx context.Context, sandboxID string, info config.DeviceInfo) (api.Device, error)

	AddInterfaceFunc     func(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error)
	RemoveInterfaceFunc  func(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error)
	ListInterfacesFunc   func(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error)
	UpdateRoutesFunc     func(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error)
	ListRoutesFunc       func(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error)
	CleanupContainerFunc func(ctx context.Context, sandboxID, containerID string, force bool) error
}

VCMock is a type that provides an implementation of the VC interface. It is used for testing.

func (*VCMock) AddDevice

func (m *VCMock) AddDevice(ctx context.Context, sandboxID string, info config.DeviceInfo) (api.Device, error)

AddDevice implements the VC function of the same name.

func (*VCMock) AddInterface

func (m *VCMock) AddInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error)

AddInterface implements the VC function of the same name.

func (*VCMock) CleanupContainer

func (m *VCMock) CleanupContainer(ctx context.Context, sandboxID, containerID string, force bool) error

func (*VCMock) CreateContainer

func (m *VCMock) CreateContainer(ctx context.Context, sandboxID string, containerConfig vc.ContainerConfig) (vc.VCSandbox, vc.VCContainer, error)

CreateContainer implements the VC function of the same name.

func (*VCMock) CreateSandbox

func (m *VCMock) CreateSandbox(ctx context.Context, sandboxConfig vc.SandboxConfig) (vc.VCSandbox, error)

CreateSandbox implements the VC function of the same name.

func (*VCMock) DeleteContainer

func (m *VCMock) DeleteContainer(ctx context.Context, sandboxID, containerID string) (vc.VCContainer, error)

DeleteContainer implements the VC function of the same name.

func (*VCMock) DeleteSandbox

func (m *VCMock) DeleteSandbox(ctx context.Context, sandboxID string) (vc.VCSandbox, error)

DeleteSandbox implements the VC function of the same name.

func (*VCMock) EnterContainer

func (m *VCMock) EnterContainer(ctx context.Context, sandboxID, containerID string, cmd types.Cmd) (vc.VCSandbox, vc.VCContainer, *vc.Process, error)

EnterContainer implements the VC function of the same name.

func (*VCMock) FetchSandbox

func (m *VCMock) FetchSandbox(ctx context.Context, sandboxID string) (vc.VCSandbox, error)

FetchSandbox implements the VC function of the same name.

func (*VCMock) KillContainer

func (m *VCMock) KillContainer(ctx context.Context, sandboxID, containerID string, signal syscall.Signal, all bool) error

KillContainer implements the VC function of the same name.

func (*VCMock) ListInterfaces

func (m *VCMock) ListInterfaces(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error)

ListInterfaces implements the VC function of the same name.

func (*VCMock) ListRoutes

func (m *VCMock) ListRoutes(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error)

ListRoutes implements the VC function of the same name.

func (*VCMock) ListSandbox

func (m *VCMock) ListSandbox(ctx context.Context) ([]vc.SandboxStatus, error)

ListSandbox implements the VC function of the same name.

func (*VCMock) PauseContainer

func (m *VCMock) PauseContainer(ctx context.Context, sandboxID, containerID string) error

PauseContainer implements the VC function of the same name.

func (*VCMock) ProcessListContainer

func (m *VCMock) ProcessListContainer(ctx context.Context, sandboxID, containerID string, options vc.ProcessListOptions) (vc.ProcessList, error)

ProcessListContainer implements the VC function of the same name.

func (*VCMock) RemoveInterface

func (m *VCMock) RemoveInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error)

RemoveInterface implements the VC function of the same name.

func (*VCMock) ResumeContainer

func (m *VCMock) ResumeContainer(ctx context.Context, sandboxID, containerID string) error

ResumeContainer implements the VC function of the same name.

func (*VCMock) RunSandbox

func (m *VCMock) RunSandbox(ctx context.Context, sandboxConfig vc.SandboxConfig) (vc.VCSandbox, error)

RunSandbox implements the VC function of the same name.

func (*VCMock) SetFactory

func (m *VCMock) SetFactory(ctx context.Context, factory vc.Factory)

SetFactory implements the VC function of the same name.

func (*VCMock) SetLogger

func (m *VCMock) SetLogger(ctx context.Context, logger *logrus.Entry)

SetLogger implements the VC function of the same name.

func (*VCMock) StartContainer

func (m *VCMock) StartContainer(ctx context.Context, sandboxID, containerID string) (vc.VCContainer, error)

StartContainer implements the VC function of the same name.

func (*VCMock) StartSandbox

func (m *VCMock) StartSandbox(ctx context.Context, sandboxID string) (vc.VCSandbox, error)

StartSandbox implements the VC function of the same name.

func (*VCMock) StatsContainer

func (m *VCMock) StatsContainer(ctx context.Context, sandboxID, containerID string) (vc.ContainerStats, error)

StatsContainer implements the VC function of the same name.

func (*VCMock) StatsSandbox

func (m *VCMock) StatsSandbox(ctx context.Context, sandboxID string) (vc.SandboxStats, []vc.ContainerStats, error)

StatsSandbox implements the VC function of the same name.

func (*VCMock) StatusContainer

func (m *VCMock) StatusContainer(ctx context.Context, sandboxID, containerID string) (vc.ContainerStatus, error)

StatusContainer implements the VC function of the same name.

func (*VCMock) StatusSandbox

func (m *VCMock) StatusSandbox(ctx context.Context, sandboxID string) (vc.SandboxStatus, error)

StatusSandbox implements the VC function of the same name.

func (*VCMock) StopContainer

func (m *VCMock) StopContainer(ctx context.Context, sandboxID, containerID string) (vc.VCContainer, error)

StopContainer implements the VC function of the same name.

func (*VCMock) StopSandbox

func (m *VCMock) StopSandbox(ctx context.Context, sandboxID string, force bool) (vc.VCSandbox, error)

StopSandbox implements the VC function of the same name.

func (*VCMock) UpdateContainer

func (m *VCMock) UpdateContainer(ctx context.Context, sandboxID, containerID string, resources specs.LinuxResources) error

UpdateContainer implements the VC function of the same name.

func (*VCMock) UpdateRoutes

func (m *VCMock) UpdateRoutes(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error)

UpdateRoutes implements the VC function of the same name.

Jump to

Keyboard shortcuts

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