exec

package
v0.0.0-...-5a493b6 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	// Env is the environment variables to pass.
	Env map[string]string
	// Cmd is the executable to call.
	Cmd string
	// Args is the command line arguments.
	Args []string
	// Workdir is the working directory.
	Workdir string
	// SecretEnv contains environment variables and their value, but makes sure
	// to not log or print their value, to avoid secrets leaking.
	SecretEnv map[string]string
}

Cmd represents a command to execute.

type Config

type Config struct {
	Reqs []Requirement
	Cmds []Cmd
}

Config is an Executor configuration.

type DefaultRunner

type DefaultRunner struct{}

DefaultRunner executes the commands on the local system.

func (DefaultRunner) Run

func (DefaultRunner) Run(ctx context.Context, cmd Cmd) error

Run runs a command as a subprocess.

type DirExists

type DirExists struct {
	Path string
}

DirExists is a requirement that is satisfied when the given path is present.

func (DirExists) Check

func (d DirExists) Check(ctx context.Context, fs afero.Fs) error

Check returns an error if the path to check is not present.

type Executor

type Executor struct {
	Cfg    Config
	Fs     afero.Fs
	Runner Runner
}

Executor executes the configured commands.

func (Executor) CanExecute

func (e Executor) CanExecute(ctx context.Context) error

CanExecute returns true if the backup satisfies all requirements.

func (Executor) Run

func (e Executor) Run(ctx context.Context) error

Run runs the backup.

type Requirement

type Requirement interface {
	Check(ctx context.Context, fs afero.Fs) error
}

Requirement is a requirement to satisfy.

type Runner

type Runner interface {
	Run(ctx context.Context, cmd Cmd) error
}

Runner is an abstraction over command execution.

Jump to

Keyboard shortcuts

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