nodeaction

package
v3.0.0-rc71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 27 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRemoteFunc = errors.New("this command runs on the local node only, the api serves no remote form of it")

ErrNoRemoteFunc is the answer of an action asked of a node through the api when the command has no remote form.

Functions

func LocalFirst

func LocalFirst() funcopt.O

LocalFirst makes actions not explicitly Local nor remoted via NodeSelector be treated as local (CRM level).

func WithAsyncFollow

func WithAsyncFollow(v bool) funcopt.O

WithAsyncFollow streams the logs of the action until it ends, rather than answering the ids it was accepted as: the logs of its session for an action asked of the daemons of nodes, of its orchestration for a target state.

func WithAsyncFunc

func WithAsyncFunc(f func(context.Context) (api.OrchestrationQueued, error)) funcopt.O

WithAsyncFunc sets a function to run if the action is async

func WithAsyncTarget

func WithAsyncTarget(s string) funcopt.O

WithAsyncTarget is the node or object state the daemons should orchestrate to reach.

func WithAsyncTime

func WithAsyncTime(d time.Duration) funcopt.O

WithAsyncTime is the maximum duration to wait for an async action It needs WithAsyncWait(true)

func WithAsyncWait

func WithAsyncWait(v bool) funcopt.O

WithAsyncWait runs an event-watcher waiting for target state, global expect reached

func WithAsyncWaitFunc

func WithAsyncWaitFunc(f func(context.Context, *client.T, uuid.UUID, string) error) funcopt.O

WithAsyncWaitFunc sets how the end of the orchestration is waited for, in place of asking the node that accepted it until it says so.

func WithAsyncWatch

func WithAsyncWatch(v bool) funcopt.O

WithAsyncWatch runs an event-driven monitor on the selected objects after setting a new target. So the operator can see the orchestration unfolding.

func WithColor

func WithColor(s string) funcopt.O

WithColor activates the colorization of outputs auto => yes if os.Stdout is a tty yes no

func WithDefaultOutput

func WithDefaultOutput(s string) funcopt.O

WithDefaultOutput sets the output the results are rendered in when the user asks for none. Empty, a result is rendered as the action run on this node renders it, under the name of its node when there are several: the remote function of the action answers what the action did, not the ids of the execs it started.

func WithFormat

func WithFormat(s string) funcopt.O

WithFormat controls the output data format. <empty> => human readable format json => json machine readable format flat => flattened json (<k>=<v>) machine readable format flat_json => same as flat (backward compat)

func WithLocal

func WithLocal(v bool) funcopt.O

WithLocal routes the action to the CRM instead of remoting it via orchestration or remote execution.

func WithLocalFunc

func WithLocalFunc(f func() (any, error)) funcopt.O

WithLocalFunc sets a function to run if the action is local

func WithRemoteFunc

func WithRemoteFunc(f func(context.Context, string) (any, error)) funcopt.O

WithRemoteFunc sets a function to run if the action is remote

func WithRemoteNodes

func WithRemoteNodes(s string) funcopt.O

WithRemoteNodes expands into a selection of nodes to execute the action on.

func WithSort

func WithSort(s string) funcopt.O

WithSort sets the order of the result table.

An action reaching several nodes answers a row per run, and they arrive in whatever order the nodes answered in.

Types

type T

type T struct {
	actionrouter.T
	// AsyncFunc submits the action and answers the orchestration it was
	// accepted as, which is what a wait waits for, and the node that
	// accepted it, which a wait asks.
	AsyncFunc  func(context.Context) (api.OrchestrationQueued, error)
	LocalFunc  func() (any, error)
	RemoteFunc func(context.Context, string) (any, error)

	// WaitFunc waits for the orchestration to end, in place of asking
	// the node that accepted it until it says so: an upgrade of the
	// packages restarts that node's daemon.
	WaitFunc func(context.Context, *client.T, uuid.UUID, string) error
	// contains filtered or unexported fields
}

T has is an actionrouter.T with a node func

func New

func New(opts ...funcopt.O) *T

func (T) Do

func (t T) Do() error

func (T) DoAsync

func (t T) DoAsync() error

DoAsync uses the agent API to submit a target state to reach via an orchestration.

func (T) DoLocal

func (t T) DoLocal() error

func (T) DoRemote

func (t T) DoRemote() error

DoRemote posts the action to a peer node agent API, for synchronous execution.

func (T) HasLocal

func (t T) HasLocal() bool

func (T) Options

func (t T) Options() actionrouter.T

Options returns the base Action struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL