plan

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPlanNotAvailable = errors.New(`plan for given action is not available`)
)

Functions

func NewShellVars

func NewShellVars(src devenv.Variables) []string

Types

type Action

type Action string
const (
	ActionStart   Action = "start"
	ActionStop    Action = "stop"
	ActionRestart Action = "restart"
)

type ComposePlanMetadata

type ComposePlanMetadata struct {
	Profile       *devenv.Profile
	Variables     devenv.Variables
	Vars          map[string]string
	WorkingDir    string
	DockerVersion types.Version
	ComposePath   string
	ResourceDir   string
	LocalDataDir  string
}

func (ComposePlanMetadata) Project

func (m ComposePlanMetadata) Project() *devenv.Profile

Project is an alias of Profile

type ComposeShellExecutable

type ComposeShellExecutable struct {
	Args []string
	WD   string
	Env  []string
	Desc string
}

ComposeShellExecutable ShellExecutable variant with special dry-run strategy for docker compose CLI

func (ComposeShellExecutable) Exec

func (exec ComposeShellExecutable) Exec(ctx context.Context, opts ExecOption) error

func (ComposeShellExecutable) String

func (exec ComposeShellExecutable) String() string

type ContainerMonitorExecutable

type ContainerMonitorExecutable struct {
	ApiClient *client.Client
	Names     []string
	Resolver  ContainerResolver
	Desc      string
	// contains filtered or unexported fields
}

func NewContainerMonitorExecutable

func NewContainerMonitorExecutable(client *client.Client, opts ...func(exec *ContainerMonitorExecutable)) *ContainerMonitorExecutable

func (*ContainerMonitorExecutable) Exec

func (*ContainerMonitorExecutable) String

func (exec *ContainerMonitorExecutable) String() string

func (*ContainerMonitorExecutable) WithTimeout

func (exec *ContainerMonitorExecutable) WithTimeout(timeout time.Duration) Executable

type ContainerResolver

type ContainerResolver func(name string, c *types.Container) string

func ComposeContainerResolver

func ComposeContainerResolver(profileName string) ContainerResolver

func ExactNameContainerResolver

func ExactNameContainerResolver() ContainerResolver

type DockerComposePlanner

type DockerComposePlanner struct {
	// WorkingDir the working directory. Usually is the temporary dir configured by rootcmd.GlobalArgs
	WorkingDir string
	Profile    *devenv.Profile
	// contains filtered or unexported fields
}

func NewDockerComposePlanner

func NewDockerComposePlanner(p *devenv.Profile, wd string) *DockerComposePlanner

func (*DockerComposePlanner) Plan

func (pl *DockerComposePlanner) Plan(action Action) (ExecutionPlan, error)

func (*DockerComposePlanner) Prepare

func (pl *DockerComposePlanner) Prepare() (err error)

type ExecOption

type ExecOption struct {
	Verbose bool
	DryRun  bool
}
var DefaultExecOption ExecOption

type ExecOptions

type ExecOptions func(opt *ExecOption)

type Executable

type Executable interface {
	Exec(ctx context.Context, opts ExecOption) error
}

func NewContainerHookExecutables

func NewContainerHookExecutables(dockerClient *dockerclient.Client, phase devenv.HookPhase,
	_ ComposePlanMetadata, cResolver ContainerResolver, hooks ...devenv.Hook) ([]Executable, error)

NewContainerHookExecutables create an executable that monitor existing containers and wait for it to stop Note: Currently, we don't support manually start containers. So the hook containers should be started.

Therefore, only post-start containers are possible.

func NewScriptHookExecutables

func NewScriptHookExecutables(hook devenv.Hook, wd string, vars []string, searchDirs ...string) ([]Executable, error)

type ExecutionPlan

type ExecutionPlan interface {
	Steps() []Executable
	Metadata() interface{}
	Execute(ctx context.Context, opts ...ExecOptions) error
}

func NewClosableExecutionPlan

func NewClosableExecutionPlan(metadata interface{}, closerFunc func() error, execs ...Executable) ExecutionPlan

func NewExecutionPlan

func NewExecutionPlan(metadata interface{}, execs ...Executable) ExecutionPlan

type ExecutionPlanner

type ExecutionPlanner interface {
	Plan(action Action) (ExecutionPlan, error)
}

type MkdirExecutable

type MkdirExecutable struct {
	Paths []string
	Desc  string
}

func (MkdirExecutable) Exec

func (exec MkdirExecutable) Exec(ctx context.Context, opts ExecOption) error

func (MkdirExecutable) String

func (exec MkdirExecutable) String() string

type PrintExecutable

type PrintExecutable string

func (PrintExecutable) Exec

func (exec PrintExecutable) Exec(ctx context.Context, opts ExecOption) error

func (PrintExecutable) String

func (exec PrintExecutable) String() string

type PruneContainersExecutable

type PruneContainersExecutable struct {
	ApiClient *dockerclient.Client
	// contains filtered or unexported fields
}

func (*PruneContainersExecutable) Exec

func (*PruneContainersExecutable) String

func (exec *PruneContainersExecutable) String() string

type PruneImagesExecutable

type PruneImagesExecutable struct {
	ApiClient *dockerclient.Client
	// contains filtered or unexported fields
}

func (*PruneImagesExecutable) Exec

func (exec *PruneImagesExecutable) Exec(ctx context.Context, opts ExecOption) error

func (*PruneImagesExecutable) String

func (exec *PruneImagesExecutable) String() string

type PruneVolumesExecutable

type PruneVolumesExecutable struct {
	ApiClient *dockerclient.Client
	// contains filtered or unexported fields
}

func (*PruneVolumesExecutable) Exec

func (exec *PruneVolumesExecutable) Exec(ctx context.Context, opts ExecOption) error

func (*PruneVolumesExecutable) String

func (exec *PruneVolumesExecutable) String() string

type ShellExecutable

type ShellExecutable struct {
	Cmds []string
	WD   string
	Env  []string
	Desc string
}

func (ShellExecutable) Exec

func (exec ShellExecutable) Exec(ctx context.Context, opts ExecOption) error

func (ShellExecutable) String

func (exec ShellExecutable) String() string

func (ShellExecutable) WithCommands

func (exec ShellExecutable) WithCommands(cmds ...string) *ShellExecutable

type TimeoutExecutableWrapper

type TimeoutExecutableWrapper struct {
	Timeout  time.Duration
	Delegate Executable
}

func (TimeoutExecutableWrapper) Exec

func (TimeoutExecutableWrapper) String

func (exec TimeoutExecutableWrapper) String() string

Jump to

Keyboard shortcuts

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