task

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedRollback means the task do not support rollback.
	ErrUnsupportedRollback = stderrors.New("unsupported rollback")
	// ErrNoExecutor means not being able to get the executor.
	ErrNoExecutor = stderrors.New("no executor")
	// ErrNoOutput means not being able to get the output of host.
	ErrNoOutput = stderrors.New("no outputs available")
)
View Source
var (

	// ErrEnvInitFailed is ErrEnvInitFailed
	ErrEnvInitFailed = errNSEnvInit.NewType("failed")
)

Functions

This section is empty.

Types

type Builder

type Builder struct {
	Logger *logprinter.Logger
	// contains filtered or unexported fields
}

Builder is used to build task

func NewBuilder

func NewBuilder(logger *logprinter.Logger) *Builder

NewBuilder returns a *Builder instance

func NewSimpleUerSSH

func NewSimpleUerSSH(logger *logprinter.Logger, host string, port int, user string, sshTimeout, exeTimeout uint64) *Builder

NewSimpleUerSSH append a UserSSH task to the current task collection with operator.Options and SSHConnectionProps

func (*Builder) Build

func (b *Builder) Build() Task

Build returns a task that contains all tasks appended by previous operation

func (*Builder) BuildAsStep

func (b *Builder) BuildAsStep(prefix string) *StepDisplay

BuildAsStep returns a task that is wrapped by a StepDisplay. The task will print single line progress.

func (*Builder) ClusterSSH

func (b *Builder) ClusterSSH(
	topo spec.Topology,
	deployUser string, sshTimeout, exeTimeout uint64) *Builder

ClusterSSH init all UserSSH need for the cluster.

func (*Builder) CopyComponent

func (b *Builder) CopyComponent(pkgSrc, component, os, arch string,
	version string,
	srcPath, dstHost, dstDir string,
) *Builder

CopyComponent appends a CopyComponent task to the current task collection

func (*Builder) Download

func (b *Builder) Download(component, os, arch string, version string) *Builder

Download appends a Downloader task to the current task collection

func (*Builder) EnvInit

func (b *Builder) EnvInit(host, deployUser string, userGroup string) *Builder

EnvInit appends a EnvInit task to the current task collection

func (*Builder) Func

func (b *Builder) Func(name string, fn func(ctx context.Context) error) *Builder

Func append a func task.

func (*Builder) InitConfig

func (b *Builder) InitConfig(clusterName, clusterVersion string, specManager *spec.SpecManager, inst spec.Instance, deployUser string, ignoreCheck bool, paths meta.DirPaths) *Builder

InitConfig appends a CopyComponent task to the current task collection

func (*Builder) Mkdir

func (b *Builder) Mkdir(user, host string, dirs ...string) *Builder

Mkdir appends a Mkdir task to the current task collection

func (*Builder) MonitoredConfig

func (b *Builder) MonitoredConfig(clusterName, comp, host string, info *spec.MonitorHostInfo, globResCtl meta.ResourceControl, options *spec.TSMonitoredOptions, deployUser string, tlsEnabled bool, paths meta.DirPaths) *Builder

MonitoredConfig appends a CopyComponent task to the current task collection

func (*Builder) Parallel

func (b *Builder) Parallel(ignoreError bool, tasks ...Task) *Builder

Parallel appends a parallel task to the current task collection

func (*Builder) ParallelStep

func (b *Builder) ParallelStep(prefix string, ignoreError bool, tasks ...*StepDisplay) *Builder

ParallelStep appends a new ParallelStepDisplay task, which will print multi line progress in parallel for inner tasks. Inner tasks must be a StepDisplay task.

func (*Builder) RootSSH

func (b *Builder) RootSSH(
	host string, port int, user, password, keyFile, passphrase string, sshTimeout, exeTimeout uint64) *Builder

RootSSH appends a RootSSH task to the current task collection

func (*Builder) SSHKeyGen

func (b *Builder) SSHKeyGen(keypath string) *Builder

SSHKeyGen appends a SSHKeyGen task to the current task collection

func (*Builder) SSHKeySet

func (b *Builder) SSHKeySet(privKeyPath, pubKeyPath string) *Builder

SSHKeySet appends a SSHKeySet task to the current task collection

func (*Builder) Serial

func (b *Builder) Serial(tasks ...Task) *Builder

Serial appends the tasks to the tail of queue

func (*Builder) Step

func (b *Builder) Step(prefix string, inner Task, logger *logprinter.Logger) *Builder

Step appends a new StepDisplay task, which will print single line progress for inner tasks.

func (*Builder) UserAction

func (b *Builder) UserAction(host, deployUser string, userGroup string, skipCreateUser bool) *Builder

UserAction appends a UserAction task to the current task collection

func (*Builder) UserSSH

func (b *Builder) UserSSH(host string, port int, deployUser string, sshTimeout, exeTimeout uint64) *Builder

UserSSH append a UserSSH task to the current task collection

type CopyComponent

type CopyComponent struct {
	// contains filtered or unexported fields
}

CopyComponent is used to copy all files related the specific version a component to the target directory of path

func (*CopyComponent) Execute

func (c *CopyComponent) Execute(ctx context.Context) error

Execute implements the Task interface

func (*CopyComponent) Rollback

func (c *CopyComponent) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (*CopyComponent) String

func (c *CopyComponent) String() string

String implements the fmt.Stringer interface

type Downloader

type Downloader struct {
	// contains filtered or unexported fields
}

Downloader is used to download the specific version of a component from the repository, there is nothing to do if the specified version exists.

func NewDownloader

func NewDownloader(component string, os string, arch string, version string) *Downloader

NewDownloader create a Downloader instance.

func (*Downloader) Execute

func (d *Downloader) Execute(_ context.Context) error

Execute implements the Task interface

func (*Downloader) Rollback

func (d *Downloader) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (*Downloader) String

func (d *Downloader) String() string

String implements the fmt.Stringer interface

type EnvInit

type EnvInit struct {
	// contains filtered or unexported fields
}

EnvInit is used to initialize the remote environment, e.g: 1. Generate SSH key 2. ssh-copy-id

func (*EnvInit) Execute

func (e *EnvInit) Execute(ctx context.Context) error

Execute implements the Task interface

func (*EnvInit) Rollback

func (e *EnvInit) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (*EnvInit) String

func (e *EnvInit) String() string

String implements the fmt.Stringer interface

type Func

type Func struct {
	// contains filtered or unexported fields
}

Func wrap a closure.

func NewFunc

func NewFunc(name string, fn func(ctx context.Context) error) *Func

NewFunc create a Func task

func (*Func) Execute

func (m *Func) Execute(ctx context.Context) error

Execute implements the Task interface

func (*Func) Rollback

func (m *Func) Rollback(_ context.Context) error

Rollback implements the Task interface

func (*Func) String

func (m *Func) String() string

String implements the fmt.Stringer interface

type InitConfig

type InitConfig struct {
	// contains filtered or unexported fields
}

InitConfig is used to copy all configurations to the target directory of path

func (*InitConfig) Execute

func (c *InitConfig) Execute(ctx context.Context) error

Execute implements the Task interface

func (*InitConfig) Rollback

func (c *InitConfig) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (*InitConfig) String

func (c *InitConfig) String() string

String implements the fmt.Stringer interface

type InstallPackage

type InstallPackage struct {
	// contains filtered or unexported fields
}

InstallPackage is used to copy all files related the specific version a component to the target directory of path

func (*InstallPackage) Execute

func (c *InstallPackage) Execute(ctx context.Context) error

Execute implements the Task interface

func (*InstallPackage) Rollback

func (c *InstallPackage) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (*InstallPackage) String

func (c *InstallPackage) String() string

String implements the fmt.Stringer interface

type Mkdir

type Mkdir struct {
	// contains filtered or unexported fields
}

Mkdir is used to create directory on the target host

func (*Mkdir) Execute

func (m *Mkdir) Execute(ctx context.Context) error

Execute implements the Task interface

func (*Mkdir) Rollback

func (m *Mkdir) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (*Mkdir) String

func (m *Mkdir) String() string

String implements the fmt.Stringer interface

type MonitoredConfig

type MonitoredConfig struct {
	// contains filtered or unexported fields
}

MonitoredConfig is used to generate the monitor node configuration

func (*MonitoredConfig) Execute

func (m *MonitoredConfig) Execute(ctx context.Context) error

Execute implements the Task interface

func (*MonitoredConfig) Rollback

func (m *MonitoredConfig) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (*MonitoredConfig) String

func (m *MonitoredConfig) String() string

String implements the fmt.Stringer interface

type Parallel

type Parallel struct {
	// contains filtered or unexported fields
}

Parallel will execute a bundle of task in parallelism way

func (*Parallel) Execute

func (pt *Parallel) Execute(ctx context.Context) error

Execute implements the Task interface

func (*Parallel) Rollback

func (pt *Parallel) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (*Parallel) String

func (pt *Parallel) String() string

String implements the fmt.Stringer interface

type ParallelStepDisplay

type ParallelStepDisplay struct {
	Logger *logprinter.Logger
	// contains filtered or unexported fields
}

ParallelStepDisplay is a task that will display multiple progress bars in parallel for inner tasks. Inner tasks will be executed in parallel.

func (*ParallelStepDisplay) Execute

func (ps *ParallelStepDisplay) Execute(ctx context.Context) error

Execute implements the Task interface

func (*ParallelStepDisplay) Rollback

func (ps *ParallelStepDisplay) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (*ParallelStepDisplay) SetLogger

func (ps *ParallelStepDisplay) SetLogger(logger *logprinter.Logger) *ParallelStepDisplay

SetLogger set the logger of step

func (*ParallelStepDisplay) String

func (ps *ParallelStepDisplay) String() string

String implements the fmt.Stringer interface

type RootSSH

type RootSSH struct {
	// contains filtered or unexported fields
}

RootSSH is used to establish a SSH connection to the target host with specific key

func (*RootSSH) Execute

func (s *RootSSH) Execute(ctx context.Context) error

Execute implements the Task interface

func (*RootSSH) Rollback

func (s *RootSSH) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (RootSSH) String

func (s RootSSH) String() string

String implements the fmt.Stringer interface

type SSHKeyGen

type SSHKeyGen struct {
	// contains filtered or unexported fields
}

SSHKeyGen is used to generate SSH key

func (*SSHKeyGen) Execute

func (s *SSHKeyGen) Execute(ctx context.Context) error

Execute implements the Task interface

func (*SSHKeyGen) Rollback

func (s *SSHKeyGen) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (*SSHKeyGen) String

func (s *SSHKeyGen) String() string

String implements the fmt.Stringer interface

type SSHKeySet

type SSHKeySet struct {
	// contains filtered or unexported fields
}

SSHKeySet is used to set the Context private/public key path

func (*SSHKeySet) Execute

func (s *SSHKeySet) Execute(ctx context.Context) error

Execute implements the Task interface

func (*SSHKeySet) Rollback

func (s *SSHKeySet) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (*SSHKeySet) String

func (s *SSHKeySet) String() string

String implements the fmt.Stringer interface

type Serial

type Serial struct {
	// contains filtered or unexported fields
}

Serial will execute a bundle of task in serialized way

func (*Serial) Execute

func (s *Serial) Execute(ctx context.Context) error

Execute implements the Task interface

func (*Serial) Rollback

func (s *Serial) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (*Serial) String

func (s *Serial) String() string

String implements the fmt.Stringer interface

type StepDisplay

type StepDisplay struct {
	Logger *logprinter.Logger
	// contains filtered or unexported fields
}

StepDisplay is a task that will display a progress bar for inner task.

func (*StepDisplay) Execute

func (s *StepDisplay) Execute(ctx context.Context) error

Execute implements the Task interface

func (*StepDisplay) Rollback

func (s *StepDisplay) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (*StepDisplay) SetLogger

func (s *StepDisplay) SetLogger(logger *logprinter.Logger) *StepDisplay

SetLogger set the logger of step

func (*StepDisplay) String

func (s *StepDisplay) String() string

String implements the fmt.Stringer interface

type Task

type Task interface {
	fmt.Stringer
	Execute(ctx context.Context) error
	Rollback(ctx context.Context) error
}

Task represents a operation while gemix execution

type UserAction

type UserAction struct {
	// contains filtered or unexported fields
}

UserAction is used to create user or del user on the target host

func (*UserAction) Execute

func (u *UserAction) Execute(ctx context.Context) error

Execute implements the Task interface

func (*UserAction) Rollback

func (u *UserAction) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (*UserAction) String

func (u *UserAction) String() string

String implements the fmt.Stringer interface

type UserActionOpt

type UserActionOpt string
const (
	UserActionAdd UserActionOpt = "add"
	UserActionDel UserActionOpt = "del"
)

type UserSSH

type UserSSH struct {
	// contains filtered or unexported fields
}

UserSSH is used to establish a SSH connection to the target host with generated key

func (*UserSSH) Execute

func (s *UserSSH) Execute(ctx context.Context) error

Execute implements the Task interface

func (*UserSSH) Rollback

func (s *UserSSH) Rollback(ctx context.Context) error

Rollback implements the Task interface

func (UserSSH) String

func (s UserSSH) String() string

String implements the fmt.Stringer interface

Jump to

Keyboard shortcuts

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