Documentation
¶
Index ¶
- Constants
- type BlockDevice
- type Command
- type DiskInterface
- type DockerInterface
- type FSInterface
- type LocalRunner
- func (r *LocalRunner) Exec(ctx context.Context, cmd string, args ...string) (string, error)
- func (r *LocalRunner) NonSudoExec(ctx context.Context, command string, args ...string) (string, error)
- func (r *LocalRunner) Scp(ctx context.Context, local, remote string) error
- func (r *LocalRunner) Stat(path string) (os.FileInfo, error)
- type LocalRunnerCfg
- type Manager
- type NetInterface
- type NewManagerFunc
- type OsInterface
- type PublishArgs
- type RemoteRunner
- func (r *RemoteRunner) Close()
- func (r *RemoteRunner) Exec(ctx context.Context, command string, args ...string) (string, error)
- func (r *RemoteRunner) NonSudoExec(ctx context.Context, command string, args ...string) (string, error)
- func (r *RemoteRunner) Scp(ctx context.Context, local, remote string) error
- func (r *RemoteRunner) Stat(path string) (os.FileInfo, error)
- type RemoteRunnerCfg
- type RunArgs
- type RunError
- type RunnerInterface
- type VolumeArgs
Constants ¶
const ( ContainerRestartPolicyDefault = "" ContainerRestartPolicyAlways = "always" ContainerRestartPolicyUnlessStopped = "unless-stopped" )
Container restart policy defines
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockDevice ¶ added in v0.3.0
type BlockDevice struct {
Name string `json:"name"`
Label string `json:"label"`
Size int64 `json:"size"`
Serial string `json:"serial"`
Children []BlockDevice `json:"children,omitempty"`
}
BlockDevice represents a block device on the system, including its name, label, size, serial number, and any child devices.
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command define command
func NewCommand ¶
NewCommand inits a new command
func (*Command) AppendArgs ¶
AppendArgs append new args to current args
type DiskInterface ¶
type DiskInterface interface {
GetNvmeDisks() ([]string, error)
ListBlockDevices(ctx context.Context) ([]BlockDevice, error)
}
DiskInterface provides interface about disk.
type DockerInterface ¶
type DockerInterface interface {
GetContainer(string) string
Run(ctx context.Context, args *RunArgs) (out string, err error)
Cp(ctx context.Context, src, container, containerPath string) error
Rm(ctx context.Context, name string, force bool) (out string, err error)
Exec(context.Context, string, string, ...string) (out string, err error)
Load(ctx context.Context, path string) (out string, err error)
Tag(ctx context.Context, src, dst string) error
}
DockerInterface provides interface about docker.
type FSInterface ¶
type FSInterface interface {
MkdirTemp(context.Context, string, string) (string, error)
MkTempFile(context.Context, string) (string, error)
MkdirAll(context.Context, string) error
RemoveAll(context.Context, string) error
ReadFile(context.Context, string) (string, error)
WriteFile(string, []byte, os.FileMode) error
DownloadFile(string, string) error
ReadRemoteFile(string) (string, error)
IsNotExist(string) (bool, error)
Sha256sum(context.Context, string) (string, error)
Tar(srcPaths []string, basePath, dstPath string, needGzip bool) error
ExtractTar(ctx context.Context, srcPath, dstDir string) error
}
FSInterface provides interface about local fs, this is not implemented for remote runner.
type LocalRunner ¶
type LocalRunner struct {
// contains filtered or unexported fields
}
LocalRunner implements RunInterface by running command on local host.
func NewLocalRunner ¶
func NewLocalRunner(cfg *LocalRunnerCfg) *LocalRunner
NewLocalRunner creates a local runner.
func (*LocalRunner) NonSudoExec ¶
func (r *LocalRunner) NonSudoExec(ctx context.Context, command string, args ...string) (string, error)
NonSudoExec executes a command.
type LocalRunnerCfg ¶
type LocalRunnerCfg struct {
Logger log.Interface
MaxExitTimeout *time.Duration
User string
Password string
}
LocalRunnerCfg defines configurations of a local runner.
type Manager ¶
type Manager struct {
Runner RunnerInterface
Os OsInterface
Net NetInterface
Docker DockerInterface
Disk DiskInterface
FS FSInterface
}
Manager provides a way to use all external interfaces
func NewManager ¶
func NewManager(runner RunnerInterface, logger log.Interface) (em *Manager)
NewManager create a new external manager
type NetInterface ¶
NetInterface provides interface about network.
type OsInterface ¶ added in v0.3.0
OsInterface provides interface about os.
type PublishArgs ¶
PublishArgs defines args for publishing a container port.
type RemoteRunner ¶
type RemoteRunner struct {
// contains filtered or unexported fields
}
RemoteRunner implements RunInterface by running command on a remote host.
func NewRemoteRunner ¶
func NewRemoteRunner(cfg *RemoteRunnerCfg) (*RemoteRunner, error)
NewRemoteRunner creates a remote runner.
func (*RemoteRunner) NonSudoExec ¶
func (r *RemoteRunner) NonSudoExec(ctx context.Context, command string, args ...string) (string, error)
NonSudoExec executes a command.
type RemoteRunnerCfg ¶
type RemoteRunnerCfg struct {
Username string
Password *string
TargetHost string
TargetPort int
PrivateKey *string
Logger log.Interface
Timeout time.Duration
}
RemoteRunnerCfg defines configurations of a remote runner.
type RunArgs ¶
type RunArgs struct {
Image string
HostNetwork bool
Entrypoint *string
Rm *bool
Command []string
Privileged *bool
Ulimits map[string]string
Name *string
Detach *bool
Publish []*PublishArgs
Volumes []*VolumeArgs
Envs map[string]string
RestartPolicy string
}
RunArgs defines args for docker run command.
type RunError ¶
type RunError interface {
ExitCode() int
Error() string
ExitCodeEquals(syscall.Errno) bool
ExitCodeIn(...syscall.Errno) bool
}
RunError is the wrapper of os.exec error, it export error code
func NewRunError ¶
NewRunError is used to get the RunError
type RunnerInterface ¶
type RunnerInterface interface {
NonSudoExec(ctx context.Context, command string, args ...string) (string, error)
Exec(ctx context.Context, command string, args ...string) (string, error)
Scp(ctx context.Context, local, remote string) error
Stat(path string) (os.FileInfo, error)
}
RunnerInterface is the interface for running command.
type VolumeArgs ¶
VolumeArgs defines args for binding a volume.