pallet.action-plan documentation

An action plan contains instances of actions (action maps) for execution.

The action plan is built by executing a phase function. Each phase function calls actions which insert themselves into the action plan.

The action plan is transformed to provide aggregated operations, run delayed crate functions, and to resolve precedence relations between actions.

A translated plan is executed by passing an executor, which is a function that will be passed each action map in the plan. The executor function is responsible for selecting the implementation of the action to be used, and calling the implementation with the action-map arguments.

Note this is an implementation namespace.

action-data

fn

[session {:keys [action args blocks], :as action-m}]

Return an action's data.

action-map

fn

[action arg-vector {:as options}]

Return an action map for the given action and args. The action map is an instance of an action. The action plan is a tree of action maps.

options specifies naming and dependencies for this instance of the action, and may contain :action-id, :always-before and :always-after keys. If an options is supplied, an action-id is generated if none present, to ensure that the standard action precedence is not altered. :script-dir and user options like :sudo-user may also be specified. :script-prefix can be used to prefix with something other than sudo.

  • :action the action that is scheduled,
  • :args the arguments to pass to the action function,
  • :context captures the phase context, for use at execution time,
  • :action-id a keyword that identifies the instance of an action,
  • :always-before a symbol, keyword or set thereof. A symbol references an action, and a keyword references an instance of an action,
  • :always-after a symbol, keyword or set thereof,
  • :node-value-path a symbol specifying a node value (added when scheduled).

The action is generated by the specified action function and arguments that will be applied to the function when the action plan is executed.

action-map-execution

fn

[action-map]

Helper to return the execution of the action associated with an action-map.

checked-commands

fn

[name & script]

Return a stevedore script that uses the current context to label the action

checked-commands*

macro

[name scripts]

Return a stevedore script that uses the current context to label the action

checked-script

macro

[name & script]

Return a stevedore script that uses the current context to label the action

context-label

var

Return a label for an action

defining-context-string

fn

[]

Returns a context string for the defining phase context.

execute-action-map

fn

[executor session {:keys [node-value-path context script-comments], :or {script-comments false}, :as action}]

Execute a single action, catching any exception and reporting it as an error map.

execute-if

fn

[session {:keys [blocks], :as action} value]

Execute an if action

map-action-f

fn

[exec-action action-plan session]

Map exec-action over actions in the action-plan, applying session.

pop-block

fn

[action-plan]

Take the last block and add it to the :blocks key of the scope below it in the stack. The block is reversed to put it into the order in which elements were added.

push-block

fn

[action-plan]

Push a block onto the action-plan

schedule-action-map

fn

[action-plan action-map]

Registers an action map in the action plan for execution. This function is responsible for creating a node-value (as node-value-path's have to be unique for all instances of an aggregated action) as a handle to the value that will be returned when the action map is executed.

stop-execution-on-error

fn

[[result session]]

:execute-status-fn algorithm to stop execution on an error

translate

fn

[action-plan session]

Process the action-plan, applying groupings and precedence, producing an action plan with fully bound functions, ready for execution.

This is equivalent to using an identity monad with a monadic value that is a tree of action maps.

translated?

fn

[action-plan]

Predicate to test if an action plan has been translated