Documentation
¶
Index ¶
Constants ¶
const ( // Operator runs where the operator/uniter is running. Operator = RunLocation("operator") // Workload runs where the workload is running. Workload = RunLocation("workload") )
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 Context ¶
type Context interface {
jujuc.Context
Id() string
HookVars(paths context.Paths, remote bool, getEnvFunc context.GetEnvFunc) ([]string, error)
ActionData() (*context.ActionData, error)
SetProcess(process context.HookProcess)
HasExecutionSetUnitStatus() bool
ResetExecutionSetUnitStatus()
ModelType() model.ModelType
Prepare() error
Flush(badge string, failure error) error
GetLogger(module string) loggo.Logger
}
Context exposes hooks.Context, and additional methods needed by Runner.
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 ¶
NewRunnerFunc returns a func used to create a Runner backed by the supplied context and paths.
type Runner ¶
type Runner interface {
// Context returns the context against which the runner executes.
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.
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. |
|
The worker/uniter/runner/jujuc package 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.
|
The worker/uniter/runner/jujuc package 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. |