Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandRunner ¶
type CommandRunner struct {
// Env is global environment variables passed to all commands.
Env []string
// Steps are the steps to execute.
Steps []*CommandStep
// Stdout is the Writer used for Stdout. If nil then os.Stdout is used.
Stdout io.Writer
// Stderr is the Writer used for Stderr. If nil then os.Stderr is used.
Stderr io.Writer
}
CommandRunner runs commands and returns the build steps that were run.
func (*CommandRunner) Dry ¶
func (r *CommandRunner) Dry() (steps []*CommandStep, err error)
Dry returns the command steps as they would be executed by the runner without actually executing the commands. This allows builders to get an accurate set of steps in a trusted environment as executing commands will execute untrusted code.
func (*CommandRunner) Run ¶
func (r *CommandRunner) Run(ctx context.Context) (steps []*CommandStep, err error)
Run executes a series of commands and returns the steps that were executed successfully. Commands are run in sequence and are expected to return a zero exit status.
Global environment variables are merged with steps environment variables in the returned steps. In the case of duplicates the last occurrence has precidence. Environment variables are *not* inherited from the current process.
The returned CommandSteps should be included in the buildConfig provenance. These are *not* the same as the runner commands. Env vars are sanitized, pwd is changed to the absolute path, and only commands that executed successfully are returned.
type CommandStep ¶
type CommandStep struct {
// Command is the command that was run.
Command []string `json:"command"`
// Env are the environment variables passed to the command.
Env []string `json:"env"`
// WorkingDir is the working directory the command was executed in.
WorkingDir string `json:"workingDir"`
}
CommandStep is a command that was executed by the builder.