exec

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

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.

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

This section is empty.

Types

type CommandError

type CommandError struct {
	ActionName string
	Err        error
}

func (*CommandError) Error

func (e *CommandError) Error() string

func (*CommandError) ExitStatus

func (e *CommandError) ExitStatus() int

type CommandExecutor

type CommandExecutor struct {
}

func (*CommandExecutor) ExecuteCommand

func (*CommandExecutor) ExecuteCommand(debug bool, actionName string, command string, arg ...string) error

Start a process and wait for its completion

func (*CommandExecutor) ExecuteCommandWithCombinedOutput added in v0.3.0

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

func (*CommandExecutor) ExecuteCommandWithOutput

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

func (*CommandExecutor) ExecuteCommandWithOutputFile added in v0.5.0

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

func (*CommandExecutor) ExecuteCommandWithOutputFileTimeout added in v1.1.0

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

Same as ExecuteCommandWithOutputFile but with a timeout limit.

func (*CommandExecutor) ExecuteCommandWithTimeout added in v0.6.0

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

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

func (*CommandExecutor) ExecuteStat added in v0.4.0

func (*CommandExecutor) ExecuteStat(name string) (os.FileInfo, error)

func (*CommandExecutor) StartExecuteCommand

func (*CommandExecutor) StartExecuteCommand(debug bool, actionName string, command string, arg ...string) (*exec.Cmd, error)

Start a process and return immediately

type Executor

type Executor interface {
	StartExecuteCommand(debug bool, actionName string, command string, arg ...string) (*exec.Cmd, error)
	ExecuteCommand(debug bool, actionName string, command string, arg ...string) error
	ExecuteCommandWithOutput(debug bool, actionName string, command string, arg ...string) (string, error)
	ExecuteCommandWithCombinedOutput(debug bool, actionName string, command string, arg ...string) (string, error)
	ExecuteCommandWithOutputFile(debug bool, actionName, command, outfileArg string, arg ...string) (string, error)
	ExecuteCommandWithOutputFileTimeout(debug bool, timeout time.Duration, actionName, command, outfileArg string, arg ...string) (string, error)
	ExecuteCommandWithTimeout(debug bool, timeout time.Duration, actionName string, command string, arg ...string) (string, error)
	ExecuteStat(name string) (os.FileInfo, error)
}

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(debug bool, actionName string, 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(debug bool, actionName string, 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(debug bool, actionName string, command string, arg ...string) (string, error)

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

func (*TranslateCommandExecutor) ExecuteCommandWithOutput added in v1.1.0

func (e *TranslateCommandExecutor) ExecuteCommandWithOutput(debug bool, actionName string, 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(debug bool, actionName string, 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(
	debug bool, timeout time.Duration, actionName string,
	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(debug bool, timeout time.Duration, actionName string, command string, arg ...string) (string, error)

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

func (*TranslateCommandExecutor) ExecuteStat added in v1.1.0

func (e *TranslateCommandExecutor) ExecuteStat(name string) (os.FileInfo, error)

ExecuteStat returns a file stat

func (*TranslateCommandExecutor) StartExecuteCommand added in v1.1.0

func (e *TranslateCommandExecutor) StartExecuteCommand(debug bool, actionName string, command string, arg ...string) (*exec.Cmd, error)

StartExecuteCommand starts a process and return immediately

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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