juju: github.com/juju/juju/worker/uniter/runner Index | Files | Directories

package runner

import "github.com/juju/juju/worker/uniter/runner"

Index

Package Files

args.go env.go factory.go runner.go

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")
)

type Context Uses

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 Uses

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

ExecFunc is the exec func type.

type ExecParams Uses

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 Uses

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 identified by the supplied id.
    NewActionRunner(actionId string, cancel <-chan struct{}) (Runner, error)
}

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

func NewFactory Uses

func NewFactory(
    state *uniter.State,
    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 Uses

type HookHandlerType string

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

func (HookHandlerType) String Uses

func (t HookHandlerType) String() string

String implements fmt.Stringer for HookHandlerType.

type NewRunnerFunc Uses

type NewRunnerFunc func(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 Uses

type RunLocation string

RunLocation dictates where to execute commands.

type Runner Uses

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.

func NewRunner Uses

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

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

Directories

PathSynopsis
contextPackage context contains the ContextFactory and Context definitions.
context/mocksPackage mocks is a generated GoMock package.
debug
jujucThe 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.
jujuc/jujuctesting
jujuc/mocksPackage mocks is a generated GoMock package.
testing

Package runner imports 32 packages (graph) and is imported by 110 packages. Updated 2020-08-09. Refresh now. Tools for package owners.