Version: v0.0.0-...-0d16973 Latest Latest

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

Go to latest
Published: Aug 10, 2021 License: MIT Imports: 18 Imported by: 0



Package invoker handles invoking the 'mach' stage in a network-transparent manner with the c4t-mach binary.



This section is empty.


View Source
var (
	// ErrDirEmpty occurs when the local directory filepath is empty.
	ErrDirEmpty = errors.New("local dir is empty string")


This section is empty.


type ConfigPlanQuantityOverrider

type ConfigPlanQuantityOverrider struct {
	// PostPlanOverrides applies any overrides that should happen after the machine overrides.
	PostPlanOverrides quantity.MachNodeSet

ConfigPlanQuantityOverrider overrides quantities by looking up the machine that the plan targets in a config map, then extracting the overrides from there.

func (*ConfigPlanQuantityOverrider) OverrideQuantitiesFromPlan

func (c *ConfigPlanQuantityOverrider) OverrideQuantitiesFromPlan(p *plan.Plan, qs *quantity.MachNodeSet) error

type Invoker

type Invoker struct {
	// contains filtered or unexported fields

Invoker runs the machine-runner, through SSH if needed.

Much of the invoker's behaviour is injected through two sources: a runner factory (which can either pass in cached SSH-or-lack-therof configuration, or delegate to the incoming machine plan), and a set of quantity overrides (that can either be fully pre-cached, or also delegate in part to the plan). This set-up is intended to let the single-shot binary for the invoker rely almost entirely on information coming to it through the plan, while also letting the director set up the configuration in advance and bypass plan inspection.

func New

func New(ldir string, fac runner.Factory, o ...Option) (*Invoker, error)

New constructs a new Invoker with local directory ldir, runner factory fac, and options o.

func (*Invoker) Close

func (m *Invoker) Close() error

Close closes any persistent connections used by this invoker.

func (*Invoker) Run

func (m *Invoker) Run(ctx context.Context, p *plan.Plan) (*plan.Plan, error)

Run runs the machine invoker stage.

func (*Invoker) Stage

func (*Invoker) Stage() stage.Stage

Stage gets the appropriate stage information for the invoker.

type NopPlanQuantityOverrider

type NopPlanQuantityOverrider struct{}

NopPlanQuantityOverrider is a PlanQuantityOverrider that doesn't actually override quantities.

func (NopPlanQuantityOverrider) OverrideQuantitiesFromPlan

func (n NopPlanQuantityOverrider) OverrideQuantitiesFromPlan(*plan.Plan, *quantity.MachNodeSet) error

OverrideQuantitiesFromPlan does nothing.

type Observer

type Observer interface {

Observer is the union of the various interfaces of observers used by invoker.

type Option

type Option func(*Invoker) error

Option is the type of options for the invoker.

func AllowReinvoke

func AllowReinvoke(allow bool) Option

AllowReinvoke sets whether the invoker should allow the re-invocation of plans that have already been invoked.

func ObserveCopiesWith

func ObserveCopiesWith(obs ...copier.Observer) Option

ObserveCopiesWith adds each observer given to the invoker's copy observer pool.

func ObserveMachWith

func ObserveMachWith(obs Option

ObserveMachWith adds each observer given to the invoker's machine observer pool.

func Options

func Options(ops ...Option) Option

Options bundles the separate options ops into a single option.

func OverrideBaseQuantities

func OverrideBaseQuantities(qs quantity.MachNodeSet) Option

OverrideBaseQuantities overrides the base quantity set with qs.

func OverrideQuantitiesFromPlanThen

func OverrideQuantitiesFromPlanThen(qs quantity.MachNodeSet) Option

OverrideQuantitiesFromPlanThen tells the invoker to override its base quantity set with the quantities in the incoming plan, and then override them again using qs.

This is intended for single-shot uses of the invoker, where there is no pre-calculation of the quantity set; in the director form of the invoker, the director will cache the expected quantity set, and there is no need to consult the plan.

type PlanQuantityOverrider

type PlanQuantityOverrider interface {
	// OverrideQuantitiesFromPlan applies to qs any quantity overrides that require information from the plan p.
	// This is part of the Factory interface because some, but not all, factories require plan information.
	OverrideQuantitiesFromPlan(p *plan.Plan, qs *quantity.MachNodeSet) error

PlanQuantityOverrider is the interface of things that may, or may not, override the invoker's quantity set with quantities according to information in a plan.


Path Synopsis
Package runner contains low-level code for running the machine node via SSH and locally.
Package runner contains low-level code for running the machine node via SSH and locally.

Jump to

Keyboard shortcuts

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