Documentation ¶
Index ¶
- Constants
- Variables
- func ResolveServiceDependencies(cs []*Container) error
- func SplitNames(name string) (string, string, string)
- func TSort(G []*node) ([]*node, error)
- type Container
- func (c *Container) ActiveState(ctx context.Context) manifest.ActiveState
- func (c *Container) AddHost(ctx context.Context, host string, more ...string) error
- func (c *Container) Category() manifest.Category
- func (c *Container) DataDir() string
- func (c *Container) DependsOn() []string
- func (c *Container) Deploy(ctx context.Context, path string) error
- func (c *Container) DeployDir() string
- func (c *Container) Destroy(ctx context.Context) error
- func (c *Container) EnvDir() string
- func (c *Container) Exec(ctx context.Context, user string, stdin io.Reader, stdout, stderr io.Writer, ...) error
- func (c *Container) ExecE(ctx context.Context, user string, in io.Reader, out io.Writer, cmd ...string) error
- func (c *Container) ExecQ(ctx context.Context, user string, cmd ...string) error
- func (c *Container) FQDN() string
- func (c *Container) Flags() uint32
- func (c *Container) GetHosts(ctx context.Context) []string
- func (c *Container) GetInfo(ctx context.Context) (*manifest.SandboxInfo, error)
- func (c *Container) Getenv(ctx context.Context, name string) (string, error)
- func (c *Container) Home() string
- func (c *Container) Hostname() string
- func (c *Container) IP() (ip string)
- func (c *Container) Install(ctx context.Context, source string) error
- func (c *Container) LogDir() string
- func (c *Container) PluginTag() string
- func (c *Container) RemoveHost(ctx context.Context, host string, more ...string) error
- func (c *Container) RepoDir() string
- func (c *Container) Restart(ctx context.Context) error
- func (c *Container) ServiceName() string
- func (c *Container) Setenv(ctx context.Context, name, value string) error
- func (c *Container) Start(ctx context.Context) error
- func (c *Container) Stop(ctx context.Context) error
- func (c *Container) Subst(ctx context.Context, user string, in io.Reader, cmd ...string) (string, error)
- func (c *Container) User() string
- type CreateOptions
- type DockerClient
- func (cli DockerClient) Create(ctx context.Context, opts CreateOptions) ([]*Container, error)
- func (cli DockerClient) CreateBuilder(ctx context.Context, opts CreateOptions) (c *Container, err error)
- func (cli DockerClient) FindAll(ctx context.Context, name, namespace string) ([]*Container, error)
- func (cli DockerClient) FindApplications(ctx context.Context, name, namespace string) ([]*Container, error)
- func (cli DockerClient) FindService(ctx context.Context, name, namespace, service string) ([]*Container, error)
- func (cli DockerClient) Inspect(ctx context.Context, id string) (*Container, error)
- type JSONError
- type JSONMessage
- type JSONProgress
- type StatusError
- type StdType
Constants ¶
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" )
const EXTRA_HOSTS_KEY = "CLOUDWAY_EXTRA_HOSTS"
const (
HotDeployable uint32 = 1 << iota
)
Variables ¶
var ErrCircularReference = errors.New("Circular reference detected")
Functions ¶
func ResolveServiceDependencies ¶
Resolve service dependencies.
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) 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 ¶
Silently execute the command and accumulate error messages from standard error of the command.
Equivalent to: ExecE(user, nil, nil, cmd...)
func (*Container) RemoveHost ¶
func (*Container) ServiceName ¶
func (*Container) Setenv ¶
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.
type CreateOptions ¶
type DockerClient ¶
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) 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.
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.
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 ¶
StatusError reports an unsuccessful exit by a command
func (StatusError) Error ¶
func (e StatusError) Error() string