compat

package
v0.0.0-...-c095839 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvContainerEndpoint = "CONTAINER_ENDPOINT"
	DefaultBasePath      = ""
	DefaultNetworkDriver = "bridge"
)

Variables

This section is empty.

Functions

func FromCreatedVolume

func FromCreatedVolume(created *volumes_compat.VolumeCreateCreated) *container.Volume

func FromInspectVolume

func FromInspectVolume(volumeInspect *volumes_compat.VolumeInspectOK) *container.Volume

func FromVolumeList

func FromVolumeList(volumesList *models.VolumeListOKBody) []*container.Volume

func GetDefaultContainerEndpoint

func GetDefaultContainerEndpoint() string

func ReadResponse

func ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error)

func ToNetworkInfo

func ToNetworkInfo(network *models.NetworkResource) *container.Network

func ToNetworkInfoList

func ToNetworkInfoList(networks []*models.NetworkResource) []*container.Network

func ToVolumeCreate

func ToVolumeCreate(volume *container.Volume) *models.DockerVolumeCreate

Types

type APIError

type APIError struct {
	// API root cause formatted for automated parsing
	// Example: API root cause
	Because string `json:"cause,omitempty"`

	// human error message, formatted for a human to read
	// Example: human error message
	Message string `json:"message,omitempty"`

	// http response code
	ResponseCode int64 `json:"response,omitempty"`
}

func ToAPIError

func ToAPIError(err interface{}) *APIError

func (*APIError) Error

func (a *APIError) Error() string

type CompatClient

type CompatClient struct {
	RestClient runtime.ClientTransport
	// contains filtered or unexported fields
}

func NewCompatClient

func NewCompatClient(endpoint, basePath string) (*CompatClient, error)

func NewCompatClientMock

func NewCompatClientMock(containers []*container.Container) *CompatClient

func (*CompatClient) ContainerCreate

func (c *CompatClient) ContainerCreate(container *container.Container) error

func (*CompatClient) ContainerExec

func (c *CompatClient) ContainerExec(id string, command []string) (string, error)

func (*CompatClient) ContainerInspect

func (c *CompatClient) ContainerInspect(id string) (*container.Container, error)

func (*CompatClient) ContainerList

func (c *CompatClient) ContainerList() ([]*container.Container, error)

func (*CompatClient) ContainerLogs

func (c *CompatClient) ContainerLogs(id string) (string, error)

func (*CompatClient) ContainerRemove

func (c *CompatClient) ContainerRemove(name string) error

func (*CompatClient) ContainerRename

func (c *CompatClient) ContainerRename(currentName, newName string) error

func (*CompatClient) ContainerRestart

func (c *CompatClient) ContainerRestart(name string) error

func (*CompatClient) ContainerStart

func (c *CompatClient) ContainerStart(name string) error

func (*CompatClient) ContainerStop

func (c *CompatClient) ContainerStop(name string) error

func (*CompatClient) ContainerUpdate

func (c *CompatClient) ContainerUpdate(name string, fn func(newContainer *container.Container)) (*container.Container, error)

ContainerUpdate replaces the container (by name) with an identical copy with an applied Customization (required). To achieve that, it follows this procedure: - Create a new container - Stop current container - Rename current container - Rename the new container (replacing the original one) - Starts the new container - Removes the original container

In case of failures during this process, the original container is restored.

func (*CompatClient) ContainerUpdateImage

func (c *CompatClient) ContainerUpdateImage(ctx context.Context, name string, newImage string) (*container.Container, error)

ContainerUpdateImage updates the image used by the given container (name).

func (*CompatClient) GetEndpoint

func (c *CompatClient) GetEndpoint() string

func (*CompatClient) ImageInspect

func (c *CompatClient) ImageInspect(id string) (*container.Image, error)

func (*CompatClient) ImageList

func (c *CompatClient) ImageList() ([]*container.Image, error)

func (*CompatClient) ImagePull

func (c *CompatClient) ImagePull(ctx context.Context, id string) error

func (*CompatClient) IsSockEndpoint

func (c *CompatClient) IsSockEndpoint() bool

func (*CompatClient) NetworkConnect

func (c *CompatClient) NetworkConnect(id, container string, aliases ...string) error

func (*CompatClient) NetworkCreate

func (c *CompatClient) NetworkCreate(network *container.Network) (*container.Network, error)

func (*CompatClient) NetworkDisconnect

func (c *CompatClient) NetworkDisconnect(id, container string) error

func (*CompatClient) NetworkInspect

func (c *CompatClient) NetworkInspect(id string) (*container.Network, error)

func (*CompatClient) NetworkList

func (c *CompatClient) NetworkList() ([]*container.Network, error)

func (*CompatClient) NetworkRemove

func (c *CompatClient) NetworkRemove(id string) error

func (*CompatClient) ResponseIDReader

func (c *CompatClient) ResponseIDReader(httpClient *runtime.ClientOperation)

func (*CompatClient) ToSpecGenerator

func (c *CompatClient) ToSpecGenerator(newContainer *container.Container) *models.CreateContainerConfig

func (*CompatClient) Validate

func (c *CompatClient) Validate() (*container.Version, error)

func (*CompatClient) Version

func (c *CompatClient) Version() (*container.Version, error)

func (*CompatClient) VolumeCreate

func (c *CompatClient) VolumeCreate(volume *container.Volume) (*container.Volume, error)

func (*CompatClient) VolumeInspect

func (c *CompatClient) VolumeInspect(id string) (*container.Volume, error)

func (*CompatClient) VolumeList

func (c *CompatClient) VolumeList() ([]*container.Volume, error)

func (*CompatClient) VolumeRemove

func (c *CompatClient) VolumeRemove(id string) error

type ContainerEngine

type ContainerEngine string
var (
	ContainerEnginePodman ContainerEngine = "podman"
	ContainerEngineDocker ContainerEngine = "docker"
)

type Error

type Error struct {
	Recommendation string
	Err            error
}

func (*Error) Error

func (e *Error) Error() string

type IdGetter

type IdGetter func() int

type NetworkConnectReader

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

func (*NetworkConnectReader) ReadResponse

func (o *NetworkConnectReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error)

ReadResponse reads a server response into the received o.

type RestClientMock

type RestClientMock struct {
	Containers []*container.Container
	Images     []*container.Image

	Volumes      map[string]*container.Volume
	VolumesFiles map[string]map[string]string

	ErrorHook func(operation *runtime.ClientOperation) error
	// contains filtered or unexported fields
}

RestClientMock maintains (in memory) a set of containers and volumes that are manipulated through compat client. It also maintains a set of volume files (in disk) to mock podman volumes. The optional ErrorHook can be set by tests to modify the behavior of certain operations before they are actually performed by the mock implementation.

func (*RestClientMock) CleanupMockVolumeDir

func (r *RestClientMock) CleanupMockVolumeDir() error

func (*RestClientMock) HandleContainerCreate

func (r *RestClientMock) HandleContainerCreate(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (*containers_compat.ContainerCreateCreated, error)

func (*RestClientMock) HandleContainerDelete

func (r *RestClientMock) HandleContainerDelete(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (interface{}, error)

func (*RestClientMock) HandleContainerInspect

func (r *RestClientMock) HandleContainerInspect(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (*containers_compat.ContainerInspectOK, error)

func (*RestClientMock) HandleContainerList

func (r *RestClientMock) HandleContainerList(operation *runtime.ClientOperation, errorHook func(operation *runtime.ClientOperation) error) (*containers_compat.ContainerListOK, error)

func (*RestClientMock) HandleContainerRename

func (r *RestClientMock) HandleContainerRename(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (*containers_compat.ContainerRenameNoContent, error)

func (*RestClientMock) HandleContainerStart

func (r *RestClientMock) HandleContainerStart(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (interface{}, error)

func (*RestClientMock) HandleContainerStop

func (r *RestClientMock) HandleContainerStop(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (interface{}, error)

func (*RestClientMock) HandleImageCreate

func (r *RestClientMock) HandleImageCreate(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (interface{}, error)

func (*RestClientMock) HandleImageList

func (r *RestClientMock) HandleImageList(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (interface{}, error)

func (*RestClientMock) HandleNetworkCreate

func (r *RestClientMock) HandleNetworkCreate(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (interface{}, error)

func (*RestClientMock) HandleNetworkDelete

func (r *RestClientMock) HandleNetworkDelete(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (interface{}, error)

func (*RestClientMock) HandleNetworkInspect

func (r *RestClientMock) HandleNetworkInspect(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (interface{}, error)

func (*RestClientMock) HandleSystemInfo

func (r *RestClientMock) HandleSystemInfo(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (interface{}, error)

func (*RestClientMock) HandleVolumeCreate

func (r *RestClientMock) HandleVolumeCreate(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (interface{}, error)

func (*RestClientMock) HandleVolumeDelete

func (r *RestClientMock) HandleVolumeDelete(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (interface{}, error)

func (*RestClientMock) HandleVolumeInspect

func (r *RestClientMock) HandleVolumeInspect(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (interface{}, error)

func (*RestClientMock) HandleVolumeList

func (r *RestClientMock) HandleVolumeList(operation *runtime.ClientOperation, hook func(operation *runtime.ClientOperation) error) (interface{}, error)

func (*RestClientMock) MockVolumeFiles

func (r *RestClientMock) MockVolumeFiles(volumes map[string]*container.Volume, volumesFiles map[string]map[string]string) error

func (*RestClientMock) Submit

func (r *RestClientMock) Submit(operation *runtime.ClientOperation) (interface{}, error)

type VolumeListReader

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

func (*VolumeListReader) ReadResponse

func (o *VolumeListReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error)

ReadResponse reads a server response into the received o.

Jump to

Keyboard shortcuts

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