Documentation
¶
Index ¶
Constants ¶
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") )
const ( // ErrTerminated indicate the hook or action exited due to a SIGTERM or SIGKILL signal. ErrTerminated = errors.ConstError("terminated") )
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(stdCtx stdcontext.Context, commandInfo context.CommandInfo) (Runner, error) // NewHookRunner returns an execution context suitable for running the // supplied hook definition (which must be valid). NewHookRunner(stdCtx stdcontext.Context, hookInfo hook.Info) (Runner, error) // NewActionRunner returns an execution context suitable for running the action. NewActionRunner(stdCtx stdcontext.Context, 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, ) ( 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 Option ¶
type Option func(*options)
Option is a functional option for NewRunner.
func WithExecutor ¶
WithExecutor passes a custom executor to the runner.
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(ctx stdcontext.Context, name string) (HookHandlerType, error) // RunAction executes the action with the supplied name. RunAction(ctx stdcontext.Context, name string) (HookHandlerType, error) // RunCommands executes the supplied script. RunCommands(ctx stdcontext.Context, commands string) (*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. |
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. |
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |