actionrouter

package
v1.0.0-alpha1.0...-2e0dbe4 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultHumanRenderer

func DefaultHumanRenderer(data interface{}) string

func Do

func Do(t Actioner) error

Do is the switch method between local, remote or async mode. If Watch is set, end up starting a monitor on the selected objects.

Types

type Actioner

type Actioner interface {
	DoRemote() error
	DoLocal() error
	DoAsync() error
	HasLocal() bool
	Options() T
}

Actioner is the interface implemented by nodeaction.T and objectaction.T

type Result

type Result struct {
	Nodename      string        `json:"nodename"`
	Path          naming.Path   `json:"path,omitempty"`
	Data          interface{}   `json:"data"`
	Error         error         `json:"-"`
	Panic         interface{}   `json:"-"`
	HumanRenderer func() string `json:"-"`
}

Result is a predictible type of actions return value, for reflect.

func (Result) Unstructured

func (t Result) Unstructured() map[string]any

type T

type T struct {
	Digest bool

	//
	// ObjectSelector expands into a selection of objects to execute
	// the action on.
	//
	ObjectSelector string

	//
	// NodeSelector expands into a selection of nodes to execute the
	// action on.
	//
	NodeSelector string

	RID    string
	Subset string
	Tag    string

	//
	// Local routes the action to the CRM instead of remoting it via
	// orchestration or remote execution.
	//
	Local bool

	//
	// DefaultIsLocal makes actions not explicitely Local nor remoted
	// via NodeSelector be treated as local (CRM level).
	//
	DefaultIsLocal bool

	//
	// Flags is the command flags as parsed by cobra. This is the struct
	// passed to the object method on local execution.
	//
	Flags any

	//
	// Target is the node or object state the daemons should orchestrate
	// to reach.
	//
	Target string

	//
	// TargetOptions is the options of the orchestration needed to reach
	// the Target.
	//
	TargetOptions any

	// Wait runs an event watcher to wait for target state or global expect reached
	Wait bool

	// WaitDuration is the maximum duration allowed for the Wait
	WaitDuration time.Duration

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

	//
	// Output controls the output data format.
	// <empty>   => human readable format
	// tab=...   => tubular customizable format
	// yaml      => yaml machine readable format
	// json      => json machine readable format
	// flat      => flattened json (<k>=<v>) machine readable format
	// flat_json => same as flat (backward compat)
	//
	Output string

	// DefaultOutput defines a default output to use when Output is
	// not specified.
	DefaultOutput string

	//
	// Color activates the colorization of outputs
	// auto => yes if os.Stdout is a tty
	// yes
	// no
	//
	Color string
}

T holds the action options common to all actioner implementations.

Jump to

Keyboard shortcuts

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