runner

package
v0.0.0-...-b0bff92 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Operator runs where the operator/uniter is running.
	Operator = RunLocation("operator")
	// Workload runs where the workload is running.
	Workload = RunLocation("workload")
)
View Source
const (
	InvalidHookHandler = HookHandlerType("invalid")

	// ExplicitHookHandler indicates that a bespoke, per-hook script was
	// used for handling a particular hook.
	ExplicitHookHandler = HookHandlerType("explicit")

	// DispatchingHookHandler indicates the use of a specialized script that
	// acts as a dispatcher for all types of hooks. This functionality has
	// been introduced with the operator framework changes.
	DispatchingHookHandler = HookHandlerType("dispatch")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecFunc

type ExecFunc func(ExecParams) (*utilexec.ExecResponse, error)

ExecFunc is the exec func type.

type ExecParams

type ExecParams struct {
	Commands      []string
	Env           []string
	WorkingDir    string
	Clock         clock.Clock
	ProcessSetter func(context.HookProcess)
	Cancel        <-chan struct{}

	Stdout       io.ReadWriter
	StdoutLogger charmrunner.Stopper

	Stderr       io.ReadWriter
	StderrLogger charmrunner.Stopper
}

ExecParams holds all the necessary parameters for ExecFunc.

type Factory

type Factory interface {

	// NewCommandRunner returns an execution context suitable for running
	// an arbitrary script.
	NewCommandRunner(commandInfo context.CommandInfo) (Runner, error)

	// NewHookRunner returns an execution context suitable for running the
	// supplied hook definition (which must be valid).
	NewHookRunner(hookInfo hook.Info) (Runner, error)

	// NewActionRunner returns an execution context suitable for running the action.
	NewActionRunner(action *uniter.Action, cancel <-chan struct{}) (Runner, error)
}

Factory represents a long-lived object that can create runners relevant to a specific unit.

func NewFactory

func NewFactory(
	paths context.Paths,
	contextFactory context.ContextFactory,
	newProcessRunner NewRunnerFunc,
	remoteExecutor ExecFunc,
) (
	Factory, error,
)

NewFactory returns a Factory capable of creating runners for executing charm hooks, actions and commands.

type HookHandlerType

type HookHandlerType string

HookHandlerType is used to indicate the type of script used for handling a particular hook type.

func (HookHandlerType) String

func (t HookHandlerType) String() string

String implements fmt.Stringer for HookHandlerType.

type NewRunnerFunc

type NewRunnerFunc func(context context.Context, paths context.Paths, remoteExecutor ExecFunc) Runner

NewRunnerFunc returns a func used to create a Runner backed by the supplied context and paths.

type RunLocation

type RunLocation string

RunLocation dictates where to execute commands.

type Runner

type Runner interface {
	// Context returns the context against which the runner executes.
	Context() context.Context

	// RunHook executes the hook with the supplied name and returns back
	// the type of script handling hook that was used or whether any errors
	// occurred.
	RunHook(name string) (HookHandlerType, error)

	// RunAction executes the action with the supplied name.
	RunAction(name string) (HookHandlerType, error)

	// RunCommands executes the supplied script.
	RunCommands(commands string, runLocation RunLocation) (*utilexec.ExecResponse, error)
}

Runner is responsible for invoking commands in a context.

func NewRunner

func NewRunner(context context.Context, paths context.Paths, remoteExecutor ExecFunc) Runner

NewRunner returns a Runner backed by the supplied context and paths.

Directories

Path Synopsis
Package context contains the ContextFactory and Context definitions.
Package context contains the ContextFactory and Context definitions.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package jujuc implements the server side of the jujuc proxy tool, which forwards command invocations to the unit agent process so that they can be executed against specific state.
Package jujuc implements the server side of the jujuc proxy tool, which forwards command invocations to the unit agent process so that they can be executed against specific state.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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