Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandOption ¶
type CommandOption interface { ShellScriptOption // ApplyToCommandOptions copies the configuration of this option to the // given command execution options. ApplyToCommandOptions(target *CommandOptions) }
CommandOption is a setter for one or more command or script execution options.
type CommandOptions ¶
type CommandOptions struct { // Container is the name of the container to run the command in. If not // specified, defaults to the first container in the pod. Container string }
CommandOptions customizes command execution.
func (*CommandOptions) ApplyOptions ¶
func (o *CommandOptions) ApplyOptions(opts []CommandOption)
ApplyOptions runs each of the given options against this command execution options struct.
func (CommandOptions) ApplyToCommandOptions ¶
func (o CommandOptions) ApplyToCommandOptions(target *CommandOptions)
ApplyToCommandOptions copies all of the options set on this struct to another set of command execution options.
func (CommandOptions) ApplyToShellScriptOptions ¶
func (o CommandOptions) ApplyToShellScriptOptions(target *ShellScriptOptions)
ApplyToShellScriptOptions copies all of the options set on this struct to the given shell script execution options.
type Result ¶
type Result struct { // ExitCode is the exit code returned by the command. ExitCode int // Stdout is the complete contents of the command's standard output file // descriptor. Stdout string // Stderr is the complete contents of the command's standard error file // descriptor. Stderr string }
Result provides access to some information after running a command.
func Command ¶
func Command(ctx context.Context, cfg *rest.Config, pod *corev1obj.Pod, command []string, opts ...CommandOption) (*Result, error)
Command executes an arbitrary command in the specified pod.
The result of executing the command is provided in the returned struct. If the command fails, this function will not return an error, but the result ExitCode will be set to a non-zero value.
func ShellScript ¶
func ShellScript(ctx context.Context, cfg *rest.Config, pod *corev1obj.Pod, script string, opts ...ShellScriptOption) (*Result, error)
ShellScript executes an arbitrary script in the specified pod.
Other than presenting a simplified way of specifying the content of the script to run, it behaves identically to Command.
type ShellScriptOption ¶
type ShellScriptOption interface {
ApplyToShellScriptOptions(target *ShellScriptOptions)
}
ShellScriptOption is a setter for one or more shell script execution options.
type ShellScriptOptions ¶
type ShellScriptOptions struct { CommandOptions // Shell is the path to the shell to use for executing the script. Defaults // to /bin/sh. Shell string }
ShellScriptOptions customizes shell script execution.
func (*ShellScriptOptions) ApplyOptions ¶
func (o *ShellScriptOptions) ApplyOptions(opts []ShellScriptOption)
ApplyOptions runs each of the given options against this shell script execution options struct.
func (ShellScriptOptions) ApplyToShellScriptOptions ¶
func (o ShellScriptOptions) ApplyToShellScriptOptions(target *ShellScriptOptions)
ApplyToShellScriptOptions copies all of the options set on this struct to another set of shell script execution options.
type WithContainer ¶
type WithContainer string
WithContainer specifies a container name to use for command execution.
func (WithContainer) ApplyToCommandOptions ¶
func (wc WithContainer) ApplyToCommandOptions(target *CommandOptions)
ApplyToCommandOptions sets the container name when executing a command directly.
func (WithContainer) ApplyToShellScriptOptions ¶
func (wc WithContainer) ApplyToShellScriptOptions(target *ShellScriptOptions)
ApplyToShellScriptOptions sets the container name when executing a shell script.
type WithShell ¶
type WithShell string
WithShell specifies the name of the POSIX-compatible shell to use when executing a shell script.
func (WithShell) ApplyToShellScriptOptions ¶
func (ws WithShell) ApplyToShellScriptOptions(target *ShellScriptOptions)
ApplyToShellScriptOptions sets the shell when executing a shell script.