container

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2016 License: GPL-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APP_NAME_KEY        = "com.cloudway.app.name"
	APP_NAMESPACE_KEY   = "com.cloudway.app.namespace"
	APP_HOME_KEY        = "com.cloudway.app.home"
	CATEGORY_KEY        = "com.cloudway.container.category"
	PLUGIN_KEY          = "com.cloudway.container.plugin"
	FLAGS_KEY           = "com.cloudway.container.flags"
	SERVICE_NAME_KEY    = "com.cloudway.service.name"
	SERVICE_DEPENDS_KEY = "com.cloudway.service.depends"
)
View Source
const EXTRA_HOSTS_KEY = "CLOUDWAY_EXTRA_HOSTS"
View Source
const (
	HotDeployable uint32 = 1 << iota
)

Variables

View Source
var ErrCircularReference = errors.New("Circular reference detected")

Functions

func ResolveServiceDependencies

func ResolveServiceDependencies(cs []*Container) error

Resolve service dependencies.

func SplitNames

func SplitNames(name string) (string, string, string)

func TSort

func TSort(G []*node) ([]*node, error)

Kahn's algorithm. See https://en.wikipedia.org/wiki/Topological_sorting

Types

type Container

type Container struct {
	Name      string
	Namespace string

	DockerClient
	*types.ContainerJSON
}

func (*Container) ActiveState

func (c *Container) ActiveState(ctx context.Context) manifest.ActiveState

func (*Container) AddHost

func (c *Container) AddHost(ctx context.Context, host string, more ...string) error

func (*Container) Category

func (c *Container) Category() manifest.Category

func (*Container) DataDir

func (c *Container) DataDir() string

func (*Container) DependsOn

func (c *Container) DependsOn() []string

func (*Container) Deploy

func (c *Container) Deploy(ctx context.Context, path string) error

func (*Container) DeployDir

func (c *Container) DeployDir() string

func (*Container) Destroy

func (c *Container) Destroy(ctx context.Context) error

Destroy the application container.

func (*Container) EnvDir

func (c *Container) EnvDir() string

Returns the env directory of the container.

func (*Container) Exec

func (c *Container) Exec(ctx context.Context, user string, stdin io.Reader, stdout, stderr io.Writer, cmd ...string) error

Execute command in application container.

func (*Container) ExecE

func (c *Container) ExecE(ctx context.Context, user string, in io.Reader, out io.Writer, cmd ...string) error

Execute the command and accumulate error messages from standard error of the command.

func (*Container) ExecQ

func (c *Container) ExecQ(ctx context.Context, user string, cmd ...string) error

Silently execute the command and accumulate error messages from standard error of the command.

Equivalent to: ExecE(user, nil, nil, cmd...)

func (*Container) FQDN

func (c *Container) FQDN() string

Returns the fully qualified domain name of the container.

func (*Container) Flags

func (c *Container) Flags() uint32

func (*Container) GetHosts

func (c *Container) GetHosts(ctx context.Context) []string

func (*Container) GetInfo

func (c *Container) GetInfo(ctx context.Context) (*manifest.SandboxInfo, error)

Get application information from container.

func (*Container) Getenv

func (c *Container) Getenv(ctx context.Context, name string) (string, error)

Get an environment variable value.

func (*Container) Home

func (c *Container) Home() string

Returns the application home directory within the container.

func (*Container) Hostname

func (c *Container) Hostname() string

Returns the host name of the container.

func (*Container) IP

func (c *Container) IP() (ip string)

Returns the IP address of the container

func (*Container) Install

func (c *Container) Install(ctx context.Context, source string) error

func (*Container) LogDir

func (c *Container) LogDir() string

func (*Container) PluginTag

func (c *Container) PluginTag() string

func (*Container) RemoveHost

func (c *Container) RemoveHost(ctx context.Context, host string, more ...string) error

func (*Container) RepoDir

func (c *Container) RepoDir() string

func (*Container) Restart

func (c *Container) Restart(ctx context.Context) error

Restart the application container.

func (*Container) ServiceName

func (c *Container) ServiceName() string

func (*Container) Setenv

func (c *Container) Setenv(ctx context.Context, name, value string) error

Adds the variable to the environment with the value, if name does not exists. If name does exist in the environment, then its value is changed to value.

func (*Container) Start

func (c *Container) Start(ctx context.Context) error

Start the application container.

func (*Container) Stop

func (c *Container) Stop(ctx context.Context) error

Stop the application container.

func (*Container) Subst

func (c *Container) Subst(ctx context.Context, user string, in io.Reader, cmd ...string) (string, error)

Performs the expansion by executing command and return the contents as the standard output of the command, with any trailing newlines deleted.

func (*Container) User

func (c *Container) User() string

Returns the container's operating system user that running the application.

type CreateOptions

type CreateOptions struct {
	Name        string
	Namespace   string
	ServiceName string
	Plugin      *manifest.Plugin
	Image       string
	Flags       uint32
	Secret      string
	Home        string
	User        string
	Network     string
	Capacity    string
	Scaling     int
	Hosts       []string
	Env         map[string]string
	Repo        string
	Logger      io.Writer
}

type DockerClient

type DockerClient struct {
	*client.Client
}

func NewClient

func NewClient(cli *client.Client) DockerClient

func NewEnvClient

func NewEnvClient() (DockerClient, error)

func (DockerClient) Create

func (cli DockerClient) Create(ctx context.Context, opts CreateOptions) ([]*Container, error)

Create new application containers.

func (DockerClient) CreateBuilder

func (cli DockerClient) CreateBuilder(ctx context.Context, opts CreateOptions) (c *Container, err error)

Create a builder container.

func (DockerClient) FindAll

func (cli DockerClient) FindAll(ctx context.Context, name, namespace string) ([]*Container, error)

Find all containers with the given name and namespace.

func (DockerClient) FindApplications

func (cli DockerClient) FindApplications(ctx context.Context, name, namespace string) ([]*Container, error)

Find all application containers with the given name and namespace.

func (DockerClient) FindService

func (cli DockerClient) FindService(ctx context.Context, name, namespace, service string) ([]*Container, error)

Find service container with the give name, namespace and service name.

func (DockerClient) Inspect

func (cli DockerClient) Inspect(ctx context.Context, id string) (*Container, error)

Returns an application container object constructed from the container id in the system.

type JSONError

type JSONError struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

JSONError wraps a concrete Code and Message, `Code` is a integer error code, `Message` is the error message.

func (*JSONError) Error

func (e *JSONError) Error() string

type JSONMessage

type JSONMessage struct {
	Stream          string        `json:"stream,omitempty"`
	Status          string        `json:"status,omitempty"`
	Progress        *JSONProgress `json:"progressDtail,omitempty"`
	ProgressMessage string        `json:"progress,omitempty"`
	ID              string        `json:"id,omitempty"`
	From            string        `json:"from,omitempty"`
	Time            int64         `json:"time,omitempty"`
	TimeNano        int64         `json:"timeNano,omitempty"`
	Error           *JSONError    `json:"errorDetail,omitempty"`
	ErrorMessage    string        `json:"error,omitempty"` // deprecated
	// Aux contains out-of-band data, such as digests for push signing.
	Aux *json.RawMessage `json:"aux,omitempty"`
}

JSONMessage defines a message struct. It describes the created time, where it from, status, ID of the message. It's used for docker events.

type JSONProgress

type JSONProgress struct {
	Current int64 `json:"current,omitempty"`
	Total   int64 `json:"total,omitempty"`
	Start   int64 `json:"start,omitempty"`
}

JSONProgress describes a Progress. Start is the initial value for the operation. Current is the current terminal, value of the progress made towards Total. Total is the end value describing when we made 100% progress for an operation.

type StatusError

type StatusError struct {
	Command []string
	Code    int
	Message string
}

StatusError reports an unsuccessful exit by a command

func (StatusError) Error

func (e StatusError) Error() string

type StdType

type StdType byte

StdType is the type of standard stream a writer can multiplex to.

const (
	// Stdin represents standard input stream type.
	Stdin StdType = iota
	// Stdout represents standard output stream type.
	Stdout
	// Stderr represents standard error stream type.
	Stderr
)

Jump to

Keyboard shortcuts

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