Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigureUI(mainLogger Logger, processLoggerConfig LoggerConfig)
- func Decrypt(data []byte, passphrase string) ([]byte, error)
- func DecryptBase64(encoded string, passphrase string) ([]byte, error)
- func Encrypt(data []byte, passphrase string) ([]byte, error)
- func EncryptToBase64(data []byte, passphrase string) (string, error)
- func IsRunpfileValid(runpfile *Runpfile) (bool, []error)
- func RandomKey() string
- func ResetColor()
- func ResolveRunpfilePath(rp string) (string, error)
- type ApplicationContext
- func (c *ApplicationContext) AddReport(message string)
- func (c *ApplicationContext) GetReport() []string
- func (c *ApplicationContext) GetRunningProcesses() map[string]RunpProcess
- func (c *ApplicationContext) RegisterRunningProcess(proc RunpProcess)
- func (c *ApplicationContext) RemoveRunningProcess(proc RunpProcess)
- type Auth
- type AwaitCondition
- type ContainerProcess
- func (p *ContainerProcess) AwaitResource() string
- func (p *ContainerProcess) AwaitTimeout() string
- func (p *ContainerProcess) Dir() string
- func (p *ContainerProcess) ID() string
- func (p *ContainerProcess) IsStartable() (bool, error)
- func (p *ContainerProcess) SetDir(wd string)
- func (p *ContainerProcess) SetID(id string)
- func (p *ContainerProcess) SetPreconditions(preconditions Preconditions)
- func (p *ContainerProcess) ShouldWait() bool
- func (p *ContainerProcess) StartCommand() (RunpCommand, error)
- func (p *ContainerProcess) StopCommand() (RunpCommand, error)
- func (p *ContainerProcess) StopTimeout() time.Duration
- func (p *ContainerProcess) String() string
- func (p *ContainerProcess) VerifyPreconditions() PreconditionVerifyResult
- type Endpoint
- type EnvironmentSettings
- type EtcHostsPrecondition
- type ExecCommandStopper
- func (c *ExecCommandStopper) Pid() int
- func (c *ExecCommandStopper) Run() error
- func (c *ExecCommandStopper) Start() error
- func (c *ExecCommandStopper) Stderr(stderr io.Writer)
- func (c *ExecCommandStopper) Stdout(stdout io.Writer)
- func (c *ExecCommandStopper) Stop() error
- func (c *ExecCommandStopper) String() string
- func (c *ExecCommandStopper) Wait() error
- type ExecCommandWrapper
- func (c *ExecCommandWrapper) Pid() int
- func (c *ExecCommandWrapper) Run() error
- func (c *ExecCommandWrapper) Start() error
- func (c *ExecCommandWrapper) Stderr(stderr io.Writer)
- func (c *ExecCommandWrapper) Stdout(stdout io.Writer)
- func (c *ExecCommandWrapper) Stop() error
- func (c *ExecCommandWrapper) String() string
- func (c *ExecCommandWrapper) Wait() error
- type HostProcess
- func (p *HostProcess) AwaitResource() string
- func (p *HostProcess) AwaitTimeout() string
- func (p *HostProcess) Dir() string
- func (p *HostProcess) ID() string
- func (p *HostProcess) IsStartable() (bool, error)
- func (p *HostProcess) SetDir(wd string)
- func (p *HostProcess) SetID(id string)
- func (p *HostProcess) SetPreconditions(preconditions Preconditions)
- func (p *HostProcess) ShouldWait() bool
- func (p *HostProcess) StartCommand() (RunpCommand, error)
- func (p *HostProcess) StopCommand() (RunpCommand, error)
- func (p *HostProcess) StopTimeout() time.Duration
- func (p *HostProcess) String() string
- func (p *HostProcess) VerifyPreconditions() PreconditionVerifyResult
- type Logger
- type LoggerConfig
- type OsPrecondition
- type Precondition
- type PreconditionVerifyResult
- type PreconditionVote
- type Preconditions
- type RunpCommand
- type RunpProcess
- type RunpUnit
- type RunpVersionPrecondition
- type Runpfile
- type RunpfileExecutor
- type SSHTunnelCommandStopper
- func (c *SSHTunnelCommandStopper) Pid() int
- func (c *SSHTunnelCommandStopper) Run() error
- func (c *SSHTunnelCommandStopper) Start() error
- func (c *SSHTunnelCommandStopper) Stderr(stderr io.Writer)
- func (c *SSHTunnelCommandStopper) Stdout(stdout io.Writer)
- func (c *SSHTunnelCommandStopper) Stop() error
- func (c *SSHTunnelCommandStopper) String() string
- func (c *SSHTunnelCommandStopper) Wait() error
- type SSHTunnelCommandWrapper
- func (c *SSHTunnelCommandWrapper) Pid() int
- func (c *SSHTunnelCommandWrapper) Run() error
- func (c *SSHTunnelCommandWrapper) Start() error
- func (c *SSHTunnelCommandWrapper) Stderr(stderr io.Writer)
- func (c *SSHTunnelCommandWrapper) Stdout(stdout io.Writer)
- func (c *SSHTunnelCommandWrapper) Stop() error
- func (c *SSHTunnelCommandWrapper) String() string
- func (c *SSHTunnelCommandWrapper) Wait() error
- type SSHTunnelProcess
- func (p *SSHTunnelProcess) AwaitResource() string
- func (p *SSHTunnelProcess) AwaitTimeout() string
- func (p *SSHTunnelProcess) Dir() string
- func (p *SSHTunnelProcess) ID() string
- func (p *SSHTunnelProcess) IsStartable() (bool, error)
- func (p *SSHTunnelProcess) SetDir(wd string)
- func (p *SSHTunnelProcess) SetID(id string)
- func (p *SSHTunnelProcess) SetPreconditions(preconditions Preconditions)
- func (p *SSHTunnelProcess) ShouldWait() bool
- func (p *SSHTunnelProcess) StartCommand() (RunpCommand, error)
- func (p *SSHTunnelProcess) StopCommand() (RunpCommand, error)
- func (p *SSHTunnelProcess) StopTimeout() time.Duration
- func (p *SSHTunnelProcess) String() string
- func (p *SSHTunnelProcess) VerifyPreconditions() PreconditionVerifyResult
- type Shell
- type StartPlan
- type VersionComparationOperator
Constants ¶
const ( // Unknown vote Unknown PreconditionVote = 0 // Stop the process Stop = 1 // Proceed the process can be ran Proceed = 2 )
const ( // None ... None VersionComparationOperator = "None" // LessThan ... LessThan = "LessThan" // LessThanOrEqual ... LessThanOrEqual = "LessThanOrEqual" // Equal ... Equal = "Equal" // GreaterThanOrEqual ... GreaterThanOrEqual = "GreaterThanOrEqual" // GreaterThan ... GreaterThan = "GreaterThan" )
const ErrFmtCreateProcess = "Unable to create Process for %s. Check configuration: missing Host, SSHTunnel or Container key?"
ErrFmtCreateProcess format used for error in process creation.
Variables ¶
var BuildTime = ""
BuildTime of the running app.
var GitCommit = ""
GitCommit is the Git hash and a "+CHANGES" suffix if there are uncommitted changes.
var Version = ""
Version of the running app.
Functions ¶
func ConfigureUI ¶
func ConfigureUI(mainLogger Logger, processLoggerConfig LoggerConfig)
ConfigureUI allows to the main package to set main logger instance and configure the process logger instances.
func DecryptBase64 ¶
DecryptBase64 decrypt a secret encoded in base 64
func EncryptToBase64 ¶
EncryptToBase64 encypt secret and encode in base 64
func IsRunpfileValid ¶
IsRunpfileValid returns a boolean rapresenting if any Runpfile value is valid and a list of errors.
func RandomKey ¶
func RandomKey() string
RandomKey generates a random string usable as key to encrypt secrets
func ResetColor ¶ added in v0.5.1
func ResetColor()
ResetColor resets the foreground and background to original colors
func ResolveRunpfilePath ¶
ResolveRunpfilePath Returns the path to the Runpfile and error
Types ¶
type ApplicationContext ¶
ApplicationContext is a singleton object containing some global variables.
func GetApplicationContext ¶
func GetApplicationContext() *ApplicationContext
GetApplicationContext returns the singleton instance of the application context.
func (*ApplicationContext) AddReport ¶
func (c *ApplicationContext) AddReport(message string)
AddReport add a report string to the reports list.
func (*ApplicationContext) GetReport ¶
func (c *ApplicationContext) GetReport() []string
GetReport returns all reports.
func (*ApplicationContext) GetRunningProcesses ¶
func (c *ApplicationContext) GetRunningProcesses() map[string]RunpProcess
GetRunningProcesses returns all running processes.
func (*ApplicationContext) RegisterRunningProcess ¶
func (c *ApplicationContext) RegisterRunningProcess(proc RunpProcess)
RegisterRunningProcess add process to the list of running ones.
func (*ApplicationContext) RemoveRunningProcess ¶
func (c *ApplicationContext) RemoveRunningProcess(proc RunpProcess)
RemoveRunningProcess add process.
type Auth ¶
type Auth struct { Secret string // encrypted secret in base 64 EncryptedSecret string `yaml:"encrypted_secret"` IdentityFile string `yaml:"identity_file"` }
Auth is auth
type AwaitCondition ¶
AwaitCondition defines time to wait for a resource.
type ContainerProcess ¶
type ContainerProcess struct { // image Image string // if not used it will be created Name string // in format docker-compose Ports []string // rm Automatically remove the container when it exits SkipRm bool `yaml:"skip_rm"` // in format docker-compose Volumes []string VolumesFrom []string `yaml:"volumes_from"` Mounts []string ShmSize string `yaml:"shm_size"` Command string // generics WorkingDir string `yaml:"workdir"` Env map[string]string Await AwaitCondition // contains filtered or unexported fields }
ContainerProcess implements RunpProcess.
func (*ContainerProcess) AwaitResource ¶
func (p *ContainerProcess) AwaitResource() string
AwaitResource returns the await resource.
func (*ContainerProcess) AwaitTimeout ¶
func (p *ContainerProcess) AwaitTimeout() string
AwaitTimeout returns the await timeout.
func (*ContainerProcess) IsStartable ¶
func (p *ContainerProcess) IsStartable() (bool, error)
IsStartable ...
func (*ContainerProcess) SetDir ¶
func (p *ContainerProcess) SetDir(wd string)
SetDir for the sub process
func (*ContainerProcess) SetID ¶
func (p *ContainerProcess) SetID(id string)
SetID for the sub process
func (*ContainerProcess) SetPreconditions ¶ added in v0.5.4
func (p *ContainerProcess) SetPreconditions(preconditions Preconditions)
SetPreconditions set preconditions.
func (*ContainerProcess) ShouldWait ¶
func (p *ContainerProcess) ShouldWait() bool
ShouldWait returns if the process has await set.
func (*ContainerProcess) StartCommand ¶
func (p *ContainerProcess) StartCommand() (RunpCommand, error)
StartCommand returns the command starting the process.
func (*ContainerProcess) StopCommand ¶
func (p *ContainerProcess) StopCommand() (RunpCommand, error)
StopCommand returns the command stopping the process.
func (*ContainerProcess) StopTimeout ¶
func (p *ContainerProcess) StopTimeout() time.Duration
StopTimeout duration to wait to force kill process
func (*ContainerProcess) String ¶
func (p *ContainerProcess) String() string
String representation of process
func (*ContainerProcess) VerifyPreconditions ¶ added in v0.5.4
func (p *ContainerProcess) VerifyPreconditions() PreconditionVerifyResult
VerifyPreconditions check if process can be started
type EnvironmentSettings ¶ added in v0.6.0
type EnvironmentSettings struct {
ContainerRunnerExe string `yaml:"container_runner"`
}
EnvironmentSettings represents settings for the current box.
type EtcHostsPrecondition ¶ added in v0.7.0
type EtcHostsPrecondition struct { Contains map[string][]string // contains filtered or unexported fields }
EtcHostsPrecondition verify /etc/hosts contains given host.
func (*EtcHostsPrecondition) IsSet ¶ added in v0.7.0
func (p *EtcHostsPrecondition) IsSet() bool
IsSet ...
func (*EtcHostsPrecondition) Verify ¶ added in v0.7.0
func (p *EtcHostsPrecondition) Verify() PreconditionVerifyResult
Verify ...
type ExecCommandStopper ¶
type ExecCommandStopper struct {
// contains filtered or unexported fields
}
ExecCommandStopper is the component calling the actual command stopping the process.
func (*ExecCommandStopper) Stderr ¶
func (c *ExecCommandStopper) Stderr(stderr io.Writer)
Stderr ...
func (*ExecCommandStopper) Stdout ¶
func (c *ExecCommandStopper) Stdout(stdout io.Writer)
Stdout ...
func (*ExecCommandStopper) String ¶
func (c *ExecCommandStopper) String() string
func (*ExecCommandStopper) Wait ¶
func (c *ExecCommandStopper) Wait() error
Wait waits for the command to exit.
type ExecCommandWrapper ¶
type ExecCommandWrapper struct {
// contains filtered or unexported fields
}
ExecCommandWrapper is wrapper for *exec.Cmd
func (*ExecCommandWrapper) Pid ¶
func (c *ExecCommandWrapper) Pid() int
Pid return PID for this command wrapper
func (*ExecCommandWrapper) Stderr ¶
func (c *ExecCommandWrapper) Stderr(stderr io.Writer)
Stderr set the stderr writer
func (*ExecCommandWrapper) Stdout ¶
func (c *ExecCommandWrapper) Stdout(stdout io.Writer)
Stdout set the stdout writer
func (*ExecCommandWrapper) String ¶
func (c *ExecCommandWrapper) String() string
func (*ExecCommandWrapper) Wait ¶
func (c *ExecCommandWrapper) Wait() error
Wait waits for the command to exit.
type HostProcess ¶
type HostProcess struct { // command line CommandLine string `yaml:"command"` // executable Executable string Args []string Shell Shell // generic WorkingDir string `yaml:"workdir"` Env map[string]string Await AwaitCondition // contains filtered or unexported fields }
HostProcess implements RunpProcess.
func (*HostProcess) AwaitResource ¶
func (p *HostProcess) AwaitResource() string
AwaitResource returns the await resource.
func (*HostProcess) AwaitTimeout ¶
func (p *HostProcess) AwaitTimeout() string
AwaitTimeout returns the await timeout.
func (*HostProcess) IsStartable ¶
func (p *HostProcess) IsStartable() (bool, error)
IsStartable always true.
func (*HostProcess) SetPreconditions ¶ added in v0.5.4
func (p *HostProcess) SetPreconditions(preconditions Preconditions)
SetPreconditions set preconditions.
func (*HostProcess) ShouldWait ¶
func (p *HostProcess) ShouldWait() bool
ShouldWait returns if the process has await set.
func (*HostProcess) StartCommand ¶
func (p *HostProcess) StartCommand() (RunpCommand, error)
StartCommand returns the command starting the process.
func (*HostProcess) StopCommand ¶
func (p *HostProcess) StopCommand() (RunpCommand, error)
StopCommand returns the command stopping the process.
func (*HostProcess) StopTimeout ¶
func (p *HostProcess) StopTimeout() time.Duration
StopTimeout duration to wait to force kill process
func (*HostProcess) VerifyPreconditions ¶ added in v0.5.4
func (p *HostProcess) VerifyPreconditions() PreconditionVerifyResult
VerifyPreconditions check if process can be started
type Logger ¶
type Logger interface { WriteLinef(format string, a ...interface{}) (int, error) Debugf(format string, a ...interface{}) (int, error) WriteLine(line string) (int, error) Debug(line string) (int, error) Write(p []byte) (int, error) }
Logger writes out messages from the main program and output from the running processes.
type LoggerConfig ¶
LoggerConfig contains configuration for a logger.
type OsPrecondition ¶ added in v0.5.4
type OsPrecondition struct { // linux | darwin | windows Inclusions []string // contains filtered or unexported fields }
OsPrecondition verify os.
func (*OsPrecondition) Verify ¶ added in v0.5.4
func (p *OsPrecondition) Verify() PreconditionVerifyResult
Verify ...
type Precondition ¶ added in v0.5.4
type Precondition interface { IsSet() bool Verify() PreconditionVerifyResult }
Precondition is.
type PreconditionVerifyResult ¶ added in v0.5.4
type PreconditionVerifyResult struct { Vote PreconditionVote Reasons []string }
PreconditionVerifyResult ...
type PreconditionVote ¶ added in v0.5.4
type PreconditionVote int64
PreconditionVote ...
func (PreconditionVote) String ¶ added in v0.5.4
func (e PreconditionVote) String() string
type Preconditions ¶ added in v0.5.4
type Preconditions struct { Os OsPrecondition Runp RunpVersionPrecondition Hosts EtcHostsPrecondition }
Preconditions ...
func (*Preconditions) Verify ¶ added in v0.5.4
func (p *Preconditions) Verify() PreconditionVerifyResult
Verify ...
type RunpCommand ¶
type RunpCommand interface { Pid() int Stdout(stdout io.Writer) Stderr(stderr io.Writer) Start() error Run() error Stop() error Wait() error }
RunpCommand is the interface for all command types: host, container, aws process...
type RunpProcess ¶
type RunpProcess interface { ID() string VerifyPreconditions() PreconditionVerifyResult SetPreconditions(Preconditions) SetID(string) StartCommand() (RunpCommand, error) StopCommand() (RunpCommand, error) StopTimeout() time.Duration Dir() string SetDir(string) ShouldWait() bool AwaitResource() string AwaitTimeout() string IsStartable() (bool, error) }
RunpProcess is wrapper for running process
type RunpUnit ¶
type RunpUnit struct { Name string Description string StopTimeout string `yaml:"stop_timeout"` Preconditions Preconditions Host *HostProcess Container *ContainerProcess SSHTunnel *SSHTunnelProcess `yaml:"ssh_tunnel"` // contains filtered or unexported fields }
RunpUnit is...
func (*RunpUnit) SkipDirResolution ¶
SkipDirResolution avoid resolve dir for containers
type RunpVersionPrecondition ¶ added in v0.5.4
type RunpVersionPrecondition struct { Operator VersionComparationOperator Version string }
RunpVersionPrecondition checks Runp version.
func (*RunpVersionPrecondition) IsSet ¶ added in v0.5.4
func (p *RunpVersionPrecondition) IsSet() bool
IsSet ...
func (*RunpVersionPrecondition) Verify ¶ added in v0.5.4
func (p *RunpVersionPrecondition) Verify() PreconditionVerifyResult
Verify ...
type Runpfile ¶
type Runpfile struct { Name string Description string Version string Vars map[string]string Root string Units map[string]*RunpUnit SecretKey string `yaml:"-"` Include []string }
Runpfile is the model containing the full configuration.
func LoadRunpfileFromPath ¶
LoadRunpfileFromPath returns an Runpfile object reading file from path.
type RunpfileExecutor ¶
type RunpfileExecutor struct { LoggerFactory func(string, int, LoggerConfig) Logger // contains filtered or unexported fields }
RunpfileExecutor Executor implementation for Runpfile.
func NewExecutor ¶
func NewExecutor(rf *Runpfile) *RunpfileExecutor
NewExecutor creates new RunpfileExecutor
func (*RunpfileExecutor) Start ¶
func (e *RunpfileExecutor) Start()
Start call start on all processes.
type SSHTunnelCommandStopper ¶
type SSHTunnelCommandStopper struct {
// contains filtered or unexported fields
}
SSHTunnelCommandStopper is the component calling the actual command stopping the process.
func (*SSHTunnelCommandStopper) Stderr ¶
func (c *SSHTunnelCommandStopper) Stderr(stderr io.Writer)
Stderr ...
func (*SSHTunnelCommandStopper) Stdout ¶
func (c *SSHTunnelCommandStopper) Stdout(stdout io.Writer)
Stdout ...
func (*SSHTunnelCommandStopper) String ¶
func (c *SSHTunnelCommandStopper) String() string
type SSHTunnelCommandWrapper ¶
type SSHTunnelCommandWrapper struct {
// contains filtered or unexported fields
}
SSHTunnelCommandWrapper ...
func (*SSHTunnelCommandWrapper) Stderr ¶
func (c *SSHTunnelCommandWrapper) Stderr(stderr io.Writer)
Stderr ...
func (*SSHTunnelCommandWrapper) Stdout ¶
func (c *SSHTunnelCommandWrapper) Stdout(stdout io.Writer)
Stdout ...
func (*SSHTunnelCommandWrapper) String ¶
func (c *SSHTunnelCommandWrapper) String() string
type SSHTunnelProcess ¶
type SSHTunnelProcess struct { WorkingDir string `yaml:"workdir"` Env map[string]string Await AwaitCondition User string Auth Auth Local Endpoint Jump Endpoint Target Endpoint // command executed to test connection to jump server TestCommand string `yaml:"test_command"` // contains filtered or unexported fields }
SSHTunnelProcess implements RunpProcess.
func (*SSHTunnelProcess) AwaitResource ¶
func (p *SSHTunnelProcess) AwaitResource() string
AwaitResource returns the await resource.
func (*SSHTunnelProcess) AwaitTimeout ¶
func (p *SSHTunnelProcess) AwaitTimeout() string
AwaitTimeout returns the await timeout.
func (*SSHTunnelProcess) IsStartable ¶
func (p *SSHTunnelProcess) IsStartable() (bool, error)
IsStartable always true.
func (*SSHTunnelProcess) SetDir ¶
func (p *SSHTunnelProcess) SetDir(wd string)
SetDir for the sub process
func (*SSHTunnelProcess) SetID ¶
func (p *SSHTunnelProcess) SetID(id string)
SetID for the sub process
func (*SSHTunnelProcess) SetPreconditions ¶ added in v0.5.4
func (p *SSHTunnelProcess) SetPreconditions(preconditions Preconditions)
SetPreconditions set preconditions.
func (*SSHTunnelProcess) ShouldWait ¶
func (p *SSHTunnelProcess) ShouldWait() bool
ShouldWait returns if the process has await set.
func (*SSHTunnelProcess) StartCommand ¶
func (p *SSHTunnelProcess) StartCommand() (RunpCommand, error)
StartCommand returns the command starting the process.
func (*SSHTunnelProcess) StopCommand ¶
func (p *SSHTunnelProcess) StopCommand() (RunpCommand, error)
StopCommand returns the command stopping the process.
func (*SSHTunnelProcess) StopTimeout ¶
func (p *SSHTunnelProcess) StopTimeout() time.Duration
StopTimeout duration to wait to force kill process
func (*SSHTunnelProcess) String ¶
func (p *SSHTunnelProcess) String() string
String representation of process
func (*SSHTunnelProcess) VerifyPreconditions ¶ added in v0.5.4
func (p *SSHTunnelProcess) VerifyPreconditions() PreconditionVerifyResult
VerifyPreconditions check if process can be started
type StartPlan ¶
type StartPlan struct {
Await AwaitCondition
}
StartPlan defines how and when start process.
type VersionComparationOperator ¶ added in v0.5.4
type VersionComparationOperator string
VersionComparationOperator ...
Source Files ¶
- app_context.go
- encription.go
- env_settings.go
- log.go
- log_colors.go
- preprocessor.go
- runpfile.go
- runpfile_command.go
- runpfile_command_exec.go
- runpfile_command_sshtunnel.go
- runpfile_executor.go
- runpfile_preconditions.go
- runpfile_preconditions_etchosts.go
- runpfile_preconditions_os.go
- runpfile_preconditions_runp.go
- runpfile_process.go
- runpfile_process_container.go
- runpfile_process_host.go
- runpfile_process_sshtunnel.go
- shell_unix.go
- utils.go
- version.go