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

type Context Uses

type Context interface {
    jujuc.Context
    Id() string
    HookVars(paths context.Paths, remote bool) ([]string, error)
    ActionData() (*context.ActionData, error)
    SetProcess(process context.HookProcess)
    HasExecutionSetUnitStatus() bool
    ResetExecutionSetUnitStatus()
    ModelType() model.ModelType

    Prepare() error
    Flush(badge string, failure error) error
}

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) (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,
    remoteExecutor ExecFunc,
) (
    Factory, error,
)

NewFactory returns a Factory capable of creating runners for executing charm hooks, actions and 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.
    RunHook(name string) error

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

    // RunCommands executes the supplied script.
    RunCommands(commands string) (*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.
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
testing

Package runner imports 30 packages (graph) and is imported by 102 packages. Updated 2019-11-16. Refresh now. Tools for package owners.