container

package
v0.0.0-...-036f8e8 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsMap

func AsMap(args ...interface{}) map[string]interface{}

AsMap convert multiple arguments into map[string]interface{}

func Containers

func Containers(containers ...types.Container) []types.Container

Containers list of containers

func DetailsResponse

func DetailsResponse(params map[string]interface{}) types.ContainerJSON

DetailsResponse mock container details response

func HTTPClient

func HTTPClient(daemonURL string, tlsConfig *tls.Config) (*http.Client, error)

HTTPClient create new http client to connect to the docker daemon

func ImageDetailsResponse

func ImageDetailsResponse(params map[string]interface{}) types.ImageInspect

ImageDetailsResponse mock image response

func Response

func Response(params map[string]interface{}) types.Container

Response mock single container

Types

type Client

type Client interface {
	ListContainers(context.Context, FilterFunc, ListOpts) ([]*Container, error)
	StopContainer(context.Context, *Container, int, bool) error
	KillContainer(context.Context, *Container, string, bool) error
	ExecContainer(context.Context, *Container, string, bool) error
	RestartContainer(context.Context, *Container, time.Duration, bool) error
	RemoveContainer(context.Context, *Container, bool, bool, bool, bool) error
	NetemContainer(context.Context, *Container, string, []string, []*net.IPNet, []string, []string, time.Duration, string, bool, bool) error
	StopNetemContainer(context.Context, *Container, string, []*net.IPNet, []string, []string, string, bool, bool) error
	PauseContainer(context.Context, *Container, bool) error
	UnpauseContainer(context.Context, *Container, bool) error
	StartContainer(context.Context, *Container, bool) error
	StressContainer(context.Context, *Container, []string, string, bool, time.Duration, bool) (string, <-chan string, <-chan error, error)
	StopContainerWithID(context.Context, string, time.Duration, bool) error
}

Client interface

func NewClient

func NewClient(dockerHost string, tlsConfig *tls.Config) (Client, error)

NewClient returns a new Client instance which can be used to interact with the Docker API.

type Container

type Container struct {
	ContainerInfo types.ContainerJSON
	ImageInfo     types.ImageInspect
}

Container represents a running Docker container.

func CreateLabeledTestContainers

func CreateLabeledTestContainers(count int, labels map[string]string) []*Container

CreateLabeledTestContainers generate test containers with labels

func CreateTestContainers

func CreateTestContainers(count int) []*Container

CreateTestContainers create test container

func ListNContainers

func ListNContainers(ctx context.Context, client Client, names []string, pattern string, labels []string, limit int) ([]*Container, error)

ListNContainers list containers up to specified limit

func RandomContainer

func RandomContainer(containers []*Container) *Container

RandomContainer select random container

func (*Container) ID

func (c *Container) ID() string

ID returns the Docker container ID.

func (*Container) ImageID

func (c *Container) ImageID() string

ImageID returns the ID of the Docker image that was used to start the container.

func (*Container) ImageName

func (c *Container) ImageName() string

ImageName returns the name of the Docker image that was used to start the container. If the original image was specified without a particular tag, the "latest" tag is assumed.

func (*Container) IsPumba

func (c *Container) IsPumba() bool

IsPumba returns a boolean flag indicating whether or not the current container is the Pumba container itself. The Pumba container is identified by the presence of the "com.gaiaadm.pumba" label in the container metadata.

func (*Container) IsPumbaSkip

func (c *Container) IsPumbaSkip() bool

IsPumbaSkip returns a boolean flag indicating whether or not the current container should be ignored by Pumba. This container is identified by the presence of the "com.gaiaadm.pumba.skip" label in the container metadata. Use it to skip monitoring and helper containers.

func (c *Container) Links() []string

Links returns a list containing the names of all the containers to which this container is linked.

func (*Container) Name

func (c *Container) Name() string

Name returns the Docker container name.

func (*Container) StopSignal

func (c *Container) StopSignal() string

StopSignal returns the custom stop signal (if any) that is encoded in the container's metadata. If the container has not specified a custom stop signal, the empty string "" is returned.

type FilterFunc

type FilterFunc func(*Container) bool

A FilterFunc is a prototype for a function that can be used to filter the results from a call to the ListContainers() method on the Client.

type ListOpts

type ListOpts struct {
	All    bool
	Labels []string
}

ListOpts list options

type MockClient

type MockClient struct {
	mock.Mock
}

MockClient is an autogenerated mock type for the Client type

func NewMockClient

func NewMockClient(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockClient

NewMockClient creates a new instance of MockClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockClient) ExecContainer

func (_m *MockClient) ExecContainer(_a0 context.Context, _a1 *Container, _a2 string, _a3 bool) error

ExecContainer provides a mock function with given fields: _a0, _a1, _a2, _a3

func (*MockClient) KillContainer

func (_m *MockClient) KillContainer(_a0 context.Context, _a1 *Container, _a2 string, _a3 bool) error

KillContainer provides a mock function with given fields: _a0, _a1, _a2, _a3

func (*MockClient) ListContainers

func (_m *MockClient) ListContainers(_a0 context.Context, _a1 FilterFunc, _a2 ListOpts) ([]*Container, error)

ListContainers provides a mock function with given fields: _a0, _a1, _a2

func (*MockClient) NetemContainer

func (_m *MockClient) NetemContainer(_a0 context.Context, _a1 *Container, _a2 string, _a3 []string, _a4 []*net.IPNet, _a5 []string, _a6 []string, _a7 time.Duration, _a8 string, _a9 bool, _a10 bool) error

NetemContainer provides a mock function with given fields: _a0, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8, _a9, _a10

func (*MockClient) PauseContainer

func (_m *MockClient) PauseContainer(_a0 context.Context, _a1 *Container, _a2 bool) error

PauseContainer provides a mock function with given fields: _a0, _a1, _a2

func (*MockClient) RemoveContainer

func (_m *MockClient) RemoveContainer(_a0 context.Context, _a1 *Container, _a2 bool, _a3 bool, _a4 bool, _a5 bool) error

RemoveContainer provides a mock function with given fields: _a0, _a1, _a2, _a3, _a4, _a5

func (*MockClient) RestartContainer

func (_m *MockClient) RestartContainer(_a0 context.Context, _a1 *Container, _a2 time.Duration, _a3 bool) error

RestartContainer provides a mock function with given fields: _a0, _a1, _a2, _a3

func (*MockClient) StartContainer

func (_m *MockClient) StartContainer(_a0 context.Context, _a1 *Container, _a2 bool) error

StartContainer provides a mock function with given fields: _a0, _a1, _a2

func (*MockClient) StopContainer

func (_m *MockClient) StopContainer(_a0 context.Context, _a1 *Container, _a2 int, _a3 bool) error

StopContainer provides a mock function with given fields: _a0, _a1, _a2, _a3

func (*MockClient) StopContainerWithID

func (_m *MockClient) StopContainerWithID(_a0 context.Context, _a1 string, _a2 time.Duration, _a3 bool) error

StopContainerWithID provides a mock function with given fields: _a0, _a1, _a2, _a3

func (*MockClient) StopNetemContainer

func (_m *MockClient) StopNetemContainer(_a0 context.Context, _a1 *Container, _a2 string, _a3 []*net.IPNet, _a4 []string, _a5 []string, _a6 string, _a7 bool, _a8 bool) error

StopNetemContainer provides a mock function with given fields: _a0, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8

func (*MockClient) StressContainer

func (_m *MockClient) StressContainer(_a0 context.Context, _a1 *Container, _a2 []string, _a3 string, _a4 bool, _a5 time.Duration, _a6 bool) (string, <-chan string, <-chan error, error)

StressContainer provides a mock function with given fields: _a0, _a1, _a2, _a3, _a4, _a5, _a6

func (*MockClient) UnpauseContainer

func (_m *MockClient) UnpauseContainer(_a0 context.Context, _a1 *Container, _a2 bool) error

UnpauseContainer provides a mock function with given fields: _a0, _a1, _a2

type MockFilterFunc

type MockFilterFunc struct {
	mock.Mock
}

MockFilterFunc is an autogenerated mock type for the FilterFunc type

func NewMockFilterFunc

func NewMockFilterFunc(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockFilterFunc

NewMockFilterFunc creates a new instance of MockFilterFunc. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockFilterFunc) Execute

func (_m *MockFilterFunc) Execute(_a0 *Container) bool

Execute provides a mock function with given fields: _a0

Jump to

Keyboard shortcuts

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