runtime

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package runtime provides interfaces describing container runtimes in generic way and their functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config interface {
	// GetAddress should return the URL, which will be used for talking to container runtime.
	GetAddress() string

	// SetAddress allows to override, which URL will be used when talking to container runtime.
	SetAddress(string)

	// New validates container runtime and returns object, which can be used to create containers etc.
	New() (Runtime, error)
}

Config defines interface for runtime configuration. Since some feature are generic to runtime, this interface make sure that other parts of the system are compatible with it.

type Fake added in v0.2.0

type Fake struct {
	// CreateF will be Create by method.
	CreateF func(config *types.ContainerConfig) (string, error)

	// DeleteF will be called by Delete method.
	DeleteF func(id string) error

	// StartF will be called by Start method.
	StartF func(id string) error

	// StatusF will be called by Status method.
	StatusF func(id string) (types.ContainerStatus, error)

	// StopF will be called by Stop method.
	StopF func(id string) error

	// CopyF will be called by Copy method.
	CopyF func(id string, files []*types.File) error

	// ReadF will be called by Read method.
	ReadF func(id string, srcPath []string) ([]*types.File, error)

	// StatF will be called by Stat method.
	StatF func(id string, paths []string) (map[string]os.FileMode, error)
}

Fake is a fake runtime client, which can be used for testing.

func (Fake) Copy added in v0.2.0

func (f Fake) Copy(id string, files []*types.File) error

Copy mocks runtime Copy().

func (Fake) Create added in v0.2.0

func (f Fake) Create(config *types.ContainerConfig) (string, error)

Create mocks runtime Create().

func (Fake) Delete added in v0.2.0

func (f Fake) Delete(id string) error

Delete mocks runtime Delete().

func (Fake) Read added in v0.2.0

func (f Fake) Read(id string, srcPath []string) ([]*types.File, error)

Read mocks runtime Read().

func (Fake) Start added in v0.2.0

func (f Fake) Start(id string) error

Start mocks runtime Start().

func (Fake) Stat added in v0.2.0

func (f Fake) Stat(id string, paths []string) (map[string]os.FileMode, error)

Stat mocks runtime Stat().

func (Fake) Status added in v0.2.0

func (f Fake) Status(id string) (types.ContainerStatus, error)

Status mocks runtime Status().

func (Fake) Stop added in v0.2.0

func (f Fake) Stop(id string) error

Stop mocks runtime Stop().

type FakeConfig added in v0.2.0

type FakeConfig struct {
	// Runtime holds container runtime to return by New() method.
	Runtime Runtime

	// Address will be used for GetAddress and SetAddress methods.
	Address string
}

FakeConfig is a Fake runtime configuration struct.

func (FakeConfig) GetAddress added in v0.2.0

func (c FakeConfig) GetAddress() string

GetAddress implements runtime.Config interface.

func (FakeConfig) New added in v0.2.0

func (c FakeConfig) New() (Runtime, error)

New implements runtime.Config interface.

func (*FakeConfig) SetAddress added in v0.2.0

func (c *FakeConfig) SetAddress(a string)

SetAddress implements runtime.Config interface.

type Runtime

type Runtime interface {
	// Create creates container and returns it's unique identifier.
	Create(config *types.ContainerConfig) (string, error)

	// Delete removes the container.
	Delete(ID string) error

	// Start starts created container.
	Start(ID string) error

	// Status returns status of the container.
	Status(ID string) (types.ContainerStatus, error)

	// Stop takes unique identifier as a parameter and stops the container.
	Stop(ID string) error

	// Copy allows to copy TAR archive into the container.
	//
	// Docker currently does not allow to copy multiple files over https://github.com/moby/moby/issues/7710
	// It seems kubelet does https://github.com/kubernetes/kubernetes/pull/72641/files
	Copy(ID string, files []*types.File) error

	// Read allows to read file in TAR archive format from container.
	//
	// TODO check if we should return some information about read file
	Read(ID string, srcPath []string) ([]*types.File, error)

	// Stat returns os.FileMode for requested files from inside the container.
	Stat(ID string, paths []string) (map[string]os.FileMode, error)
}

Runtime interface describes universal way of managing containers across different container runtimes.

Directories

Path Synopsis
Package docker implements runtime.Interface and runtime.Config interfaces by talking to Docker API.
Package docker implements runtime.Interface and runtime.Config interfaces by talking to Docker API.

Jump to

Keyboard shortcuts

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