evaluator

package
v0.0.0-...-1e7c8b3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package evaluator is the core of our run-time.

Given a parsed series of statements we execute each of them in turn.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Evaluator

type Evaluator struct {

	// Program is our parsed program, which is an array of statements.
	Program []statement.Statement

	// Identity holds the SSH key to authenticate with
	Identity string

	// Verbose is true if the execution should be verbose.
	Verbose bool

	// NOP records if we should pretend to work, or work for real.
	NOP bool

	// Variables is a map which holds the names/values of all defined
	// variables.  (Being declared/set/updated via the 'Set' primitive.)
	Variables map[string]string

	// ROVariables is a map which is similar to Variables, but only
	// contains values set on the command-line.  Variables are looked
	// for here first.
	ROVariables map[string]string

	// Connection holds the SSH-connection to the remote-host.
	Connection *simplessh.Client

	// Changed records whether the last copy operaton resulted in a change.
	Changed bool
}

Evaluator holds our internal state.

func New

func New(program []statement.Statement) *Evaluator

New creates our evaluator object, which will execute the supplied statements.

func (*Evaluator) ConnectTo

func (e *Evaluator) ConnectTo(target string) error

ConnectTo opens the SSH connection to the specified target-host.

If a connection is already open then it is maintained, and not replaced. This allows the command-line to override the destination which might be baked into a configuration-recipe.

func (*Evaluator) Run

func (e *Evaluator) Run() error

Run evaluates our program, continuing until all statements have been executed - unless an error was encountered.

func (*Evaluator) SetIdentity

func (e *Evaluator) SetIdentity(file string)

SetIdentity specifies the SSH identity file to authenticate with

func (*Evaluator) SetNOP

func (e *Evaluator) SetNOP(verb bool)

SetNOP specifies whether we should run for real, or not at all.

func (*Evaluator) SetVariable

func (e *Evaluator) SetVariable(key string, val string)

SetVariable sets the content of a read-only variable

func (*Evaluator) SetVerbose

func (e *Evaluator) SetVerbose(verb bool)

SetVerbose specifies whether we should run verbosely or not.

Jump to

Keyboard shortcuts

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