runtime

package
v0.0.0-...-8a215a2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrTypeFailedInteractionWithDockerDaemon = "FailedInteractionWithDockerDaemon"
)
View Source
const NetworkDaemonName = "network"

Variables

View Source
var (
	ErrContainterCannotStart  = errors.New("cannot start the container")
	ErrCommandFailedToExecute = errors.New("command existed with error code")
)

Functions

func Sync

func Sync(state *record.ApplicationRecord)

Syncs the network and ensures that all required containers are running to maintain the application state.

func TrySelectOneContainer

func TrySelectOneContainer(
	application string,
	labels ...Label,
) (optional.Optional[Container], error)

Types

type BasicFileContent

type BasicFileContent struct {
	Path    string
	Content []byte
}

func (*BasicFileContent) FileContent

func (self *BasicFileContent) FileContent() []byte

func (*BasicFileContent) FilePath

func (self *BasicFileContent) FilePath() string

type CmdResult

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

type Container

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

func CreateNewContainer

func CreateNewContainer(
	application string,
	options ...ContainerOption,
) (*Container, error)

func SelectAllNonApplicationContainers

func SelectAllNonApplicationContainers(
	application string,
) ([]*Container, error)

func (*Container) CopyInto

func (self *Container) CopyInto(files ...FileContent) error

func (*Container) EnsurePathExists

func (self *Container) EnsurePathExists(path string) error

func (*Container) Equal

func (self *Container) Equal(other *Container) bool

func (*Container) ExitsPath

func (self *Container) ExitsPath(path string) (bool, error)

func (*Container) Image

func (self *Container) Image() string

Returns the image name of the running container

func (*Container) Inspect

func (self *Container) Inspect() (container.InspectResponse, error)

func (*Container) IsRunning

func (self *Container) IsRunning() (bool, error)

func (*Container) ReadFile

func (self *Container) ReadFile(path string) (string, error)

func (*Container) Shutdown

func (self *Container) Shutdown() error

func (*Container) String

func (self *Container) String() string

type ContainerConfig

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

type ContainerOption

type ContainerOption func(cfg *ContainerConfig)

func WithCmd

func WithCmd(cmd ...string) ContainerOption

func WithConnectedToNetwork

func WithConnectedToNetwork(nt *Network) ContainerOption

func WithCopyIntoBeforeStart

func WithCopyIntoBeforeStart(file FileContent) ContainerOption

func WithExposeTcpPort

func WithExposeTcpPort(hostPort string, containerPort string) ContainerOption

func WithImage

func WithImage(img string) ContainerOption

func WithLabels

func WithLabels(labels ...Label) ContainerOption

func WithMount

func WithMount(hostMount string, containerMount string) ContainerOption

func WithPulling

func WithPulling() ContainerOption

type ContainerOptions

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

func NewContainerOptions

func NewContainerOptions() *ContainerOptions

func (*ContainerOptions) Add

func (self *ContainerOptions) Add(options ...ContainerOption)

func (*ContainerOptions) Build

func (self *ContainerOptions) Build(
	application string,
) (*Container, error)

type FileContent

type FileContent interface {
	FilePath() string
	FileContent() []byte
}

type Label

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

func ApplicationNameLabel

func ApplicationNameLabel(name string) Label

zeus.application.name={name}

func ObjectImageLabel

func ObjectImageLabel(image string) Label

zeus.object.image={image}

func ObjectTypeLabel

func ObjectTypeLabel(object ObjectLabel) Label

zeus.object.type={object}

type Network

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

func CreateNewNetwork

func CreateNewNetwork(
	application string,
) (*Network, error)

Interact with the docker daemon and initialises a new network. Additionally start a DNS sever inside the network.

The network gets labeled with:

  • zeus.object.type=network
  • zeus.application.name={application}

The DNS gets labeled with:

  • zeus.object.type=dns
  • zeus.application.name={applicaiton}

func SelectAllNonApplicationNetworks

func SelectAllNonApplicationNetworks(
	application string,
) ([]*Network, error)

func TrySelectApplicationNetwork

func TrySelectApplicationNetwork(
	application string,
) (*Network, error)

func (*Network) Cleanup

func (self *Network) Cleanup() error

func (*Network) String

func (self *Network) String() string

type ObjectLabel

type ObjectLabel int
const (
	IngressObject ObjectLabel = iota + 1
	NetworkObject
	DNSObject
)

type SelectedContainer

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

func SelectContainer

func SelectContainer(
	labels ...Label,
) ([]SelectedContainer, error)

Selects a container by the labels if it exists. No promise about the container is made, it can be in any state.

func (*SelectedContainer) NewContainer

func (self *SelectedContainer) NewContainer(
	application string,
) (*Container, error)

type SelectedNetwork

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

func SelectNetworks

func SelectNetworks(
	labels ...Label,
) ([]SelectedNetwork, error)

Selects a container by the labels if it exists. No promise about the container is made, it can be in any state.

If not container exists nil is returned.

func (*SelectedNetwork) NewNetwork

func (self *SelectedNetwork) NewNetwork(
	application string,
) *Network

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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