clients

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: MPL-2.0 Imports: 62 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EngineTypeDocker = "docker"
	EngineTypePodman = "podman"
	EngineNotFound   = "not found"
)
View Source
const (
	StorageDriverOverlay2     = "overlay2"
	StorageDriverFuse         = "fuse-overlayfs"
	StorageDriverBTRFS        = "btrfs"
	StorageDriverZFS          = "zfs"
	StorageDriverVFS          = "vfs"
	StorageDriverAUFS         = "aufs"
	StorageDriverDeviceMapper = "devicemapper"
	StorageDriverOverlay      = "overlay"
)
View Source
const (
	Red    = "\033[1;31m%s\033[0m"
	Green  = "\033[1;32m%s\033[0m"
	Yellow = "\033[1;33m%s\033[0m"
)
View Source
const ImageTypeDocker string = "Docker"

ImageTypeDocker defines a type for a Docker image

Variables

View Source
var ErrorCommandTimeout = fmt.Errorf("Command timed out before completing")

Functions

This section is empty.

Types

type CertBundle added in v0.2.1

type CertBundle struct {
	RootCertPath string
	RootKeyPath  string
	LeafCertPath string
	LeafKeyPath  string
}

type Command

type Command interface {
	Execute(config CommandConfig) (int, error)
	Kill(pid int) error
}

func NewCommand

func NewCommand(maxCommandTime time.Duration, l hclog.Logger) Command

NewCommand creates a new command with the given logger and maximum command time

type CommandConfig added in v0.1.9

type CommandConfig struct {
	Command          string
	Args             []string
	Env              []string
	WorkingDirectory string
	RunInBackground  bool
	LogFilePath      string
	Timeout          time.Duration
}

type CommandImpl

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

Command executes local commands

func (*CommandImpl) Execute

func (c *CommandImpl) Execute(config CommandConfig) (int, error)

Execute the given command

func (*CommandImpl) Kill added in v0.2.10

func (c *CommandImpl) Kill(pid int) error

Kill a process with the given pid

type CommandMock added in v0.1.9

type CommandMock struct {
	mock.Mock
}

Can't believe it took this long to hit this circular dependency need to refactor away all the mocks package

func (*CommandMock) Execute added in v0.1.9

func (m *CommandMock) Execute(config CommandConfig) (int, error)

func (*CommandMock) Kill added in v0.2.10

func (m *CommandMock) Kill(pid int) error

type Connector added in v0.2.1

type Connector interface {
	// Start the Connector, returns an error on failure
	Start(*CertBundle) error
	// Stop the Connector, returns an error on failure
	Stop() error
	// IsRunning returns true when the Connector is running
	IsRunning() bool

	// GenerateLocalCertBundle generates a root CA and leaf certificate for
	// securing connector communications for the local instance
	// this function is a convenience function which wraps other
	// methods
	GenerateLocalCertBundle(out string) (*CertBundle, error)

	// Fetches the local certificate bundle from the given directory
	// if any of the required files do not exist an error and a nil
	// CertBundle will be returned
	GetLocalCertBundle(dir string) (*CertBundle, error)

	// Generates a Leaf certificate for securing a connector
	GenerateLeafCert(
		privateKey, rootCA string,
		hosts, ips []string,
		dir string) (*CertBundle, error)

	// ExposeService allows you to expose a local or remote
	// service with another connector
	ExposeService(
		name string,
		port int,
		remoteAddr string,
		destAddr string,
		direction string,
	) (string, error)

	// RemoveService removes a previously exposed service
	RemoveService(id string) error

	// ListServices returns a slice of active services
	ListServices() ([]*shipyard.Service, error)
}

Connector defines a client which can be used for interfacing with the Shipyard connector

func NewConnector added in v0.2.1

func NewConnector(opts ConnectorOptions) Connector

NewConnector creates a new connector with the given options

type ConnectorImpl added in v0.2.1

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

ConnectorImpl is a concrete implementation of the Connector interface

func (*ConnectorImpl) ExposeService added in v0.2.1

func (c *ConnectorImpl) ExposeService(
	name string,
	port int,
	remoteAddr string,
	destAddr string,
	direction string,
) (string, error)

ExposeService allows you to expose a local or remote service with another connector

func (*ConnectorImpl) GenerateLeafCert added in v0.2.1

func (c *ConnectorImpl) GenerateLeafCert(
	rootKey, rootCA string, host, ips []string, dir string) (*CertBundle, error)

GenerateLeafCert generates a x509 leaf certificate with the given details

func (*ConnectorImpl) GenerateLocalCertBundle added in v0.2.1

func (c *ConnectorImpl) GenerateLocalCertBundle(out string) (*CertBundle, error)

creates a CA and local leaf cert

func (*ConnectorImpl) GetLocalCertBundle added in v0.2.1

func (c *ConnectorImpl) GetLocalCertBundle(dir string) (*CertBundle, error)

func (*ConnectorImpl) IsRunning added in v0.2.1

func (c *ConnectorImpl) IsRunning() bool

IsRunning returns true when the Connector is running

func (*ConnectorImpl) ListServices added in v0.3.39

func (c *ConnectorImpl) ListServices() ([]*shipyard.Service, error)

ListServices lists all active services

func (*ConnectorImpl) RemoveService added in v0.2.1

func (c *ConnectorImpl) RemoveService(id string) error

RemoveService removes a previously exposed service

func (*ConnectorImpl) Start added in v0.2.1

func (c *ConnectorImpl) Start(cb *CertBundle) error

Start the Connector, returns an error on failure

func (*ConnectorImpl) Stop added in v0.2.1

func (c *ConnectorImpl) Stop() error

Stop the Connector, returns an error on failure

type ConnectorMock added in v0.2.1

type ConnectorMock struct {
	mock.Mock
}

func (*ConnectorMock) ExposeService added in v0.2.1

func (m *ConnectorMock) ExposeService(
	name string,
	port int,
	remoteAddr string,
	destAddr string,
	direction string,
) (string, error)

func (*ConnectorMock) GenerateLeafCert added in v0.2.1

func (m *ConnectorMock) GenerateLeafCert(privateKey, rootCA string, hosts, ips []string, dir string) (*CertBundle, error)

func (*ConnectorMock) GenerateLocalCertBundle added in v0.2.1

func (m *ConnectorMock) GenerateLocalCertBundle(out string) (*CertBundle, error)

GenerateLocalBundle generates a root CA and leaf certificate for securing connector communications for the local instance this function is a convenience function which wraps other methods

func (*ConnectorMock) GetLocalCertBundle added in v0.2.1

func (m *ConnectorMock) GetLocalCertBundle(out string) (*CertBundle, error)

func (*ConnectorMock) IsRunning added in v0.2.1

func (m *ConnectorMock) IsRunning() bool

IsRunning returns true when the Connector is running

func (*ConnectorMock) ListServices added in v0.3.39

func (m *ConnectorMock) ListServices() ([]*shipyard.Service, error)

func (*ConnectorMock) RemoveService added in v0.2.1

func (m *ConnectorMock) RemoveService(id string) error

RemoveService removes a previously exposed service

func (*ConnectorMock) Start added in v0.2.1

func (m *ConnectorMock) Start(cb *CertBundle) error

Start the Connector, returns an error on failure

func (*ConnectorMock) Stop added in v0.2.1

func (m *ConnectorMock) Stop() error

Stop the Connector, returns an error on failure

type ConnectorOptions added in v0.2.1

type ConnectorOptions struct {
	LogDirectory string
	BinaryPath   string
	GrpcBind     string
	HTTPBind     string
	APIBind      string
	LogLevel     string
	PidFile      string
}

func DefaultConnectorOptions added in v0.2.1

func DefaultConnectorOptions() ConnectorOptions

type ContainerTasks

type ContainerTasks interface {
	SetForcePull(bool)
	// CreateContainer creates a new container for the given configuration
	// if successful CreateContainer returns the ID of the created container and a nil error
	// if not successful CreateContainer returns a blank string for the id and an error message
	CreateContainer(*config.Container) (id string, err error)
	// Container Info returns an annonymous interface corresponding to the container info
	// returns error when unable to read info such as when the container does not exist.
	ContainerInfo(id string) (interface{}, error)
	// RemoveContainer stops and removes a running container
	RemoveContainer(id string, force bool) error
	// BuildContainer builds a container based on the given configuration
	// If a cahced image already exists Build will noop
	// When force is specificed BuildContainer will rebuild the container regardless of cached images
	// Returns the canonical name of the built image and an error
	BuildContainer(config *config.Container, force bool) (string, error)
	// CreateVolume creates a new volume with the given name.
	// If successful the id of the newly created volume is returned
	CreateVolume(name string) (id string, err error)
	// RemoveVolume removes a volume with the given name
	RemoveVolume(name string) error
	// PullImage pulls a Docker image from the registry if it is not already
	// present in the local cache.
	// If the Username and Password config options are set then PullImage will attempt to
	// authenticate with the registry before pulling the image.
	// If the force parameter is set then PullImage will pull regardless of the image already
	// being cached locally.
	PullImage(image config.Image, force bool) error
	// FindContainerIDs returns the Container IDs for the given identifier
	FindContainerIDs(name string, typeName config.ResourceType) ([]string, error)
	// ContainerLogs attaches to the container and streams the logs to the returned
	// io.ReadCloser.
	// Returns an error if the container is not running
	ContainerLogs(id string, stdOut, stdErr bool) (io.ReadCloser, error)
	// CopyFromContainer allows the copying of a file from a container
	CopyFromContainer(id, src, dst string) error
	// CopyToContainer allows a file to be copied into a container
	CopyFileToContainer(id, src, dst string) error
	// CopyLocaDockerImageToVolume copies the docker images to the docker volume as a
	// compressed archive.
	// the path in the docker volume where the archive is created is returned
	// along with any errors.
	CopyLocalDockerImagesToVolume(images []string, volume string, force bool) ([]string, error)

	//CopyFilesToVolume copies the files to the path in a Docker volume
	CopyFilesToVolume(volume string, files []string, path string, force bool) ([]string, error)
	// Execute command allows the execution of commands in a running docker container
	// id is the id of the container to execute the command in
	// command is a slice of strings to execute
	// writer [optional] will be used to write any output from the command execution.
	ExecuteCommand(id string, command []string, env []string, workingDirectory string, user, group string, writer io.Writer) error
	// AttachNetwork attaches a container to a network
	// if aliases is set an alias for the container name will be added
	// if ipAddress is not null then a user defined ipaddress will be used
	AttachNetwork(network, containerid string, aliases []string, ipaddress string) error
	// DetatchNetwork disconnects a container from the network
	DetachNetwork(network, containerid string) error
	// ListNetworks lists the networks a container is attached to
	ListNetworks(id string) []config.NetworkAttachment

	// CreateShell in the running container and attach
	CreateShell(id string, command []string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error

	// Returns basic information related to the Docker Engine
	EngineInfo() *EngineInfo
}

ContainerTasks is a task oriented client which abstracts the underlying container technology from the providers this allows different concrete implementations such as Docker, or ContainerD without needing to change the provider code.

The Docker SDK can also be quite terse, the API design for this client is design is centered around performing a task such as CreateContainer, this may be composed of many individual SDK calls.

type Docker

type Docker interface {
	ContainerCreate(
		ctx context.Context,
		config *container.Config,
		hostConfig *container.HostConfig,
		networkingConfig *network.NetworkingConfig,
		platform *specs.Platform,
		containerName string,
	) (container.ContainerCreateCreatedBody, error)

	ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
	ContainerStart(context.Context, string, types.ContainerStartOptions) error
	ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error
	ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error
	ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)
	ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
	ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error
	ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
	ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
	ContainerExecResize(ctx context.Context, execID string, config types.ResizeOptions) error
	ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)

	CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
	CopyFromContainer(ctx context.Context, containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)

	NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
	NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error)
	NetworkRemove(ctx context.Context, networkID string) error
	NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error
	NetworkDisconnect(ctx context.Context, networkID, containerID string, force bool) error

	VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumeListOKBody, error)
	VolumeCreate(ctx context.Context, options volumetypes.VolumeCreateBody) (types.Volume, error)
	VolumeRemove(ctx context.Context, volumeID string, force bool) error

	ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error)
	ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)
	ImageSave(ctx context.Context, imageIDs []string) (io.ReadCloser, error)
	ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
	ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)

	ServerVersion(ctx context.Context) (types.Version, error)
	Info(ctx context.Context) (types.Info, error)
}

Docker defines an interface for a Docker client

func NewDocker

func NewDocker() (Docker, error)

NewDocker creates a new Docker client

type DockerTasks

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

DockerTasks is a concrete implementation of ContainerTasks which uses the Docker SDK

func NewDockerTasks

func NewDockerTasks(c Docker, il ImageLog, tg *TarGz, l hclog.Logger) *DockerTasks

NewDockerTasks creates a DockerTasks with the given Docker client

func (*DockerTasks) AttachNetwork added in v0.1.0

func (d *DockerTasks) AttachNetwork(net, containerid string, aliases []string, ipaddress string) error

func (*DockerTasks) BuildContainer added in v0.1.0

func (d *DockerTasks) BuildContainer(config *config.Container, force bool) (string, error)

func (*DockerTasks) ContainerInfo added in v0.1.0

func (d *DockerTasks) ContainerInfo(id string) (interface{}, error)

ContainerInfo returns the Docker container info

func (*DockerTasks) ContainerLogs

func (d *DockerTasks) ContainerLogs(id string, stdOut, stdErr bool) (io.ReadCloser, error)

ContainerLogs streams the logs for the container to the returned io.ReadCloser

func (*DockerTasks) CopyFileToContainer added in v0.1.18

func (d *DockerTasks) CopyFileToContainer(containerID, filename, path string) error

CopyFileToContainer copies the file at path filename to the container containerID and stores it in the container at the path path.

func (*DockerTasks) CopyFilesToVolume added in v0.2.16

func (d *DockerTasks) CopyFilesToVolume(volumeID string, filenames []string, path string, force bool) ([]string, error)

CopyFileToVolume copies a file to a Docker volume returns the names of the stored files

func (*DockerTasks) CopyFromContainer

func (d *DockerTasks) CopyFromContainer(id, src, dst string) error

CopyFromContainer copies a file from a container

func (*DockerTasks) CopyLocalDockerImagesToVolume added in v0.2.16

func (d *DockerTasks) CopyLocalDockerImagesToVolume(images []string, volume string, force bool) ([]string, error)

CopyLocalDockerImagesToVolume writes multiple Docker images to a Docker container as a compressed archive returns the filename of the archive and an error if one occured

func (*DockerTasks) CreateContainer

func (d *DockerTasks) CreateContainer(c *config.Container) (string, error)

CreateContainer creates a new Docker container for the given configuation

func (*DockerTasks) CreateShell

func (d *DockerTasks) CreateShell(id string, command []string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error

CreateShell creates an interactive shell inside a container https://github.com/docker/cli/blob/ae1618713f83e7da07317d579d0675f578de22fa/cli/command/container/exec.go

func (*DockerTasks) CreateVolume

func (d *DockerTasks) CreateVolume(name string) (string, error)

CreateVolume creates a Docker volume for a cluster if the volume exists performs no action returns the volume name and an error if unsuccessful

func (*DockerTasks) DetachNetwork

func (d *DockerTasks) DetachNetwork(network, containerid string) error

DetachNetwork detaches a container from a network TODO: Docker returns success before removing a container tasks which depend on the network being removed may fail in the future we need to check it has been removed before returning

func (*DockerTasks) EngineInfo added in v0.4.13

func (d *DockerTasks) EngineInfo() *EngineInfo

func (*DockerTasks) ExecuteCommand

func (d *DockerTasks) ExecuteCommand(id string, command []string, env []string, workingDir string, user, group string, writer io.Writer) error

ExecuteCommand allows the execution of commands in a running docker container id is the id of the container to execute the command in command is a slice of strings to execute writer [optional] will be used to write any output from the command execution.

func (*DockerTasks) FindContainerIDs

func (d *DockerTasks) FindContainerIDs(containerName string, typeName config.ResourceType) ([]string, error)

FindContainerIDs returns the Container IDs for the given identifier

func (*DockerTasks) ListNetworks added in v0.1.0

func (d *DockerTasks) ListNetworks(id string) []config.NetworkAttachment

ListNetworks lists the networks a container is attached to

func (*DockerTasks) PullImage

func (d *DockerTasks) PullImage(image config.Image, force bool) error

PullImage pulls a Docker image from a remote repo

func (*DockerTasks) RemoveContainer

func (d *DockerTasks) RemoveContainer(id string, force bool) error

RemoveContainer with the given id

func (*DockerTasks) RemoveVolume

func (d *DockerTasks) RemoveVolume(name string) error

RemoveVolume deletes the Docker volume associated with a cluster

func (*DockerTasks) SetForcePull

func (d *DockerTasks) SetForcePull(force bool)

SetForcePull sets a global override for the DockerTasks, when set to true Images will always be pulled from remote registries

type EngineInfo added in v0.4.13

type EngineInfo struct {
	// StorageDriver used by the engine, overlay, devicemapper, etc
	StorageDriver string

	// EngineType, docker, podman, not found
	EngineType string
}

type Getter

type Getter interface {
	Get(uri, dst string) error
	SetForce(force bool)
}

Getter is an interface which defines interations for downloading remote folders

type GetterImpl

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

GetterImpl is a concrete implementation of the Getter interface

func NewGetter

func NewGetter(force bool) *GetterImpl

NewGetter creates a new Getter

func (*GetterImpl) Get

func (g *GetterImpl) Get(uri, dst string) error

Get attempts to retrieve a folder from a remote location and stores it at the destination.

If force was set to true when creating a Getter then the destination folder will automatically be overwritten.

Returns error on failure

func (*GetterImpl) SetForce

func (g *GetterImpl) SetForce(force bool)

SetForce sets the force flag causing all downloads to overwrite the destination

type HTTP

type HTTP interface {
	// HealthCheckHTTP makes a HTTP GET request to the given URI and
	// if a successful status []codes is returned the method returns a nil error.
	// If it is not possible to contact the URI or if any status other than the passed codes is returned
	// by the upstream, then the URI is retried until the timeout elapses.
	HealthCheckHTTP(uri string, codes []int, timeout time.Duration) error
	// Do executes a HTTP request and returns the response
	Do(r *http.Request) (*http.Response, error)
}

HTTP defines an interface for a HTTP client

func NewHTTP

func NewHTTP(backoff time.Duration, l hclog.Logger) HTTP

type HTTPImpl

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

func (*HTTPImpl) Do

func (h *HTTPImpl) Do(r *http.Request) (*http.Response, error)

Do executes a HTTP request and returns the response

func (*HTTPImpl) HealthCheckHTTP

func (h *HTTPImpl) HealthCheckHTTP(address string, codes []int, timeout time.Duration) error

HealthCheckHTTP checks a http or HTTPS endpoint for a status 200

type Helm

type Helm interface {
	// CreateFromRepository creates a Helm install from a repository
	Create(kubeConfig, name, namespace string, createNamespace bool, skipCRDs bool, chart, version, valuesPath string, valuesString map[string]string) error

	// Destroy the given chart
	Destroy(kubeConfig, name, namespace string) error

	//UpsertChartRepository configures the remote chart repository
	UpsertChartRepository(name, url string) error
}

Helm defines an interface for a client which can manage Helm charts

func NewHelm

func NewHelm(l hclog.Logger) Helm

type HelmImpl

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

func (*HelmImpl) Create

func (h *HelmImpl) Create(kubeConfig, name, namespace string, createNamespace bool, skipCRDs bool, chart, version, valuesPath string, valuesString map[string]string) error

func (*HelmImpl) Destroy

func (h *HelmImpl) Destroy(kubeConfig, name, namespace string) error

Destroy removes an installed Helm chart from the system

func (*HelmImpl) UpsertChartRepository added in v0.3.42

func (h *HelmImpl) UpsertChartRepository(name, url string) error

type ImageFileLog added in v0.0.19

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

func NewImageFileLog added in v0.0.19

func NewImageFileLog(file string) *ImageFileLog

NewImageFileLog creates an ImageLog which uses a file as the underlying Datastore

func (*ImageFileLog) Clear added in v0.0.19

func (i *ImageFileLog) Clear() error

Clear the list of images

func (*ImageFileLog) Log added in v0.0.19

func (i *ImageFileLog) Log(name, t string) error

Log an image has been downloaded by Shypyard

func (*ImageFileLog) Read added in v0.0.19

func (i *ImageFileLog) Read(t string) ([]string, error)

Read a list of images which have been downloaded by Shipyard

type ImageLog added in v0.0.19

type ImageLog interface {
	Log(string, string) error
	Read(string) ([]string, error)
	Clear() error
}

ImageLog logs machine images to make cleanup possible

type Kubernetes

type Kubernetes interface {
	SetConfig(string) (Kubernetes, error)
	GetPods(string) (*v1.PodList, error)
	HealthCheckPods(selectors []string, timeout time.Duration) error
	Apply(files []string, waitUntilReady bool) error
	Delete(files []string) error
	GetPodLogs(ctx context.Context, podName, nameSpace string) (io.ReadCloser, error)
}

Kubernetes defines an interface for a Kuberenetes client

func NewKubernetes

func NewKubernetes(t time.Duration, l hclog.Logger) Kubernetes

NewKubernetes creates a new client for interacting with Kubernetes clusters

type KubernetesImpl

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

KubernetesImpl is a concrete implementation of a Kubernetes client

func (*KubernetesImpl) Apply

func (k *KubernetesImpl) Apply(files []string, waitUntilReady bool) error

Apply Kubernetes YAML files at path if waitUntilReady is true then the client will block until all resources have been created

func (*KubernetesImpl) Delete

func (k *KubernetesImpl) Delete(files []string) error

Delete Kuberentes YAML files at path

func (*KubernetesImpl) GetPodLogs added in v0.3.27

func (k *KubernetesImpl) GetPodLogs(ctx context.Context, podName, nameSpace string) (io.ReadCloser, error)

GetPodLogs returns a io.ReadCloser,err for a given pods' logs

func (*KubernetesImpl) GetPods

func (k *KubernetesImpl) GetPods(selector string) (*v1.PodList, error)

GetPods returns the Kubernetes pods based on the label selector

func (*KubernetesImpl) HealthCheckPods

func (k *KubernetesImpl) HealthCheckPods(selectors []string, timeout time.Duration) error

HealthCheckPods uses the given selector to check that all pods are started and running. selectors are checked sequentially pods = ["component=server,app=consul", "component=client,app=consul"]

func (*KubernetesImpl) SetConfig

func (k *KubernetesImpl) SetConfig(kubeconfig string) (Kubernetes, error)

SetConfig for the Kubernetes cluster and clones the client

type MockContainerTasks added in v0.4.13

type MockContainerTasks struct {
	mock.Mock
}

func (*MockContainerTasks) AttachNetwork added in v0.4.13

func (d *MockContainerTasks) AttachNetwork(network, containerid string, aliases []string, ipaddress string) error

func (*MockContainerTasks) BuildContainer added in v0.4.13

func (m *MockContainerTasks) BuildContainer(config *config.Container, force bool) (string, error)

func (*MockContainerTasks) ContainerInfo added in v0.4.13

func (m *MockContainerTasks) ContainerInfo(id string) (interface{}, error)

func (*MockContainerTasks) ContainerLogs added in v0.4.13

func (d *MockContainerTasks) ContainerLogs(id string, stdOut, stdErr bool) (io.ReadCloser, error)

func (*MockContainerTasks) CopyFileToContainer added in v0.4.13

func (d *MockContainerTasks) CopyFileToContainer(id, src, dst string) error

func (*MockContainerTasks) CopyFilesToVolume added in v0.4.13

func (d *MockContainerTasks) CopyFilesToVolume(volume string, files []string, path string, force bool) ([]string, error)

func (*MockContainerTasks) CopyFromContainer added in v0.4.13

func (d *MockContainerTasks) CopyFromContainer(id, src, dst string) error

func (*MockContainerTasks) CopyLocalDockerImagesToVolume added in v0.4.13

func (d *MockContainerTasks) CopyLocalDockerImagesToVolume(images []string, volume string, force bool) ([]string, error)

func (*MockContainerTasks) CreateContainer added in v0.4.13

func (m *MockContainerTasks) CreateContainer(c *config.Container) (id string, err error)

func (*MockContainerTasks) CreateShell added in v0.4.13

func (d *MockContainerTasks) CreateShell(id string, command []string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error

func (*MockContainerTasks) CreateVolume added in v0.4.13

func (m *MockContainerTasks) CreateVolume(name string) (id string, err error)

func (*MockContainerTasks) DetachNetwork added in v0.4.13

func (d *MockContainerTasks) DetachNetwork(network, containerid string) error

func (*MockContainerTasks) EngineInfo added in v0.4.13

func (d *MockContainerTasks) EngineInfo() *EngineInfo

func (*MockContainerTasks) ExecuteCommand added in v0.4.13

func (d *MockContainerTasks) ExecuteCommand(id string, command []string, env []string, workingDirectory string, user, group string, writer io.Writer) error

func (*MockContainerTasks) FindContainerIDs added in v0.4.13

func (m *MockContainerTasks) FindContainerIDs(name string, typeName config.ResourceType) ([]string, error)

func (*MockContainerTasks) ListNetworks added in v0.4.13

func (d *MockContainerTasks) ListNetworks(id string) []config.NetworkAttachment

func (*MockContainerTasks) PullImage added in v0.4.13

func (m *MockContainerTasks) PullImage(i config.Image, f bool) error

func (*MockContainerTasks) RemoveContainer added in v0.4.13

func (m *MockContainerTasks) RemoveContainer(id string, force bool) error

func (*MockContainerTasks) RemoveVolume added in v0.4.13

func (m *MockContainerTasks) RemoveVolume(name string) error

func (*MockContainerTasks) SetForcePull added in v0.4.13

func (m *MockContainerTasks) SetForcePull(f bool)

type MockKubernetes added in v0.3.7

type MockKubernetes struct {
	mock.Mock
}

func (*MockKubernetes) Apply added in v0.3.7

func (m *MockKubernetes) Apply(files []string, waitUntilReady bool) error

func (*MockKubernetes) Delete added in v0.3.7

func (m *MockKubernetes) Delete(files []string) error

func (*MockKubernetes) GetPodLogs added in v0.3.27

func (m *MockKubernetes) GetPodLogs(ctx context.Context, podName, nameSpace string) (io.ReadCloser, error)

func (*MockKubernetes) GetPods added in v0.3.7

func (m *MockKubernetes) GetPods(selector string) (*v1.PodList, error)

func (*MockKubernetes) HealthCheckPods added in v0.3.7

func (m *MockKubernetes) HealthCheckPods(selectors []string, timeout time.Duration) error

func (*MockKubernetes) SetConfig added in v0.3.7

func (m *MockKubernetes) SetConfig(kubeconfig string) (Kubernetes, error)

type Nomad

type Nomad interface {
	// SetConfig for the client, path is a valid Nomad JSON config file
	SetConfig(utils.ClusterConfig, string) error
	// Create jobs in the provided files
	Create(files []string) error
	// Stop jobs in the provided files
	Stop(files []string) error
	// ParseJob in the given file and return a JSON blob representing the HCL job
	ParseJob(file string) ([]byte, error)
	// JobRunning returns true if all allocations for a job are running
	JobRunning(job string) (bool, error)
	// HealthCheckAPI uses the Nomad API to check that all servers and nodes
	// are ready. The function will block until either all nodes are healthy or the
	// timeout period elapses.
	HealthCheckAPI(time.Duration) error
	// Endpoints returns a list of endpoints for a cluster
	Endpoints(job, group, task string) ([]map[string]string, error)
}

Nomad defines an interface for a Nomad client

func NewNomad

func NewNomad(c HTTP, backoff time.Duration, l hclog.Logger) Nomad

NewNomad creates a new Nomad client

type NomadImpl

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

NomadImpl is an implementation of the Nomad interface

func (*NomadImpl) Create

func (n *NomadImpl) Create(files []string) error

Create jobs in the Nomad cluster for the given files and wait until all jobs are running

func (*NomadImpl) Endpoints added in v0.1.16

func (n *NomadImpl) Endpoints(job, group, task string) ([]map[string]string, error)

Endpoints returns a list of endpoints for a cluster

func (*NomadImpl) HealthCheckAPI

func (n *NomadImpl) HealthCheckAPI(timeout time.Duration) error

HealthCheckAPI executes a HTTP heathcheck for a Nomad cluster

func (*NomadImpl) JobRunning added in v0.1.16

func (n *NomadImpl) JobRunning(job string) (bool, error)

JobRunning returns true when all allocations for a job are running

func (*NomadImpl) ParseJob

func (n *NomadImpl) ParseJob(file string) ([]byte, error)

ParseJob validates a HCL job file with the Nomad API and returns a slice of bytes representing the JSON payload.

func (*NomadImpl) SetConfig

func (n *NomadImpl) SetConfig(nomadconfig utils.ClusterConfig, context string) error

SetConfig loads the Nomad config from a file

func (*NomadImpl) Stop

func (n *NomadImpl) Stop(files []string) error

Stop the jobs defined in the files for the referenced Nomad cluster

type System

type System interface {
	OpenBrowser(string) error
	Preflight() (string, error)
	CheckVersion(string) (string, bool)
	PromptInput(in io.Reader, out io.Writer, message string) string
}

System handles interactions between Shipyard and the OS

type SystemImpl

type SystemImpl struct{}

SystemImpl is a concrete implementation of the System interface

func (*SystemImpl) CheckVersion added in v0.0.19

func (b *SystemImpl) CheckVersion(current string) (string, bool)

CheckVersion checks the current version against the latest online version if an update is required the function returns a string with the upgrade text and a boolean value set to false. If no upgrade is reuquired then the boolean will be set to true and the string will be empty.

func (*SystemImpl) OpenBrowser

func (b *SystemImpl) OpenBrowser(uri string) error

OpenBrowser opens a URI in a new browser window

func (*SystemImpl) Preflight

func (b *SystemImpl) Preflight() (string, error)

Preflight checks that the required software is installed and is working correctly

func (*SystemImpl) PromptInput added in v0.1.0

func (b *SystemImpl) PromptInput(in io.Reader, out io.Writer, message string) string

PromptInput prompts the user for input in the CLI and returns the entered value

type TarGz added in v0.3.27

type TarGz struct {
}

func (*TarGz) Compress added in v0.3.27

func (tg *TarGz) Compress(buf io.Writer, options *TarGzOptions, src ...string) error

func (*TarGz) Uncompress added in v0.3.27

func (tg *TarGz) Uncompress(src io.Reader, dst string) error

type TarGzOptions added in v0.3.27

type TarGzOptions struct {
	// OmitRoot when set to true ignores the top level directory in the tar archive
	// only adding sub directories and files.
	OmitRoot bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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