Documentation
¶
Overview ¶
Package subprocess allows you to spawn new processes, log their output/error and obtain their return codes.
Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved.
SPDX-License-Identifier: Apache-2.0
Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved.
SPDX-License-Identifier: Apache-2.0
Index ¶
- func CleanKillOfCommand(ctx context.Context, cmd *exec.Cmd) (err error)
- func ConvertCommandError(err error) error
- func Execute(ctx context.Context, loggers logs.Loggers, messageOnStart string, ...) error
- func ExecuteAs(ctx context.Context, loggers logs.Loggers, messageOnStart string, ...) error
- func ExecuteAsWithDir(ctx context.Context, loggers logs.Loggers, messageOnStart string, ...) error
- func ExecuteAsWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, ...) (err error)
- func ExecuteAsWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, ...) (err error)
- func ExecuteAsWithEnvironmentWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (err error)
- func ExecuteAsWithEnvironmentWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (err error)
- func ExecuteAsWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) error
- func ExecuteAsWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) error
- func ExecuteWithDir(ctx context.Context, loggers logs.Loggers, messageOnStart string, ...) error
- func ExecuteWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, ...) (err error)
- func ExecuteWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, ...) (err error)
- func ExecuteWithEnvironmentWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (err error)
- func ExecuteWithEnvironmentWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (err error)
- func ExecuteWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) error
- func ExecuteWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) error
- func ExecuteWithSudo(ctx context.Context, loggers logs.Loggers, messageOnStart string, ...) error
- func ExecuteWithSudoWithDir(ctx context.Context, loggers logs.Loggers, messageOnStart string, ...) error
- func ExecuteWithSudoWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) error
- func ExecuteWithSudoWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) error
- func Output(ctx context.Context, loggers logs.Loggers, cmd string, args ...string) (string, error)
- func OutputAs(ctx context.Context, loggers logs.Loggers, ...) (string, error)
- func OutputAsWithDir(ctx context.Context, loggers logs.Loggers, ...) (string, error)
- func OutputAsWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, ...) (output string, err error)
- func OutputAsWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, ...) (output string, err error)
- func OutputWithDir(ctx context.Context, loggers logs.Loggers, dir string, cmd string, ...) (string, error)
- func OutputWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, ...) (string, error)
- func OutputWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, ...) (string, error)
- type ICommandIO
- type Subprocess
- func New(ctx context.Context, loggers logs.Loggers, messageOnStart string, ...) (*Subprocess, error)
- func NewWithDir(ctx context.Context, loggers logs.Loggers, messageOnStart string, ...) (*Subprocess, error)
- func NewWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, ...) (p *Subprocess, err error)
- func NewWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, ...) (p *Subprocess, err error)
- func NewWithEnvironmentWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (p *Subprocess, err error)
- func NewWithEnvironmentWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (p *Subprocess, err error)
- func NewWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (*Subprocess, error)
- func NewWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (*Subprocess, error)
- func Start(ctx context.Context, loggers logs.Loggers, messageOnStart string, ...) (*Subprocess, error)
- func StartWithDir(ctx context.Context, loggers logs.Loggers, messageOnStart string, ...) (*Subprocess, error)
- func StartWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, ...) (*Subprocess, error)
- func StartWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, ...) (*Subprocess, error)
- func StartWithEnvironmentWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (p *Subprocess, err error)
- func StartWithEnvironmentWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (p *Subprocess, err error)
- func (s *Subprocess) Cancel()
- func (s *Subprocess) Check() error
- func (s *Subprocess) Execute() (err error)
- func (s *Subprocess) Interrupt(ctx context.Context) (err error)
- func (s *Subprocess) IsOn() bool
- func (s *Subprocess) Restart() (err error)
- func (s *Subprocess) Setup(ctx context.Context, loggers logs.Loggers, messageOnStart string, ...) (err error)
- func (s *Subprocess) SetupAs(ctx context.Context, loggers logs.Loggers, messageOnStart string, ...) (err error)
- func (s *Subprocess) SetupAsWithCustomIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (err error)
- func (s *Subprocess) SetupAsWithCustomIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (err error)
- func (s *Subprocess) SetupAsWithDir(ctx context.Context, loggers logs.Loggers, messageOnStart string, ...) (err error)
- func (s *Subprocess) SetupAsWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnv []string, ...) (err error)
- func (s *Subprocess) SetupAsWithEnvironmentWithCustomIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (err error)
- func (s *Subprocess) SetupAsWithEnvironmentWithCustomIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (err error)
- func (s *Subprocess) SetupAsWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnv []string, ...) (err error)
- func (s *Subprocess) SetupWithCustomIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (err error)
- func (s *Subprocess) SetupWithCustomIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (err error)
- func (s *Subprocess) SetupWithDir(ctx context.Context, loggers logs.Loggers, messageOnStart string, ...) (err error)
- func (s *Subprocess) SetupWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnv []string, ...) (err error)
- func (s *Subprocess) SetupWithEnvironmentWithCustomIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (err error)
- func (s *Subprocess) SetupWithEnvironmentWithCustomIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, ...) (err error)
- func (s *Subprocess) SetupWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnv []string, ...) (err error)
- func (s *Subprocess) Start() (err error)
- func (s *Subprocess) Stop() (err error)
- func (s *Subprocess) Wait(ctx context.Context) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanKillOfCommand ¶ added in v1.62.0
CleanKillOfCommand tries to terminate a command gracefully.
func ConvertCommandError ¶ added in v1.62.0
func Execute ¶
func Execute(ctx context.Context, loggers logs.Loggers, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) error
Execute executes a command (i.e. spawns a subprocess).
func ExecuteAs ¶ added in v1.48.0
func ExecuteAs(ctx context.Context, loggers logs.Loggers, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, cmd string, args ...string) error
ExecuteAs executes a command (i.e. spawns a subprocess) as a different user.
func ExecuteAsWithDir ¶ added in v1.157.0
func ExecuteAsWithDir(ctx context.Context, loggers logs.Loggers, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, dir string, cmd string, args ...string) error
ExecuteAsWithDir executes a command (i.e. spawns a subprocess) as a different user with a working directory.
func ExecuteAsWithEnvironment ¶ added in v1.60.0
func ExecuteAsWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, cmd string, args ...string) (err error)
ExecuteAsWithEnvironment executes a command (i.e. spawns a subprocess) as a different user. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func ExecuteAsWithEnvironmentWithDir ¶ added in v1.157.0
func ExecuteAsWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, dir string, cmd string, args ...string) (err error)
ExecuteAsWithEnvironmentWithDir executes a command (i.e. spawns a subprocess) as a different user with a working directory. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func ExecuteAsWithEnvironmentWithIO ¶ added in v1.123.0
func ExecuteAsWithEnvironmentWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, cmd string, args ...string) (err error)
ExecuteAsWithEnvironmentWithIO executes a command (i.e. spawns a subprocess) as a different user with overridden stdin/stdout/stderr. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func ExecuteAsWithEnvironmentWithIOWithDir ¶ added in v1.157.0
func ExecuteAsWithEnvironmentWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, dir string, cmd string, args ...string) (err error)
ExecuteAsWithEnvironmentWithIOWithDir executes a command (i.e. spawns a subprocess) as a different user with a working directory and overridden stdin/stdout/stderr. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func ExecuteAsWithIO ¶ added in v1.123.0
func ExecuteAsWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, cmd string, args ...string) error
ExecuteAsWithIO executes a command (i.e. spawns a subprocess) as a different user with overridden stdin/stdout/stderr.
func ExecuteAsWithIOWithDir ¶ added in v1.157.0
func ExecuteAsWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, dir string, cmd string, args ...string) error
ExecuteAsWithIOWithDir executes a command (i.e. spawns a subprocess) as a different user with a working directory and overridden stdin/stdout/stderr.
func ExecuteWithDir ¶ added in v1.157.0
func ExecuteWithDir(ctx context.Context, loggers logs.Loggers, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) error
ExecuteWithDir executes a command (i.e. spawns a subprocess) with a working directory.
func ExecuteWithEnvironment ¶ added in v1.60.0
func ExecuteWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) (err error)
ExecuteWithEnvironment executes a command (i.e. spawns a subprocess). It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func ExecuteWithEnvironmentWithDir ¶ added in v1.157.0
func ExecuteWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) (err error)
ExecuteWithEnvironmentWithDir executes a command (i.e. spawns a subprocess) with a working directory. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func ExecuteWithEnvironmentWithIO ¶ added in v1.123.0
func ExecuteWithEnvironmentWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) (err error)
ExecuteWithEnvironmentWithIO executes a command (i.e. spawns a subprocess) with overridden stdin/stdout/stderr. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func ExecuteWithEnvironmentWithIOWithDir ¶ added in v1.157.0
func ExecuteWithEnvironmentWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) (err error)
ExecuteWithEnvironmentWithIOWithDir executes a command (i.e. spawns a subprocess) with a working directory and overridden stdin/stdout/stderr. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func ExecuteWithIO ¶ added in v1.123.0
func ExecuteWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) error
ExecuteWithIO executes a command (i.e. spawns a subprocess) with overridden stdin/stdout/stderr.
func ExecuteWithIOWithDir ¶ added in v1.157.0
func ExecuteWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) error
ExecuteWithIOWithDir executes a command (i.e. spawns a subprocess) with a working directory and overridden stdin/stdout/stderr.
func ExecuteWithSudo ¶ added in v1.48.0
func ExecuteWithSudo(ctx context.Context, loggers logs.Loggers, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) error
ExecuteWithSudo executes a command (i.e. spawns a subprocess) as root.
func ExecuteWithSudoWithDir ¶ added in v1.157.0
func ExecuteWithSudoWithDir(ctx context.Context, loggers logs.Loggers, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) error
ExecuteWithSudoWithDir executes a command (i.e. spawns a subprocess) as root with a working directory.
func ExecuteWithSudoWithIO ¶ added in v1.123.0
func ExecuteWithSudoWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) error
ExecuteWithSudoWithIO executes a command (i.e. spawns a subprocess) as root with overridden stdin/stdout/stderr.
func ExecuteWithSudoWithIOWithDir ¶ added in v1.157.0
func ExecuteWithSudoWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) error
ExecuteWithSudoWithIOWithDir executes a command (i.e. spawns a subprocess) as root with a working directory and overridden stdin/stdout/stderr.
func Output ¶ added in v1.47.0
Output executes a command and returns its output (stdOutput and stdErr are merged) as string.
func OutputAs ¶ added in v1.48.0
func OutputAs(ctx context.Context, loggers logs.Loggers, as *commandUtils.CommandAsDifferentUser, cmd string, args ...string) (string, error)
OutputAs executes a command as a different user and returns its output (stdOutput and stdErr are merged) as string.
func OutputAsWithDir ¶ added in v1.157.0
func OutputAsWithDir(ctx context.Context, loggers logs.Loggers, as *commandUtils.CommandAsDifferentUser, dir string, cmd string, args ...string) (string, error)
OutputAsWithDir executes a command as a different user with a working directory and returns its output (stdOutput and stdErr are merged) as string.
func OutputAsWithEnvironment ¶ added in v1.60.0
func OutputAsWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, as *commandUtils.CommandAsDifferentUser, cmd string, args ...string) (output string, err error)
OutputAsWithEnvironment executes a command as a different user and returns its output (stdOutput and stdErr are merged) as string. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func OutputAsWithEnvironmentWithDir ¶ added in v1.157.0
func OutputAsWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, as *commandUtils.CommandAsDifferentUser, dir string, cmd string, args ...string) (output string, err error)
OutputAsWithEnvironmentWithDir executes a command as a different user with a working directory and returns its output (stdOutput and stdErr are merged) as string. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func OutputWithDir ¶ added in v1.157.0
func OutputWithDir(ctx context.Context, loggers logs.Loggers, dir string, cmd string, args ...string) (string, error)
OutputWithDir executes a command with a working directory and returns its output (stdOutput and stdErr are merged) as string.
func OutputWithEnvironment ¶ added in v1.60.0
func OutputWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, cmd string, args ...string) (string, error)
OutputWithEnvironment executes a command and returns its output (stdOutput and stdErr are merged) as string. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func OutputWithEnvironmentWithDir ¶ added in v1.157.0
func OutputWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, dir string, cmd string, args ...string) (string, error)
OutputWithEnvironmentWithDir executes a command with a working directory and returns its output (stdOutput and stdErr are merged) as string. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
Types ¶
type ICommandIO ¶ added in v1.122.0
type ICommandIO interface {
// Register creates new readers and writers based on the constructor methods in the ICommandIO implementation. If the constructors are not specified then it will default to os.Stdin, os.Stdout, and os.Stderr
Register(context.Context) (in io.Reader, out, errs io.Writer)
}
ICommandIO allows you to set the stdin, stdout, and stderr that will be used in a subprocess. A context can be injected for context aware readers and writers
func NewDefaultIO ¶ added in v1.122.0
func NewDefaultIO() ICommandIO
func NewIOFromLoggers ¶ added in v1.122.0
func NewIOFromLoggers(loggers logs.Loggers) ICommandIO
type Subprocess ¶
type Subprocess struct {
// contains filtered or unexported fields
}
Subprocess describes what a subprocess is as well as any monitoring it may need.
func New ¶
func New(ctx context.Context, loggers logs.Loggers, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) (*Subprocess, error)
New creates a subprocess description.
func NewWithDir ¶ added in v1.157.0
func NewWithDir(ctx context.Context, loggers logs.Loggers, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) (*Subprocess, error)
NewWithDir creates a subprocess description with a working directory.
func NewWithEnvironment ¶ added in v1.60.0
func NewWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) (p *Subprocess, err error)
NewWithEnvironment creates a subprocess description. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func NewWithEnvironmentWithDir ¶ added in v1.157.0
func NewWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) (p *Subprocess, err error)
NewWithEnvironmentWithDir creates a subprocess description with a working directory. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func NewWithEnvironmentWithIO ¶ added in v1.123.0
func NewWithEnvironmentWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) (p *Subprocess, err error)
NewWithEnvironmentWithIO creates a subprocess description with overridden stdin/stdout/stderr. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func NewWithEnvironmentWithIOWithDir ¶ added in v1.157.0
func NewWithEnvironmentWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) (p *Subprocess, err error)
NewWithEnvironmentWithIOWithDir creates a subprocess description with a working directory and overridden stdin/stdout/stderr. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func NewWithIO ¶ added in v1.123.0
func NewWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) (*Subprocess, error)
NewWithIO creates a subprocess description with overridden stdin/stdout/stderr.
func NewWithIOWithDir ¶ added in v1.157.0
func NewWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) (*Subprocess, error)
NewWithIOWithDir creates a subprocess description with a working directory and overridden stdin/stdout/stderr.
func Start ¶ added in v1.138.0
func Start(ctx context.Context, loggers logs.Loggers, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) (*Subprocess, error)
Start starts a command (i.e. spawns a subprocess).
func StartWithDir ¶ added in v1.157.0
func StartWithDir(ctx context.Context, loggers logs.Loggers, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) (*Subprocess, error)
StartWithDir starts a command (i.e. spawns a subprocess) with a working directory.
func StartWithEnvironment ¶ added in v1.138.0
func StartWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) (*Subprocess, error)
StartWithEnvironment starts a command (i.e. spawns a subprocess). It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func StartWithEnvironmentWithDir ¶ added in v1.157.0
func StartWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) (*Subprocess, error)
StartWithEnvironmentWithDir starts a command (i.e. spawns a subprocess) with a working directory. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func StartWithEnvironmentWithIO ¶ added in v1.138.0
func StartWithEnvironmentWithIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) (p *Subprocess, err error)
StartWithEnvironmentWithIO starts a command (i.e. spawns a subprocess) with overridden stdin/stdout/stderr. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func StartWithEnvironmentWithIOWithDir ¶ added in v1.157.0
func StartWithEnvironmentWithIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, additionalEnvVars []string, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) (p *Subprocess, err error)
StartWithEnvironmentWithIOWithDir starts a command (i.e. spawns a subprocess) with a working directory and overridden stdin/stdout/stderr. It allows to specify the environment the subprocess should use. Each entry is of the form "key=value".
func (*Subprocess) Cancel ¶
func (s *Subprocess) Cancel()
Cancel interrupts an ongoing process. This method is idempotent.
func (*Subprocess) Check ¶
func (s *Subprocess) Check() error
Check checks whether the subprocess is correctly defined.
func (*Subprocess) Execute ¶
func (s *Subprocess) Execute() (err error)
Execute executes the command and waits for completion.
func (*Subprocess) Interrupt ¶ added in v1.100.0
func (s *Subprocess) Interrupt(ctx context.Context) (err error)
Interrupt terminates the process This method should be used in combination with `Start`. This method is idempotent
func (*Subprocess) IsOn ¶
func (s *Subprocess) IsOn() bool
IsOn states whether the subprocess is running or not.
func (*Subprocess) Restart ¶
func (s *Subprocess) Restart() (err error)
Restart restarts a process. It will stop the process if currently running.
func (*Subprocess) Setup ¶
func (s *Subprocess) Setup(ctx context.Context, loggers logs.Loggers, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) (err error)
Setup sets up a sub-process i.e. defines the command cmd and the messages on start, success and failure.
func (*Subprocess) SetupAs ¶ added in v1.48.0
func (s *Subprocess) SetupAs(ctx context.Context, loggers logs.Loggers, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, cmd string, args ...string) (err error)
SetupAs is similar to Setup but allows the command to be run as a different user.
func (*Subprocess) SetupAsWithCustomIO ¶ added in v1.122.0
func (s *Subprocess) SetupAsWithCustomIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, cmd string, args ...string) (err error)
SetupAsWithCustomIO is similar to SetupWithCustomIO but allows the command to be run as a different user. It allows the stdin, stdout, and stderr to be overridden.
func (*Subprocess) SetupAsWithCustomIOWithDir ¶ added in v1.157.0
func (s *Subprocess) SetupAsWithCustomIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, dir string, cmd string, args ...string) (err error)
SetupAsWithCustomIOWithDir is similar to SetupWithCustomIOWithDir but allows the command to be run as a different user. It allows the stdin, stdout, and stderr to be overridden.
func (*Subprocess) SetupAsWithDir ¶ added in v1.157.0
func (s *Subprocess) SetupAsWithDir(ctx context.Context, loggers logs.Loggers, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, dir string, cmd string, args ...string) (err error)
SetupAsWithDir is similar to SetupWithDir but allows the command to be run as a different user.
func (*Subprocess) SetupAsWithEnvironment ¶ added in v1.60.0
func (s *Subprocess) SetupAsWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnv []string, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, cmd string, args ...string) (err error)
SetupAsWithEnvironment is similar to Setup but allows the command to be run as a different user. Compared to SetupAs, it allows specifying additional environment variables to be used by the process.
func (*Subprocess) SetupAsWithEnvironmentWithCustomIO ¶ added in v1.122.0
func (s *Subprocess) SetupAsWithEnvironmentWithCustomIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, additionalEnv []string, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, cmd string, args ...string) (err error)
SetupAsWithEnvironmentWithCustomIO is similar to SetupWithCustomIO but allows the command to be run as a different user. Compared to SetupAsWithCustomIO, it allows specifying additional environment variables to be used by the process. It allows the stdin, stdout, and stderr to be overridden.
func (*Subprocess) SetupAsWithEnvironmentWithCustomIOWithDir ¶ added in v1.157.0
func (s *Subprocess) SetupAsWithEnvironmentWithCustomIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, additionalEnv []string, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, dir string, cmd string, args ...string) (err error)
SetupAsWithEnvironmentWithCustomIOWithDir is similar to SetupWithCustomIOWithDir but allows the command to be run as a different user. Compared to SetupAsWithCustomIOWithDir, it allows specifying additional environment variables to be used by the process. It allows the stdin, stdout, and stderr to be overridden.
func (*Subprocess) SetupAsWithEnvironmentWithDir ¶ added in v1.157.0
func (s *Subprocess) SetupAsWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnv []string, messageOnStart string, messageOnSuccess, messageOnFailure string, as *commandUtils.CommandAsDifferentUser, dir string, cmd string, args ...string) (err error)
SetupAsWithEnvironmentWithDir is similar to SetupWithDir but allows the command to be run as a different user. Compared to SetupAsWithDir, it allows specifying additional environment variables to be used by the process.
func (*Subprocess) SetupWithCustomIO ¶ added in v1.122.0
func (s *Subprocess) SetupWithCustomIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) (err error)
SetupWithCustomIO sets up a sub-process i.e. defines the command cmd and the messages on start, success and failure. It allows the stdin, stdout, and stderr to be overridden.
func (*Subprocess) SetupWithCustomIOWithDir ¶ added in v1.157.0
func (s *Subprocess) SetupWithCustomIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) (err error)
SetupWithCustomIOWithDir sets up a sub-process i.e. defines the command cmd and the messages on start, success and failure with a working directory. It allows the stdin, stdout, and stderr to be overridden.
func (*Subprocess) SetupWithDir ¶ added in v1.157.0
func (s *Subprocess) SetupWithDir(ctx context.Context, loggers logs.Loggers, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) (err error)
SetupWithDir sets up a sub-process i.e. defines the command cmd and the messages on start, success and failure with a working directory.
func (*Subprocess) SetupWithEnvironment ¶ added in v1.60.0
func (s *Subprocess) SetupWithEnvironment(ctx context.Context, loggers logs.Loggers, additionalEnv []string, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) (err error)
SetupWithEnvironment sets up a sub-process i.e. defines the command cmd and the messages on start, success and failure. Compared to Setup, it allows specifying additional environment variables to be used by the process.
func (*Subprocess) SetupWithEnvironmentWithCustomIO ¶ added in v1.122.0
func (s *Subprocess) SetupWithEnvironmentWithCustomIO(ctx context.Context, loggers logs.Loggers, io ICommandIO, additionalEnv []string, messageOnStart string, messageOnSuccess, messageOnFailure string, cmd string, args ...string) (err error)
SetupWithEnvironmentWithCustomIO sets up a sub-process i.e. defines the command cmd and the messages on start, success and failure. Compared to SetupWithCustomIO, it allows specifying additional environment variables to be used by the process. It allows the stdin, stdout, and stderr to be overridden.
func (*Subprocess) SetupWithEnvironmentWithCustomIOWithDir ¶ added in v1.157.0
func (s *Subprocess) SetupWithEnvironmentWithCustomIOWithDir(ctx context.Context, loggers logs.Loggers, io ICommandIO, additionalEnv []string, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) (err error)
SetupWithEnvironmentWithCustomIOWithDir sets up a sub-process i.e. defines the command cmd and the messages on start, success and failure with a working directory. Compared to SetupWithCustomIOWithDir, it allows specifying additional environment variables to be used by the process. It allows the stdin, stdout, and stderr to be overridden.
func (*Subprocess) SetupWithEnvironmentWithDir ¶ added in v1.157.0
func (s *Subprocess) SetupWithEnvironmentWithDir(ctx context.Context, loggers logs.Loggers, additionalEnv []string, messageOnStart string, messageOnSuccess, messageOnFailure string, dir string, cmd string, args ...string) (err error)
SetupWithEnvironmentWithDir sets up a sub-process i.e. defines the command cmd and the messages on start, success and failure with a working directory. Compared to SetupWithDir, it allows specifying additional environment variables to be used by the process.
func (*Subprocess) Start ¶
func (s *Subprocess) Start() (err error)
Start starts the process if not already started. This method is idempotent.
func (*Subprocess) Stop ¶
func (s *Subprocess) Stop() (err error)
Stop stops the process straight away if currently working without waiting for completion. This method should be used in combination with `Start`. However, in order to interrupt a process however it was started (using `Start` or `Execute`), prefer `Cancel`. This method is idempotent.