container

package
v0.0.0-...-1fcb79c Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableImages

func AvailableImages() []string

AvailableImages returns a list of available images

func IsConnectedToDocker

func IsConnectedToDocker() bool

IsConnectedToDocker returns if we are connected to the docker daemon

func New

func New() error

New initializes the container module

Types

type Event

type Event struct {
	Type EventType
	Self *LaunchableContainer
	Data interface{}
}

Event contains a container event

type EventType

type EventType int

EventType is the type of a container event

const (
	// ImagePullStatusChanged means that the pull status or progress changed
	ImagePullStatusChanged EventType = iota
	// StateChanged means that the ContainerState changed
	StateChanged
	// ConsoleOutput means that there was some console output by the container
	ConsoleOutput
	// LogMessage means there was some important log from docker
	LogMessage
	// ErrorMessage means there was some error log from docker
	ErrorMessage
)

type ImagePullProgressDetails

type ImagePullProgressDetails struct {
	Current int `json:"current"`
	Total   int `json:"total"`
}

ImagePullProgressDetails contains details of an ongoing pull

type ImagePullStatus

type ImagePullStatus struct {
	ID             string                    `json:"id"`
	Status         string                    `json:"status"`
	Progress       string                    `json:"progress"`
	ProgressDetail *ImagePullProgressDetails `json:"progressDetail"`
}

ImagePullStatus contains the status of an ongoing pull

type LaunchableContainer

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

LaunchableContainer is a container which can be launched by this launcher

func NewSasmContainer

func NewSasmContainer(image string) (*LaunchableContainer, error)

NewSasmContainer creates a new launchable sasm container image can be of: - sasm-docker-alpine-32 - sasm-docker-alpine-64

func (*LaunchableContainer) Attach

func (c *LaunchableContainer) Attach() error

Attach attaches the log listener to the container

func (*LaunchableContainer) ImageExists

func (c *LaunchableContainer) ImageExists() (bool, error)

ImageExists checks if the image exists

func (*LaunchableContainer) Launch

func (c *LaunchableContainer) Launch() error

Launch launches the container

func (*LaunchableContainer) OnContainerEvent

func (c *LaunchableContainer) OnContainerEvent(callback OnContainerEventFuc)

OnContainerEvent allows to register a callback function

func (*LaunchableContainer) Pull

func (c *LaunchableContainer) Pull() error

Pull pulls the container

func (*LaunchableContainer) Remove

func (c *LaunchableContainer) Remove() error

Remove removes the container

func (*LaunchableContainer) Start

func (c *LaunchableContainer) Start() error

Start starts the container

func (*LaunchableContainer) StateString

func (c *LaunchableContainer) StateString() string

StateString returns the current container state as a string

func (*LaunchableContainer) Stop

func (c *LaunchableContainer) Stop() error

Stop stops the container

func (*LaunchableContainer) WaitForDockerDaemon

func (c *LaunchableContainer) WaitForDockerDaemon() error

WaitForDockerDaemon trys to connect to the docker daemon 12 times in a 5 second interval before giving up.

type OnContainerEventFuc

type OnContainerEventFuc func(event Event)

OnContainerEventFuc is the type of a callback function which gets called on every container event

type State

type State int

State is the state of a container

const (
	// OfflineState means the container is offline
	OfflineState State = iota
	// LaunchingState is the state in between offline and pulling and pulling an starting state
	LaunchingState
	// PullingState means the container image is being pulled
	PullingState
	// StartingState means the container is starting
	StartingState
	// RunningState means the container is running
	RunningState
	// StoppingState means the container is stopping
	StoppingState
)

Jump to

Keyboard shortcuts

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