proxy

package
v1.5.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2019 License: Apache-2.0 Imports: 53 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShortIDLen = 12

	ContainerRunning = "running"
	ContainerError   = "error"
	ContainerStopped = "stopped"
	ContainerExited  = "exited"
	ContainerCreated = "created"
)
View Source
const (
	DriverArgFlagKey      = "flags"
	DriverArgContainerKey = "container"
	DriverArgImageKey     = "image"

	OptsVolumeStoreKey     string = "volumestore"
	OptsCapacityKey        string = "capacity"
	DockerMetadataModelKey string = "DockerMetaData"
)
View Source
const (
	SwaggerSubstringEOF = "EOF"
)

Variables

View Source
var SupportedVolDrivers = map[string]struct{}{
	"vsphere": {},
	"local":   {},
}

Volume drivers currently supported. "local" is the default driver supplied by the client and is equivalent to "vsphere" for our implementation.

Functions

func ContainerInfoToDockerContainerInspect

func ContainerInfoToDockerContainerInspect(vc *viccontainer.VicContainer, info *models.ContainerInfo, portlayerName string) (*types.ContainerJSON, error)

ContainerInfoToDockerContainerInspect takes a ContainerInfo swagger-based struct returned from VIC's port layer and creates an engine-api based container inspect struct. There maybe other asset gathering if ContainerInfo does not have all the information

func ContainerInfoToVicContainer

func ContainerInfoToVicContainer(info models.ContainerInfo, portlayerName string) *viccontainer.VicContainer

func MountsFromContainer

func MountsFromContainer(vc *viccontainer.VicContainer) []types.MountPoint

mountsFromContainer derives []types.MountPoint (used in inspect) from the cached container data.

func NewPortLayerClient

func NewPortLayerClient(portLayerAddr string) *apiclient.PortLayer

func NewVolumeModel

func NewVolumeModel(volume *models.VolumeResponse, labels map[string]string) *types.Volume

func RemoveAnonContainerVols

func RemoveAnonContainerVols(ctx context.Context, pl *client.PortLayer, cID string, vc *viccontainer.VicContainer)

RemoveAnonContainerVols removes anonymous volumes joined to a container. It is invoked once the said container has been removed. It fetches a list of volumes that are joined to at least one other container, and calls the portlayer to remove this container's anonymous volumes if they are dangling. Errors, if any, are only logged.

Types

type ArchiveProxy

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

func (*ArchiveProxy) ArchiveExportReader

func (a *ArchiveProxy) ArchiveExportReader(op trace.Operation, store, ancestorStore, deviceID, ancestor string, data bool, filterSpec archive.FilterSpec) (io.ReadCloser, error)

ArchiveExportReader streams a tar archive from the portlayer. Once the stream is complete, an io.Reader is returned and the caller can use that reader to parse the data.

func (*ArchiveProxy) ArchiveImportWriter

func (a *ArchiveProxy) ArchiveImportWriter(op trace.Operation, store, deviceID string, filterSpec archive.FilterSpec, wg *sync.WaitGroup, errchan chan error) (io.WriteCloser, error)

ArchiveImportWriter initializes a write stream for a path. This is usually called for getting a writer during docker cp TO container.

func (*ArchiveProxy) StatPath

func (a *ArchiveProxy) StatPath(op trace.Operation, store, deviceID string, filterSpec archive.FilterSpec) (*types.ContainerPathStat, error)

StatPath requests the portlayer to stat the filesystem resource at the specified path in the container vc.

type AttachConfig

type AttachConfig struct {
	*backend.ContainerAttachConfig

	// ID of the session
	ID string
	// Tells the attach copier that the stream's stdin is a TTY and to look for
	// escape sequences in stdin to detach from the stream.
	// When true the escape sequence is not passed to the underlying stream
	UseTty bool
	// CloseStdin signals that once done, stdin for the attached stream should be closed
	// For example, this would close the attached container's stdin.
	CloseStdin bool
}

AttachConfig wraps backend.ContainerAttachConfig and adds other required fields Similar to https://github.com/docker/docker/blob/master/container/stream/attach.go

type ContainerProxy

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

ContainerProxy struct

func NewContainerProxy

func NewContainerProxy(plClient *client.PortLayer, portlayerAddr string, portlayerName string) *ContainerProxy

NewContainerProxy will create a new proxy

func (*ContainerProxy) AddContainerToScope

func (c *ContainerProxy) AddContainerToScope(ctx context.Context, handle string, config types.ContainerCreateConfig) (string, error)

AddContainerToScope adds a container, referenced by handle, to a scope. If an error is return, the returned handle should not be used.

returns:

modified handle

func (*ContainerProxy) AddInteractionToContainer

func (c *ContainerProxy) AddInteractionToContainer(ctx context.Context, handle string, config types.ContainerCreateConfig) (string, error)

AddInteractionToContainer adds interaction capabilities to a container, referenced by handle. If an error is return, the returned handle should not be used.

returns:

modified handle

func (*ContainerProxy) AddLoggingToContainer

func (c *ContainerProxy) AddLoggingToContainer(ctx context.Context, handle string, config types.ContainerCreateConfig) (string, error)

AddLoggingToContainer adds logging capability to a container, referenced by handle. If an error is return, the returned handle should not be used.

returns:

modified handle

func (*ContainerProxy) BindInteraction

func (c *ContainerProxy) BindInteraction(ctx context.Context, handle string, name string, id string) (string, error)

BindInteraction enables interaction capabilities

func (*ContainerProxy) BindTask

func (c *ContainerProxy) BindTask(op trace.Operation, handle string, eid string) (string, error)

func (*ContainerProxy) CommitContainerHandle

func (c *ContainerProxy) CommitContainerHandle(ctx context.Context, handle, containerID string, waitTime int32) error

CommitContainerHandle commits any changes to container handle.

Args:

waitTime <= 0 means no wait time

func (*ContainerProxy) CreateContainerHandle

func (c *ContainerProxy) CreateContainerHandle(ctx context.Context, vc *viccontainer.VicContainer, config types.ContainerCreateConfig) (string, string, error)

CreateContainerHandle creates a new VIC container by calling the portlayer

returns:

(containerID, containerHandle, error)

func (*ContainerProxy) CreateContainerTask

func (c *ContainerProxy) CreateContainerTask(ctx context.Context, handle, id string, config types.ContainerCreateConfig) (string, error)

CreateContainerTask sets the primary command to run in the container

returns:

(containerHandle, error)

func (*ContainerProxy) CreateExecTask

func (c *ContainerProxy) CreateExecTask(ctx context.Context, handle string, config *types.ExecConfig) (string, string, error)

func (*ContainerProxy) ExitCode

ExitCode returns container exitCode

func (*ContainerProxy) GetStateFromHandle

func (c *ContainerProxy) GetStateFromHandle(op trace.Operation, handle string) (string, string, error)

GetStateFromHandle takes a handle and returns the state of the container based on that handle. Also returns handle that comes back with the response.

func (*ContainerProxy) Handle

func (c *ContainerProxy) Handle(ctx context.Context, id, name string) (string, error)

Handle retrieves a handle to a VIC container. Handles should be treated as opaque strings.

returns:

(handle string, error)

func (*ContainerProxy) InspectTask

func (c *ContainerProxy) InspectTask(op trace.Operation, handle string, eid string, cid string) (*models.TaskInspectResponse, error)

func (*ContainerProxy) Remove

Remove calls the portlayer's ContainerRemove handler to remove the container and its anonymous volumes if the remove flag is set.

func (*ContainerProxy) Rename

func (c *ContainerProxy) Rename(ctx context.Context, vc *viccontainer.VicContainer, newName string) error

Rename calls the portlayer's RenameContainerHandler to update the container name in the handle, and then commit the new name to vSphere

func (*ContainerProxy) Resize

func (c *ContainerProxy) Resize(ctx context.Context, id string, height, width int32) error

func (*ContainerProxy) Signal

func (*ContainerProxy) State

State returns container state

func (*ContainerProxy) Stop

func (c *ContainerProxy) Stop(ctx context.Context, vc *viccontainer.VicContainer, name string, seconds *int, unbound bool) error

Stop will stop (shutdown) a VIC container.

returns

error

func (*ContainerProxy) UnbindContainerFromNetwork

func (c *ContainerProxy) UnbindContainerFromNetwork(ctx context.Context, vc *viccontainer.VicContainer, handle string) (string, error)

UnbindContainerFromNetwork unbinds a container from the networks that it connects to

func (*ContainerProxy) UnbindInteraction

func (c *ContainerProxy) UnbindInteraction(ctx context.Context, handle string, name string, id string) (string, error)

UnbindInteraction disables interaction capabilities

func (*ContainerProxy) Wait

func (*ContainerProxy) WaitTask

func (c *ContainerProxy) WaitTask(op trace.Operation, handle string, cid string, eid string) error

type StorageProxy

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

func (*StorageProxy) AddImageToContainer added in v1.5.0

func (s *StorageProxy) AddImageToContainer(ctx context.Context, handle, deltaID, layerID, imageID string, config types.ContainerCreateConfig) (string, error)

AddImageToContainer adds the specified image to a container, referenced by handle. If an error is returned, the returned handle should not be used. - deltaID is the ID to use for the read/write layer - it's expected that this does not exist - layerID is the parent layer for the delta layer and is expected to exist - imageID is the current label by which we address this image and is recorded as metadata - repoName is the repository for the image and is recorded as metadata returns:

modified handle

func (*StorageProxy) AddVolumesToContainer

func (s *StorageProxy) AddVolumesToContainer(ctx context.Context, handle string, config types.ContainerCreateConfig) (string, error)

AddVolumesToContainer adds volumes to a container, referenced by handle. If an error is returned, the returned handle should not be used.

returns:

modified handle

func (*StorageProxy) Create

func (s *StorageProxy) Create(ctx context.Context, name, driverName string, volumeData, labels map[string]string) (*types.Volume, error)

func (*StorageProxy) Remove

func (s *StorageProxy) Remove(ctx context.Context, name string) error

func (*StorageProxy) VolumeInfo

func (s *StorageProxy) VolumeInfo(ctx context.Context, name string) (*models.VolumeResponse, error)

func (*StorageProxy) VolumeList

func (s *StorageProxy) VolumeList(ctx context.Context, filter string) ([]*models.VolumeResponse, error)

type StreamProxy

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

func (*StreamProxy) AttachStreams

func (s *StreamProxy) AttachStreams(ctx context.Context, ac *AttachConfig, stdin io.ReadCloser, stdout, stderr io.Writer, autoclose bool) error

AttachStreams takes the the hijacked connections from the calling client and attaches them to the 3 streams from the portlayer's rest server. stdin, stdout, stderr are the hijacked connection autoclose controls whether the underlying client transport will be closed when stdout/stderr

func (*StreamProxy) StreamContainerLogs

func (s *StreamProxy) StreamContainerLogs(ctx context.Context, name string, out io.Writer, started chan struct{}, showTimestamps bool, followLogs bool, since int64, tailLines int64) error

StreamContainerLogs reads the log stream from the portlayer rest server and writes it directly to the io.Writer that is passed in.

func (*StreamProxy) StreamContainerStats

func (s *StreamProxy) StreamContainerStats(ctx context.Context, config *convert.ContainerStatsConfig) error

StreamContainerStats will provide a stream of container stats written to the provided io.Writer. Prior to writing to the provided io.Writer there will be a transformation from the portLayer representation of stats to the docker format

type SystemProxy

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

func (*SystemProxy) ContainerCount

func (s *SystemProxy) ContainerCount(ctx context.Context) (int, int, int, error)

Use the Portlayer's support for docker ps to get the container count

return order: running, paused, stopped counts

func (*SystemProxy) PingPortlayer

func (s *SystemProxy) PingPortlayer(ctx context.Context) bool

func (*SystemProxy) VCHInfo

func (s *SystemProxy) VCHInfo(ctx context.Context) (*models.VCHInfo, error)

type VicArchiveProxy

type VicArchiveProxy interface {
	ArchiveExportReader(op trace.Operation, store, ancestorStore, deviceID, ancestor string, data bool, filterSpec archive.FilterSpec) (io.ReadCloser, error)
	ArchiveImportWriter(op trace.Operation, store, deviceID string, filterSpec archive.FilterSpec, wg *sync.WaitGroup, errchan chan error) (io.WriteCloser, error)
	StatPath(op trace.Operation, store, deviceID string, filterSpec archive.FilterSpec) (*types.ContainerPathStat, error)
}

func GetArchiveProxy

func GetArchiveProxy() VicArchiveProxy

func NewArchiveProxy

func NewArchiveProxy(client *client.PortLayer) VicArchiveProxy

type VicContainerProxy

type VicContainerProxy interface {
	CreateContainerHandle(ctx context.Context, vc *viccontainer.VicContainer, config types.ContainerCreateConfig) (string, string, error)
	CreateContainerTask(ctx context.Context, handle string, id string, config types.ContainerCreateConfig) (string, error)
	CreateExecTask(ctx context.Context, handle string, config *types.ExecConfig) (string, string, error)
	AddContainerToScope(ctx context.Context, handle string, config types.ContainerCreateConfig) (string, error)
	AddLoggingToContainer(ctx context.Context, handle string, config types.ContainerCreateConfig) (string, error)
	AddInteractionToContainer(ctx context.Context, handle string, config types.ContainerCreateConfig) (string, error)

	BindInteraction(ctx context.Context, handle string, name string, id string) (string, error)
	UnbindInteraction(ctx context.Context, handle string, name string, id string) (string, error)
	UnbindContainerFromNetwork(ctx context.Context, vc *viccontainer.VicContainer, handle string) (string, error)
	CommitContainerHandle(ctx context.Context, handle, containerID string, waitTime int32) error

	// TODO: we should not be returning a swagger model here, however we do not have a solid architected return for this yet.
	InspectTask(op trace.Operation, handle string, eid string, cid string) (*models.TaskInspectResponse, error)
	BindTask(op trace.Operation, handle string, eid string) (string, error)
	WaitTask(op trace.Operation, handle string, cid string, eid string) error

	Handle(ctx context.Context, id, name string) (string, error)

	Stop(ctx context.Context, vc *viccontainer.VicContainer, name string, seconds *int, unbound bool) error
	State(ctx context.Context, vc *viccontainer.VicContainer) (*types.ContainerState, error)
	GetStateFromHandle(op trace.Operation, handle string) (string, string, error)
	Wait(ctx context.Context, vc *viccontainer.VicContainer, timeout time.Duration) (*types.ContainerState, error)
	Signal(ctx context.Context, vc *viccontainer.VicContainer, sig uint64) error
	Resize(ctx context.Context, id string, height, width int32) error
	Rename(ctx context.Context, vc *viccontainer.VicContainer, newName string) error
	Remove(ctx context.Context, vc *viccontainer.VicContainer, config *types.ContainerRmConfig) error

	ExitCode(ctx context.Context, vc *viccontainer.VicContainer) (string, error)
}

VicContainerProxy interface

type VicStorageProxy

type VicStorageProxy interface {
	Create(ctx context.Context, name, driverName string, volumeData, labels map[string]string) (*types.Volume, error)
	VolumeList(ctx context.Context, filter string) ([]*models.VolumeResponse, error)
	VolumeInfo(ctx context.Context, name string) (*models.VolumeResponse, error)
	Remove(ctx context.Context, name string) error

	AddImageToContainer(ctx context.Context, handle, deltaID, layerID, imageID string, config types.ContainerCreateConfig) (string, error)
	AddVolumesToContainer(ctx context.Context, handle string, config types.ContainerCreateConfig) (string, error)
}

func NewStorageProxy

func NewStorageProxy(client *client.PortLayer) VicStorageProxy

type VicStreamProxy

type VicStreamProxy interface {
	AttachStreams(ctx context.Context, ac *AttachConfig, stdin io.ReadCloser, stdout, stderr io.Writer, autoclose bool) error
	StreamContainerLogs(ctx context.Context, name string, out io.Writer, started chan struct{}, showTimestamps bool, followLogs bool, since int64, tailLines int64) error
	StreamContainerStats(ctx context.Context, config *convert.ContainerStatsConfig) error
}

func NewStreamProxy

func NewStreamProxy(client *client.PortLayer) VicStreamProxy

type VicSystemProxy

type VicSystemProxy interface {
	PingPortlayer(ctx context.Context) bool
	ContainerCount(ctx context.Context) (int, int, int, error)
	VCHInfo(ctx context.Context) (*models.VCHInfo, error)
}

func NewSystemProxy

func NewSystemProxy(client *client.PortLayer) VicSystemProxy

type VolumeMetadata

type VolumeMetadata struct {
	Driver        string
	DriverOpts    map[string]string
	Name          string
	Labels        map[string]string
	AttachHistory []string
	Image         string
}

Jump to

Keyboard shortcuts

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