shell

package
v2.5.4 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterPlanError

func FilterPlanError(err error, command string) error

FilterPlanError filters to trap plan exit code that are not real error

func GetExitCode

func GetExitCode(err error) (int, error)

GetExitCode returns the exit code of a command. If the error does not implement errors.IErrorCode or is not an exec.ExitError type, the error is returned.

func LookPath

func LookPath(command string, paths ...string) (string, error)

LookPath search the supplied path to find the desired command It uses a mutex since it has to temporary override the global PATH variable.

func PromptUserForYesNo

func PromptUserForYesNo(prompt string, terragruntOptions *options.TerragruntOptions) (bool, error)

PromptUserForYesNo prompts the user for a yes/no response and return true if they entered yes.

func RunCommandToApprove

func RunCommandToApprove(cmd *exec.Cmd, expectedStatements []string, completedStatements []string, terragruntOptions *options.TerragruntOptions) error

RunCommandToApprove runs a command with approval (expect style)

Types

type CommandContext

type CommandContext struct {
	Stdout, Stderr io.Writer // If these variables are left unset, the default value from current options set will be used
	DisplayCommand string    // If not specified, the actual command will be displayed
	LogLevel       logrus.Level
	// contains filtered or unexported fields
}

CommandContext is the description of the command that must be executed

func NewCmd

func NewCmd(options *options.TerragruntOptions, cmd string) *CommandContext

NewCmd initializes the ShellCommand object

func NewTFCmd

func NewTFCmd(options *options.TerragruntOptions) *CommandContext

NewTFCmd initializes the ShellCommand object with terraform as the command

func (*CommandContext) Args

func (c *CommandContext) Args(args ...string) *CommandContext

Args add arguments to the CommandContext

func (*CommandContext) Env

func (c *CommandContext) Env(values ...string) *CommandContext

Env set additional environment variables in the CommandContext

func (*CommandContext) ExpandArgs

func (c *CommandContext) ExpandArgs() *CommandContext

ExpandArgs instructs that arguments should be expanded before run

func (*CommandContext) Expect

func (c *CommandContext) Expect(expected []string, completed []string) *CommandContext

Expect instructs that a special behavior should be done on some outputs

func (CommandContext) LogOutput

func (c CommandContext) LogOutput(logLevel logrus.Level) error

LogOutput runs the current command and log the output (stdout and stderr)

func (CommandContext) Output

func (c CommandContext) Output() (string, error)

Output runs the current command and returns the output (stdout and stderr)

func (CommandContext) Run

func (c CommandContext) Run() error

Run executes the command

func (*CommandContext) WithRetries

func (c *CommandContext) WithRetries(retries int) *CommandContext

WithRetries adds a number retries to commands before failing

func (*CommandContext) WorkingDir

func (c *CommandContext) WorkingDir(wd string) *CommandContext

WorkingDir changes the default working directory for the command

type OutputInterceptor

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

OutputInterceptor intercepts all writes to a io.Writer and writes them to a buffer while still letting them pass through. Offers some functions to help the approval process.

func (*OutputInterceptor) GetBuffer

func (interceptor *OutputInterceptor) GetBuffer() string

GetBuffer returns the string value of all intercepted data to the underlying writer.

func (*OutputInterceptor) IsComplete

func (interceptor *OutputInterceptor) IsComplete() bool

IsComplete returns true if the command is complete and should exit.

func (*OutputInterceptor) WaitingForValue

func (interceptor *OutputInterceptor) WaitingForValue() bool

WaitingForValue returns true if the command is waiting for an input value based on its output.

func (*OutputInterceptor) Write

func (interceptor *OutputInterceptor) Write(p []byte) (n int, err error)

type SignalsForwarder

type SignalsForwarder chan os.Signal

SignalsForwarder forwards signals to a command, waiting for the command to finish.

func NewSignalsForwarder

func NewSignalsForwarder(signals []os.Signal, c *exec.Cmd, logger *multilogger.Logger, cmdChannel chan error) SignalsForwarder

NewSignalsForwarder returns a new SignalsForwarder

func (*SignalsForwarder) Close

func (signalChannel *SignalsForwarder) Close() error

Close closes the signal channel

Jump to

Keyboard shortcuts

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