util

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CmdReporterAppName is the app name reported by cmd-reporter, notably on the ConfigMap's application label.
	CmdReporterAppName = "rook-cmd-reporter"

	// CmdReporterConfigMapStdoutKey defines the key in the ConfigMap where stdout is reported.
	CmdReporterConfigMapStdoutKey = "stdout"

	// CmdReporterConfigMapStderrKey defines the key in the ConfigMap where stderr is reported.
	CmdReporterConfigMapStderrKey = "stderr"

	// CmdReporterConfigMapRetcodeKey defines the key in the ConfigMap where the return code is reported.
	CmdReporterConfigMapRetcodeKey = "retcode"
)

Variables

This section is empty.

Functions

func CmdReporterFlagArgumentToCommand

func CmdReporterFlagArgumentToCommand(flagArg string) (cmd []string, args []string, err error)

CmdReporterFlagArgumentToCommand converts a string representation of a command compatible with the job reporter's command line flag "--command" into a command and arguments in typical Kubernetes container format, i.e., a list of command strings and a list of arguments. This function processes the argument to "--command" but not the "--command" text itself.

func CommandToCmdReporterFlagArgument

func CommandToCmdReporterFlagArgument(cmd []string, args []string) (string, error)

CommandToCmdReporterFlagArgument converts a command and arguments in typical Kubernetes container format into a string representation of the command+args that is compatible with the job reporter's command line flag "--command". This only returns the argument to "--command" and not the "--command" text itself.

func CopyBinaries

func CopyBinaries(target string) error

CopyBinaries copies the "tini" and "rook" binaries to a shared volume at the target path.

Types

type CmdReporter

type CmdReporter struct {
	// contains filtered or unexported fields
}

CmdReporter is a process intended to be run in simple Kubernetes jobs. The CmdReporter runs a command in a job and stores the results in a ConfigMap which can be read by the operator.

func NewCmdReporter

func NewCmdReporter(clientset kubernetes.Interface, cmd, args []string, configMapName, namespace string) (*CmdReporter, error)

NewCmdReporter creates a new CmdReporter and returns an error if cmd, configMapName, or Namespace aren't specified.

func (*CmdReporter) Run

func (r *CmdReporter) Run() error

Run a given command to completion, and store the Stdout, Stderr, and return code results of the command in a ConfigMap. If the ConfigMap already exists, the Stdout, Stderr, and return code data which may be present in the ConfigMap will be overwritten.

If cmd-reporter succeeds in running the command to completion, no error is reported, even if the command's return code is nonzero (failure). Run will return an error if the command could not be run for any reason or if there was an error storing the command results into the ConfigMap. An application label is applied to the ConfigMap, and if the label already exists and has a different application's name name, this returns an error, as this may indicate that it is not safe for cmd-reporter to edit the ConfigMap.

Jump to

Keyboard shortcuts

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