2023-06-26 01:11:05 +00:00
|
|
|
package libstack
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Deployer interface {
|
|
|
|
Deploy(ctx context.Context, filePaths []string, options DeployOptions) error
|
|
|
|
// Remove stops and removes containers
|
|
|
|
//
|
|
|
|
// projectName or filePaths are required
|
|
|
|
// if projectName is supplied filePaths will be ignored
|
|
|
|
Remove(ctx context.Context, projectName string, filePaths []string, options Options) error
|
|
|
|
Pull(ctx context.Context, filePaths []string, options Options) error
|
|
|
|
Validate(ctx context.Context, filePaths []string, options Options) error
|
2024-04-30 01:44:14 +00:00
|
|
|
WaitForStatus(ctx context.Context, name string, status Status) <-chan WaitResult
|
2023-06-26 01:11:05 +00:00
|
|
|
}
|
|
|
|
|
2023-07-13 20:55:52 +00:00
|
|
|
type Status string
|
|
|
|
|
|
|
|
const (
|
2024-04-30 01:44:14 +00:00
|
|
|
StatusUnknown Status = "unknown"
|
|
|
|
StatusStarting Status = "starting"
|
|
|
|
StatusRunning Status = "running"
|
|
|
|
StatusStopped Status = "stopped"
|
|
|
|
StatusError Status = "error"
|
|
|
|
StatusRemoving Status = "removing"
|
|
|
|
StatusRemoved Status = "removed"
|
|
|
|
StatusCompleted Status = "completed"
|
2023-07-13 20:55:52 +00:00
|
|
|
)
|
|
|
|
|
2024-04-30 01:44:14 +00:00
|
|
|
type WaitResult struct {
|
|
|
|
Status Status
|
|
|
|
ErrorMsg string
|
|
|
|
}
|
|
|
|
|
2023-06-26 01:11:05 +00:00
|
|
|
type Options struct {
|
|
|
|
WorkingDir string
|
|
|
|
Host string
|
|
|
|
ProjectName string
|
|
|
|
// EnvFilePath is the path to a .env file
|
|
|
|
EnvFilePath string
|
|
|
|
// Env is a list of environment variables to pass to the command, example: "FOO=bar"
|
|
|
|
Env []string
|
|
|
|
}
|
|
|
|
|
|
|
|
type DeployOptions struct {
|
|
|
|
Options
|
|
|
|
ForceRecreate bool
|
|
|
|
// AbortOnContainerExit will stop the deployment if a container exits.
|
|
|
|
// This is useful when running a onetime task.
|
|
|
|
//
|
|
|
|
// When this is set, docker compose will output its logs to stdout
|
|
|
|
AbortOnContainerExit bool ``
|
|
|
|
}
|