Documentation
¶
Overview ¶
Copyright @ 2021 bocloud <fushaosong@beyondcent.com>.
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 ¶
- type CommandExecutor
- func (c *CommandExecutor) ExecuteCommand(command string, arg ...string) error
- func (*CommandExecutor) ExecuteCommandResidentBinary(timeout time.Duration, command string, arg ...string) error
- func (*CommandExecutor) ExecuteCommandWithCombinedOutput(command string, arg ...string) (string, error)
- func (*CommandExecutor) ExecuteCommandWithEnv(env []string, command string, arg ...string) error
- func (*CommandExecutor) ExecuteCommandWithOutput(command string, arg ...string) (string, error)
- func (*CommandExecutor) ExecuteCommandWithOutputFile(command, outfileArg string, arg ...string) (string, error)
- func (*CommandExecutor) ExecuteCommandWithOutputFileTimeout(timeout time.Duration, command, outfileArg string, arg ...string) (string, error)
- func (*CommandExecutor) ExecuteCommandWithTimeout(timeout time.Duration, command string, arg ...string) (string, error)
- type Executor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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) ExecuteCommandResidentBinary ¶
func (*CommandExecutor) ExecuteCommandWithCombinedOutput ¶
func (*CommandExecutor) ExecuteCommandWithCombinedOutput(command string, arg ...string) (string, error)
ExecuteCommandWithCombinedOutput executes a command with combined output
func (*CommandExecutor) ExecuteCommandWithEnv ¶
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 ¶
func (*CommandExecutor) ExecuteCommandWithOutputFile(command, outfileArg string, arg ...string) (string, error)
ExecuteCommandWithOutputFile executes a command with output on a file #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) ExecuteCommandWithOutputFileTimeout ¶
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 ¶
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, command 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) ExecuteCommandResidentBinary(timeout time.Duration, command string, arg ...string) error }
Executor is the main interface for all the exec commands