exec

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: Apache-2.0 Imports: 12 Imported by: 230

Documentation

Overview

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitStatus added in v1.3.0

func ExitStatus(err error) (int, bool)

Types

type CommandExecutor

type CommandExecutor struct {
}

CommandExecutor is the type of the Executor

func (*CommandExecutor) ExecuteCommand

func (c *CommandExecutor) ExecuteCommand(command string, arg ...string) error

ExecuteCommand starts a process and wait for its completion

func (*CommandExecutor) ExecuteCommandWithCombinedOutput added in v0.3.0

func (*CommandExecutor) ExecuteCommandWithCombinedOutput(command string, arg ...string) (string, error)

ExecuteCommandWithCombinedOutput executes a command with combined output

func (*CommandExecutor) ExecuteCommandWithEnv added in v1.3.0

func (*CommandExecutor) ExecuteCommandWithEnv(env []string, command string, arg ...string) error

ExecuteCommandWithEnv starts a process with env variables and wait for its completion

func (*CommandExecutor) ExecuteCommandWithOutput

func (*CommandExecutor) ExecuteCommandWithOutput(command string, arg ...string) (string, error)

ExecuteCommandWithOutput executes a command with output

func (*CommandExecutor) ExecuteCommandWithOutputFile added in v0.5.0

func (*CommandExecutor) ExecuteCommandWithOutputFile(command, outfileArg string, arg ...string) (string, error)

ExecuteCommandWithOutputFile executes a command with output on a file

func (*CommandExecutor) ExecuteCommandWithOutputFileTimeout added in v1.1.0

func (*CommandExecutor) ExecuteCommandWithOutputFileTimeout(timeout time.Duration,
	command, outfileArg string, arg ...string) (string, error)

ExecuteCommandWithOutputFileTimeout Same as ExecuteCommandWithOutputFile but with a timeout limit. #nosec G307 Calling defer to close the file without checking the error return is not a risk for a simple file open and close

func (*CommandExecutor) ExecuteCommandWithTimeout added in v0.6.0

func (*CommandExecutor) ExecuteCommandWithTimeout(timeout time.Duration, command string, arg ...string) (string, error)

ExecuteCommandWithTimeout starts a process and wait for its completion with timeout.

type Executor

type Executor interface {
	ExecuteCommand(command string, arg ...string) error
	ExecuteCommandWithEnv(env []string, comand string, arg ...string) error
	ExecuteCommandWithOutput(command string, arg ...string) (string, error)
	ExecuteCommandWithCombinedOutput(command string, arg ...string) (string, error)
	ExecuteCommandWithOutputFile(command, outfileArg string, arg ...string) (string, error)
	ExecuteCommandWithOutputFileTimeout(timeout time.Duration, command, outfileArg string, arg ...string) (string, error)
	ExecuteCommandWithTimeout(timeout time.Duration, command string, arg ...string) (string, error)
}

Executor is the main interface for all the exec commands

type TranslateCommandExecutor added in v1.1.0

type TranslateCommandExecutor struct {

	// Executor is probably a exec.CommandExecutor that will run the translated commands
	Executor Executor

	// Translator translates every command before running it
	Translator func(command string, arg ...string) (string, []string)
}

TranslateCommandExecutor is an exec.Executor that translates every command before executing it This is useful to run the commands in a job with `kubectl run ...` when running the operator outside of Kubernetes and need to run tools that require running inside the cluster.

func (*TranslateCommandExecutor) ExecuteCommand added in v1.1.0

func (e *TranslateCommandExecutor) ExecuteCommand(command string, arg ...string) error

ExecuteCommand starts a process and wait for its completion

func (*TranslateCommandExecutor) ExecuteCommandWithCombinedOutput added in v1.1.0

func (e *TranslateCommandExecutor) ExecuteCommandWithCombinedOutput(command string, arg ...string) (string, error)

ExecuteCommandWithCombinedOutput starts a process and returns its stdout and stderr combined.

func (*TranslateCommandExecutor) ExecuteCommandWithEnv added in v1.3.0

func (e *TranslateCommandExecutor) ExecuteCommandWithEnv(env []string, command string, arg ...string) error

ExecuteCommandWithEnv starts a process with an env variable and wait for its completion

func (*TranslateCommandExecutor) ExecuteCommandWithOutput added in v1.1.0

func (e *TranslateCommandExecutor) ExecuteCommandWithOutput(command string, arg ...string) (string, error)

ExecuteCommandWithOutput starts a process and wait for its completion

func (*TranslateCommandExecutor) ExecuteCommandWithOutputFile added in v1.1.0

func (e *TranslateCommandExecutor) ExecuteCommandWithOutputFile(command, outfileArg string, arg ...string) (string, error)

ExecuteCommandWithOutputFile starts a process and saves output to file

func (*TranslateCommandExecutor) ExecuteCommandWithOutputFileTimeout added in v1.1.0

func (e *TranslateCommandExecutor) ExecuteCommandWithOutputFileTimeout(
	timeout time.Duration,
	command, outfileArg string, arg ...string) (string, error)

ExecuteCommandWithOutputFileTimeout is the same as ExecuteCommandWithOutputFile but with a timeout limit.

func (*TranslateCommandExecutor) ExecuteCommandWithTimeout added in v1.1.0

func (e *TranslateCommandExecutor) ExecuteCommandWithTimeout(timeout time.Duration, command string, arg ...string) (string, error)

ExecuteCommandWithTimeout starts a process and wait for its completion with timeout.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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