Documentation ¶
Index ¶
- func RunStdout(ctx context.Context, container app.EnvStdioContainer, runner Runner, ...) ([]byte, error)
- type Process
- type RunOption
- func RunWithArgs(args ...string) RunOption
- func RunWithDir(dir string) RunOption
- func RunWithEnv(env map[string]string) RunOption
- func RunWithEnviron(environ []string) RunOption
- func RunWithStderr(stderr io.Writer) RunOption
- func RunWithStdin(stdin io.Reader) RunOption
- func RunWithStdout(stdout io.Writer) RunOption
- type Runner
- type RunnerOption
- type StartOption
- func StartWithArgs(args ...string) StartOption
- func StartWithDir(dir string) StartOption
- func StartWithEnv(env map[string]string) StartOption
- func StartWithEnviron(environ []string) StartOption
- func StartWithStderr(stderr io.Writer) StartOption
- func StartWithStdin(stdin io.Reader) StartOption
- func StartWithStdout(stdout io.Writer) StartOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Process ¶ added in v1.18.0
type Process interface { // Wait blocks to wait for the process to exit. It will attempt to kill the // process if the passed context expires. Wait(ctx context.Context) error }
Process represents a background process.
type RunOption ¶
type RunOption func(*execOptions)
RunOption is an option for Run.
func RunWithArgs ¶
RunWithArgs returns a new RunOption that sets the arguments other than the name.
The default is no arguments.
func RunWithDir ¶
RunWithDir returns a new RunOption that sets the working directory.
The default is the current working directory.
func RunWithEnv ¶
RunWithEnv returns a new RunOption that sets the environment variables.
The default is to use the single environment variable __EMPTY_ENV__=1 as we cannot explicitly set an empty environment with the exec package.
If this and RunWithEnviron are specified, the last option specified wins.
func RunWithEnviron ¶ added in v1.32.0
RunWithEnviron returns a new RunOption that sets the environment variables.
The default is to use the single environment variable __EMPTY_ENV__=1 as we cannot explicitly set an empty environment with the exec package.
If this and RunWithEnv are specified, the last option specified wins.
func RunWithStderr ¶
RunWithStderr returns a new RunOption that sets the stderr.
The default is the null device (os.DevNull).
func RunWithStdin ¶
RunWithStdin returns a new RunOption that sets the stdin.
The default is ioext.DiscardReader.
func RunWithStdout ¶
RunWithStdout returns a new RunOption that sets the stdout.
The default is the null device (os.DevNull).
type Runner ¶
type Runner interface { // Run runs the external command. It blocks until the command exits. // // This should be used instead of exec.CommandContext(...).Run(). Run(ctx context.Context, name string, options ...RunOption) error // Start runs the external command, returning a [Process] handle to track // its progress. // // This should be used instead of exec.Command(...).Start(). Start(name string, options ...StartOption) (Process, error) // contains filtered or unexported methods }
Runner runs external commands.
A Runner will limit the number of concurrent commands, as well as explicitly set stdin, stdout, stderr, and env to nil/empty values if not set with options.
All external commands in buf MUST use command.Runner instead of exec.Command, exec.CommandContext.
type RunnerOption ¶
type RunnerOption func(*runner)
RunnerOption is an option for a new Runner.
func RunnerWithParallelism ¶
func RunnerWithParallelism(parallelism int) RunnerOption
RunnerWithParallelism returns a new Runner that sets the number of external commands that can be run concurrently.
The default is thread.Parallelism().
type StartOption ¶ added in v1.18.0
type StartOption func(*execOptions)
StartOption is an option for Start.
func StartWithArgs ¶ added in v1.18.0
func StartWithArgs(args ...string) StartOption
StartWithArgs returns a new RunOption that sets the arguments other than the name.
The default is no arguments.
func StartWithDir ¶ added in v1.18.0
func StartWithDir(dir string) StartOption
StartWithDir returns a new RunOption that sets the working directory.
The default is the current working directory.
func StartWithEnv ¶ added in v1.18.0
func StartWithEnv(env map[string]string) StartOption
StartWithEnv returns a new RunOption that sets the environment variables.
The default is to use the single environment variable __EMPTY_ENV__=1 as we cannot explicitly set an empty environment with the exec package.
If this and StartWithEnviron are specified, the last option specified wins.
func StartWithEnviron ¶ added in v1.32.0
func StartWithEnviron(environ []string) StartOption
StartWithEnviron returns a new RunOption that sets the environment variables.
The default is to use the single environment variable __EMPTY_ENV__=1 as we cannot explicitly set an empty environment with the exec package.
If this and StartWithEnv are specified, the last option specified wins.
func StartWithStderr ¶ added in v1.18.0
func StartWithStderr(stderr io.Writer) StartOption
StartWithStderr returns a new RunOption that sets the stderr.
The default is the null device (os.DevNull).
func StartWithStdin ¶ added in v1.18.0
func StartWithStdin(stdin io.Reader) StartOption
StartWithStdin returns a new RunOption that sets the stdin.
The default is ioext.DiscardReader.
func StartWithStdout ¶ added in v1.18.0
func StartWithStdout(stdout io.Writer) StartOption
StartWithStdout returns a new RunOption that sets the stdout.
The default is the null device (os.DevNull).