deployr: Index | Files

package evaluator

import ""

Package evaluator is the core of our run-time.

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


Package Files


type Evaluator Uses

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 Uses

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

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

func (*Evaluator) ConnectTo Uses

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 Uses

func (e *Evaluator) Run() error

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

func (*Evaluator) SetIdentity Uses

func (e *Evaluator) SetIdentity(file string)

SetIdentity specifies the SSH identity file to authenticate with

func (*Evaluator) SetNOP Uses

func (e *Evaluator) SetNOP(verb bool)

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

func (*Evaluator) SetVariable Uses

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

SetVariable sets the content of a read-only variable

func (*Evaluator) SetVerbose Uses

func (e *Evaluator) SetVerbose(verb bool)

SetVerbose specifies whether we should run verbosely or not.

Package evaluator imports 15 packages (graph) and is imported by 1 packages. Updated 2020-03-04. Refresh now. Tools for package owners.