Documentation ¶
Index ¶
- Constants
- Variables
- func ContainerInfoToDockerContainerInspect(vc *viccontainer.VicContainer, info *models.ContainerInfo, ...) (*types.ContainerJSON, error)
- func ContainerInfoToVicContainer(info models.ContainerInfo, portlayerName string) *viccontainer.VicContainer
- func MountsFromContainer(vc *viccontainer.VicContainer) []types.MountPoint
- func NewPortLayerClient(portLayerAddr string) *apiclient.PortLayer
- func NewVolumeModel(volume *models.VolumeResponse, labels map[string]string) *types.Volume
- func RemoveAnonContainerVols(ctx context.Context, pl *client.PortLayer, cID string, ...)
- type ArchiveProxy
- func (a *ArchiveProxy) ArchiveExportReader(op trace.Operation, store, ancestorStore, deviceID, ancestor string, data bool, ...) (io.ReadCloser, error)
- func (a *ArchiveProxy) ArchiveImportWriter(op trace.Operation, store, deviceID string, filterSpec archive.FilterSpec, ...) (io.WriteCloser, error)
- func (a *ArchiveProxy) StatPath(op trace.Operation, store, deviceID string, filterSpec archive.FilterSpec) (*types.ContainerPathStat, error)
- type AttachConfig
- type ContainerProxy
- func (c *ContainerProxy) AddContainerToScope(ctx context.Context, handle string, config types.ContainerCreateConfig) (string, error)
- func (c *ContainerProxy) AddInteractionToContainer(ctx context.Context, handle string, config types.ContainerCreateConfig) (string, error)
- func (c *ContainerProxy) AddLoggingToContainer(ctx context.Context, handle string, config types.ContainerCreateConfig) (string, error)
- func (c *ContainerProxy) BindInteraction(ctx context.Context, handle string, name string, id string) (string, error)
- func (c *ContainerProxy) BindTask(op trace.Operation, handle string, eid string) (string, error)
- func (c *ContainerProxy) CommitContainerHandle(ctx context.Context, handle, containerID string, waitTime int32) error
- func (c *ContainerProxy) CreateContainerHandle(ctx context.Context, vc *viccontainer.VicContainer, ...) (string, string, error)
- func (c *ContainerProxy) CreateContainerTask(ctx context.Context, handle, id string, config types.ContainerCreateConfig) (string, error)
- func (c *ContainerProxy) CreateExecTask(ctx context.Context, handle string, config *types.ExecConfig) (string, string, error)
- func (c *ContainerProxy) ExitCode(ctx context.Context, vc *viccontainer.VicContainer) (string, error)
- func (c *ContainerProxy) GetStateFromHandle(op trace.Operation, handle string) (string, string, error)
- func (c *ContainerProxy) Handle(ctx context.Context, id, name string) (string, error)
- func (c *ContainerProxy) InspectTask(op trace.Operation, handle string, eid string, cid string) (*models.TaskInspectResponse, error)
- func (c *ContainerProxy) Remove(ctx context.Context, vc *viccontainer.VicContainer, ...) error
- func (c *ContainerProxy) Rename(ctx context.Context, vc *viccontainer.VicContainer, newName string) error
- func (c *ContainerProxy) Resize(ctx context.Context, id string, height, width int32) error
- func (c *ContainerProxy) Signal(ctx context.Context, vc *viccontainer.VicContainer, sig uint64) error
- func (c *ContainerProxy) State(ctx context.Context, vc *viccontainer.VicContainer) (*types.ContainerState, error)
- func (c *ContainerProxy) Stop(ctx context.Context, vc *viccontainer.VicContainer, name string, seconds *int, ...) error
- func (c *ContainerProxy) UnbindContainerFromNetwork(ctx context.Context, vc *viccontainer.VicContainer, handle string) (string, error)
- func (c *ContainerProxy) UnbindInteraction(ctx context.Context, handle string, name string, id string) (string, error)
- func (c *ContainerProxy) Wait(ctx context.Context, vc *viccontainer.VicContainer, timeout time.Duration) (*types.ContainerState, error)
- func (c *ContainerProxy) WaitTask(op trace.Operation, cid string, cname string, eid string) error
- type StorageProxy
- func (s *StorageProxy) AddVolumesToContainer(ctx context.Context, handle string, config types.ContainerCreateConfig) (string, error)
- func (s *StorageProxy) Create(ctx context.Context, name, driverName string, ...) (*types.Volume, error)
- func (s *StorageProxy) Remove(ctx context.Context, name string) error
- func (s *StorageProxy) VolumeInfo(ctx context.Context, name string) (*models.VolumeResponse, error)
- func (s *StorageProxy) VolumeList(ctx context.Context, filter string) ([]*models.VolumeResponse, error)
- type StreamProxy
- func (s *StreamProxy) AttachStreams(ctx context.Context, ac *AttachConfig, stdin io.ReadCloser, ...) error
- func (s *StreamProxy) StreamContainerLogs(ctx context.Context, name string, out io.Writer, started chan struct{}, ...) error
- func (s *StreamProxy) StreamContainerStats(ctx context.Context, config *convert.ContainerStatsConfig) error
- type SystemProxy
- type VicArchiveProxy
- type VicContainerProxy
- type VicStorageProxy
- type VicStreamProxy
- type VicSystemProxy
- type VolumeMetadata
Constants ¶
const ( ShortIDLen = 12 ContainerRunning = "running" ContainerError = "error" ContainerStopped = "stopped" ContainerExited = "exited" ContainerCreated = "created" )
const ( DriverArgFlagKey = "flags" DriverArgContainerKey = "container" DriverArgImageKey = "image" OptsVolumeStoreKey string = "volumestore" OptsCapacityKey string = "capacity" DockerMetadataModelKey string = "DockerMetaData" )
const (
SwaggerSubstringEOF = "EOF"
)
Variables ¶
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 NewVolumeModel ¶
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) 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 ¶
func (c *ContainerProxy) ExitCode(ctx context.Context, vc *viccontainer.VicContainer) (string, error)
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 ¶
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 ¶
func (c *ContainerProxy) Remove(ctx context.Context, vc *viccontainer.VicContainer, config *types.ContainerRmConfig) error
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) Signal ¶
func (c *ContainerProxy) Signal(ctx context.Context, vc *viccontainer.VicContainer, sig uint64) error
func (*ContainerProxy) State ¶
func (c *ContainerProxy) State(ctx context.Context, vc *viccontainer.VicContainer) (*types.ContainerState, error)
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 (c *ContainerProxy) Wait(ctx context.Context, vc *viccontainer.VicContainer, timeout time.Duration) ( *types.ContainerState, error)
type StorageProxy ¶
type StorageProxy struct {
// contains filtered or unexported fields
}
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) 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) 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
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 ¶
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
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, cid string, cname 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 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) 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