docker

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PullImageErrNotFound = fmt.Errorf("Requested image not found")
View Source
var PullImageErrUnauthorized = fmt.Errorf("Could not pull image: unauthorized")

Functions

func GetServerURLFromTag added in v0.4.0

func GetServerURLFromTag(image string) (string, error)

Types

type Agent

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

Agent is a Docker client for performing operations that interact with the Docker engine over REST

func NewAgentFromEnv

func NewAgentFromEnv() (*Agent, error)

NewAgentFromEnv creates a new Docker agent using the environment variables set on the host

func NewAgentWithAuthGetter added in v0.4.0

func NewAgentWithAuthGetter(client *api.Client, projID uint) (*Agent, error)

func StartPorter

func StartPorter(opts *PorterStartOpts) (agent *Agent, id string, err error)

StartPorter creates a new Docker agent using the host environment, and creates a new Porter instance

func (*Agent) BuildLocal added in v0.4.0

func (a *Agent) BuildLocal(opts *BuildOpts, dockerfilePath string) error

BuildLocal

func (*Agent) ConnectContainerToNetwork

func (a *Agent) ConnectContainerToNetwork(networkID, containerID, containerName string) error

ConnectContainerToNetwork attaches a container to a specified network

func (*Agent) CreateBridgeNetwork

func (a *Agent) CreateBridgeNetwork(name string) (id string, err error)

CreateBridgeNetwork creates a volume using the default driver type (bridge) with the CLI label attached

func (*Agent) CreateBridgeNetworkIfNotExist

func (a *Agent) CreateBridgeNetworkIfNotExist(name string) (id string, err error)

CreateBridgeNetworkIfNotExist creates a volume using driver type "local" with the given name if it does not exist. If the volume does exist but does not contain the required label (a.label), an error is thrown.

func (*Agent) CreateLocalVolume

func (a *Agent) CreateLocalVolume(name string) (*types.Volume, error)

CreateLocalVolume creates a volume using driver type "local" with no configured options. The equivalent of:

docker volume create --driver local [name]

func (*Agent) CreateLocalVolumeIfNotExist

func (a *Agent) CreateLocalVolumeIfNotExist(name string) (*types.Volume, error)

CreateLocalVolumeIfNotExist creates a volume using driver type "local" with the given name if it does not exist. If the volume does exist but does not contain the required label (a.label), an error is thrown.

func (*Agent) PullImage

func (a *Agent) PullImage(image string) error

PullImage pulls an image specified by the image string

func (*Agent) PushImage added in v0.4.0

func (a *Agent) PushImage(image string) error

PushImage pushes an image specified by the image string

func (*Agent) RemoveLocalVolume

func (a *Agent) RemoveLocalVolume(name string) error

RemoveLocalVolume removes a volume by name

func (*Agent) StartPorterContainer

func (a *Agent) StartPorterContainer(opts PorterServerStartOpts) (string, error)

StartPorterContainer pulls a specific Porter image and starts a container using the Docker engine. It returns the container ID

func (*Agent) StartPostgresContainer

func (a *Agent) StartPostgresContainer(opts PostgresOpts) (string, error)

StartPostgresContainer pulls a specific Porter image and starts a container using the Docker engine

func (*Agent) StopPorterContainers

func (a *Agent) StopPorterContainers(remove bool) error

StopPorterContainers finds all containers that were started via the CLI and stops them -- removes the container if remove is set to true

func (*Agent) StopPorterContainersWithProcessID

func (a *Agent) StopPorterContainersWithProcessID(processID string, remove bool) error

StopPorterContainersWithProcessID finds all containers that were started via the CLI and have a given process id and stops them -- removes the container if remove is set to true

func (*Agent) TagImage added in v0.4.0

func (a *Agent) TagImage(old, new string) error

func (*Agent) WaitForContainerHealthy

func (a *Agent) WaitForContainerHealthy(id string, streak int) error

WaitForContainerHealthy waits until a container is returning a healthy status. Streak is the maximum number of failures in a row, while timeout is the length of time between checks.

func (*Agent) WaitForContainerStop

func (a *Agent) WaitForContainerStop(id string) error

WaitForContainerStop waits until a container has stopped to exit

type AuthEntry added in v0.4.0

type AuthEntry struct {
	AuthorizationToken string
	RequestedAt        time.Time
	ExpiresAt          time.Time
	ProxyEndpoint      string
}

AuthEntry is a stored token for registry access with an expiration time.

func (*AuthEntry) IsValid added in v0.4.0

func (authEntry *AuthEntry) IsValid(testTime time.Time) bool

IsValid checks if AuthEntry is still valid at runtime. AuthEntries expire at 1/2 of their original requested window.

type AuthGetter added in v0.4.0

type AuthGetter struct {
	Client    *api.Client
	Cache     CredentialsCache
	ProjectID uint
}

AuthGetter retrieves

func (*AuthGetter) GetCredentials added in v0.4.0

func (a *AuthGetter) GetCredentials(serverURL string) (user string, secret string, err error)

func (*AuthGetter) GetDOCRCredentials added in v0.4.0

func (a *AuthGetter) GetDOCRCredentials(serverURL string, projID uint) (user string, secret string, err error)

func (*AuthGetter) GetDockerHubCredentials added in v0.4.0

func (a *AuthGetter) GetDockerHubCredentials(serverURL string, projID uint) (user string, secret string, err error)

func (*AuthGetter) GetECRCredentials added in v0.4.0

func (a *AuthGetter) GetECRCredentials(serverURL string, projID uint) (user string, secret string, err error)

func (*AuthGetter) GetGCRCredentials added in v0.4.0

func (a *AuthGetter) GetGCRCredentials(serverURL string, projID uint) (user string, secret string, err error)

type BuildOpts added in v0.4.0

type BuildOpts struct {
	ImageRepo    string
	Tag          string
	BuildContext string
	Env          map[string]string
}

type CredentialsCache added in v0.4.0

type CredentialsCache interface {
	Get(registry string) *AuthEntry
	Set(registry string, entry *AuthEntry)
	List() []*AuthEntry
}

CredentialsCache is a simple interface for getting/setting auth credentials so that we don't request new tokens when previous ones haven't expired

func NewFileCredentialsCache added in v0.4.0

func NewFileCredentialsCache() CredentialsCache

NewFileCredentialsCache returns a new file credentials cache.

path is used for temporary files during save, and filename should be a relative filename in the same directory where the cache is serialized and deserialized.

cachePrefixKey is used for scoping credentials for a given credential cache (i.e. region and accessKey).

type FileCredentialCache added in v0.4.0

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

func (*FileCredentialCache) Clear added in v0.4.0

func (f *FileCredentialCache) Clear()

func (*FileCredentialCache) Get added in v0.4.0

func (f *FileCredentialCache) Get(registry string) *AuthEntry

func (*FileCredentialCache) List added in v0.4.0

func (f *FileCredentialCache) List() []*AuthEntry

List returns all of the available AuthEntries (regardless of prefix)

func (*FileCredentialCache) Set added in v0.4.0

func (f *FileCredentialCache) Set(registry string, entry *AuthEntry)

type PorterDB

type PorterDB int

PorterDB is used for enumerating DB types

const (
	Postgres PorterDB = iota
	SQLite
)

The supported DB types

type PorterServerStartOpts

type PorterServerStartOpts struct {
	Name          string
	Image         string
	StartCmd      []string
	HostPort      uint
	ContainerPort uint
	Mounts        []mount.Mount
	VolumeMap     map[string]struct{}
	Env           []string
	NetworkID     string
}

PorterServerStartOpts are the options for starting the Porter server

type PorterStartOpts

type PorterStartOpts struct {
	ProcessID      string
	ServerImageTag string
	ServerPort     int
	DB             PorterDB
	Env            []string
}

PorterStartOpts are the options for starting the Porter stack

type PostgresOpts

type PostgresOpts struct {
	Name      string
	Image     string
	Env       []string
	VolumeMap map[string]struct{}
	Mounts    []mount.Mount
	NetworkID string
}

PostgresOpts are the options for starting the Postgres DB

type PullImageEvent

type PullImageEvent struct {
	Status         string `json:"status"`
	Error          string `json:"error"`
	Progress       string `json:"progress"`
	ProgressDetail struct {
		Current int `json:"current"`
		Total   int `json:"total"`
	} `json:"progressDetail"`
}

PullImageEvent represents a response from the Docker API with an image pull event

type RegistryCache added in v0.4.0

type RegistryCache struct {
	Registries map[string]*AuthEntry
	Version    string
}

Jump to

Keyboard shortcuts

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