docker_deploy

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrComposeAndRunOptionsSet = errors.New("only one of run_options or compose_options can be set")
View Source
var ErrComposeFileRequired = errors.New("compose_file is required")
View Source
var ErrComposeRepoDigestRequired = errors.New("repo_digest is required in compose_file")
View Source
var ErrContainerNotFound = errors.New("container not found")
View Source
var ErrImageNameRequired = errors.New("image_name is required")
View Source
var ErrImageNotFound = errors.New("image not found")
View Source
var ErrPasswordIsRequired = errors.New("credentials.password is required")
View Source
var ErrRepoDigestRequired = errors.New("repo_digest is required")
View Source
var ErrUsernameIsRequired = errors.New("credentials.username is required")
View Source
var Model = resource.NewModel("viam-soleng", "manage", "docker")

Functions

func NewDockerSensor

func NewDockerSensor(ctx context.Context, deps resource.Dependencies, conf resource.Config, logger logging.Logger) (sensor.Sensor, error)

func StringSliceEqual

func StringSliceEqual(a, b []string) bool

StringSliceEqual checks if two string slices are equal

func TestGetImageId

func TestGetImageId(t *testing.T)

func TestIsRunning

func TestIsRunning(t *testing.T)

Types

type ComposeOptions

type ComposeOptions struct {
	ComposeFile []string `json:"compose_file"`
}

This is for docker compose based configs

type Config

type Config struct {
	Attributes     utils.AttributeMap `json:"attributes,omitempty"`
	RunOptions     *RunOptions        `json:"run_options"`
	ComposeOptions *ComposeOptions    `json:"compose_options"`
	ImageName      string             `json:"image_name"`
	RepoDigest     string             `json:"repo_digest"`
	RunOnce        bool               `json:"run_once"`
	DownloadOnly   bool               `json:"download_only"`
	Credentials    *Credentials       `json:"credentials"`
}

func (*Config) HasChanged

func (conf *Config) HasChanged(newConf *Config) bool

func (*Config) Validate

func (conf *Config) Validate(path string) ([]string, error)

type Credentials

type Credentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type DockerConfig

type DockerConfig struct {
	resource.Named
	// contains filtered or unexported fields
}

func (*DockerConfig) Close

func (dc *DockerConfig) Close(ctx context.Context) error

func (*DockerConfig) Readings

func (dc *DockerConfig) Readings(ctx context.Context, extra map[string]interface{}) (map[string]interface{}, error)

Readings implements sensor.Sensor.

func (*DockerConfig) Ready

func (dc *DockerConfig) Ready(ctx context.Context, extra map[string]interface{}) (bool, error)

func (*DockerConfig) Reconfigure

func (dc *DockerConfig) Reconfigure(ctx context.Context, _ resource.Dependencies, conf resource.Config) error

type DockerContainer

type DockerContainer interface {
	IsRunning() (bool, error)
	GetHasRun() (bool, error)
	SetHasRun() error
	GetContainerId() string
	GetImageId() (string, error)
	GetRepoDigest() string
}

func NewDockerContainer

func NewDockerContainer(dockerClient *client.Client, containerId string, name string, repoDigest string, logger logging.Logger, cancelCtx context.Context, cancelFunc context.CancelFunc) DockerContainer

type DockerContainerDetails

type DockerContainerDetails struct {
	ContainerID string
	ImageID     string
	Command     string
	Created     time.Time
	Status      string
	Ports       string
	Names       string
}

type DockerImageDetails

type DockerImageDetails struct {
	Repository string
	Tag        string
	RepoDigest string
	ImageID    string
	Created    time.Time
	Size       int64
}

type DockerManager

type DockerManager interface {
	ListContainers() ([]DockerContainerDetails, error)
	CreateContainer(imageName string, repoDigest string, entry_point_args []string, options []string, logger logging.Logger, cancelCtx context.Context, cancelFunc context.CancelFunc) (DockerContainer, error)
	CreateComposeContainers(imageName string, repoDigest string, composeFile []string, logger logging.Logger, cancelCtx context.Context, cancelFunc context.CancelFunc) ([]DockerContainer, error)

	ListImages() ([]DockerImageDetails, error)
	GetImageDetails(imageId string) (*DockerImageDetails, error)
	GetContainer(containerId string) (*DockerContainerDetails, error)
	GetContainerImageDigest(containerId string) (string, error)
	GetContainersRunningImage(imageDigest string) ([]DockerContainerDetails, error)

	PullImage(imageName string, repoDigest string) error
	ImageExists(repoDigest string) (bool, error)
	RemoveImageByImageId(imageId string) error
	RemoveImageByRepoDigest(repoDigest string) error

	StartContainer(containerId string) error
	StopContainer(containerId string) error
	RemoveContainer(containerId string) error
}

func NewLocalDockerManager

func NewLocalDockerManager(logger logging.Logger) (DockerManager, error)

func NewLocalDockerManagerWithAuth

func NewLocalDockerManagerWithAuth(username string, password string, logger logging.Logger) (DockerManager, error)

type LocalDockerContainer

type LocalDockerContainer struct {
	Id         string
	Name       string
	RepoDigest string
	// contains filtered or unexported fields
}

func (*LocalDockerContainer) GetContainerId

func (di *LocalDockerContainer) GetContainerId() string

func (*LocalDockerContainer) GetHasRun

func (di *LocalDockerContainer) GetHasRun() (bool, error)

func (*LocalDockerContainer) GetImageId

func (di *LocalDockerContainer) GetImageId() (string, error)

func (*LocalDockerContainer) GetRepoDigest

func (di *LocalDockerContainer) GetRepoDigest() string

func (*LocalDockerContainer) IsRunning

func (di *LocalDockerContainer) IsRunning() (bool, error)

func (*LocalDockerContainer) SetHasRun

func (di *LocalDockerContainer) SetHasRun() error

type LocalDockerManager

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

func (*LocalDockerManager) CreateComposeContainers

func (dm *LocalDockerManager) CreateComposeContainers(imageName string, repoDigest string, composeFile []string, logger logging.Logger, cancelCtx context.Context, cancelFunc context.CancelFunc) ([]DockerContainer, error)

func (*LocalDockerManager) CreateContainer

func (dm *LocalDockerManager) CreateContainer(imageName string, repoDigest string, entry_point_args []string, options []string, logger logging.Logger, cancelCtx context.Context, cancelFunc context.CancelFunc) (DockerContainer, error)

func (*LocalDockerManager) GetContainer

func (dm *LocalDockerManager) GetContainer(containerId string) (*DockerContainerDetails, error)

func (*LocalDockerManager) GetContainerImageDigest

func (dm *LocalDockerManager) GetContainerImageDigest(containerId string) (string, error)

func (*LocalDockerManager) GetContainersRunningImage

func (dm *LocalDockerManager) GetContainersRunningImage(repoDigest string) ([]DockerContainerDetails, error)

func (*LocalDockerManager) GetImageDetails

func (dm *LocalDockerManager) GetImageDetails(imageId string) (*DockerImageDetails, error)

func (*LocalDockerManager) ImageExists

func (dm *LocalDockerManager) ImageExists(repoDigest string) (bool, error)

func (*LocalDockerManager) ListContainers

func (dm *LocalDockerManager) ListContainers() ([]DockerContainerDetails, error)

func (*LocalDockerManager) ListImages

func (dm *LocalDockerManager) ListImages() ([]DockerImageDetails, error)

func (*LocalDockerManager) PullImage

func (dm *LocalDockerManager) PullImage(imageName string, repoDigest string) error

func (*LocalDockerManager) RemoveContainer

func (dm *LocalDockerManager) RemoveContainer(containerId string) error

func (*LocalDockerManager) RemoveImageByImageId

func (dm *LocalDockerManager) RemoveImageByImageId(imageId string) error

func (*LocalDockerManager) RemoveImageByRepoDigest

func (dm *LocalDockerManager) RemoveImageByRepoDigest(repoDigest string) error

func (*LocalDockerManager) StartContainer

func (dm *LocalDockerManager) StartContainer(containerId string) error

func (*LocalDockerManager) StopContainer

func (dm *LocalDockerManager) StopContainer(containerId string) error

type RunOptions

type RunOptions struct {
	Env            []string `json:"env"`
	EntryPointArgs []string `json:"entry_point_args"`
	Options        []string `json:"options"`
}

Jump to

Keyboard shortcuts

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