triggers

package
v0.5.4-0...-121c8a9 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bin

type Bin struct {
	Task    string   `toml:"task"`
	Bin     string   `toml:"bin"`
	Args    []string `toml:"args"`
	Replace *Replace `toml:"replace"`
}

Bin contains the details of the binary to be executed.

func (*Bin) Execute

func (b *Bin) Execute(s Scope, env map[string]string) Output

Execute the binary from the confuration

func (Bin) FanOut

func (b Bin) FanOut() (nbins []Bin, outputs []Output)

FanOut generates one or more bin tasks from a given, as needed by replacing the "***" sequence in the arguments and creating separate binaries to be executed.

type Check

type Check struct {
	Paths []string `toml:"paths"`
}

Check contains paths that must exixt to execute the configuration. This supports globbing.

type Deps

type Deps struct {
	After []string `toml:"after"`
}

Deps contains a description of the dependencies between triggers

type Map

type Map map[string]Trigger

Map relates the name of trigger to its definition

func (Map) Graph

func (tm Map) Graph(chroot, live bool) (g deps.Graph)

Graph generates a dependency graph

func (Map) Merge

func (tm Map) Merge(tm2 Map)

Merge combines two Maps by copying from right to left

func (Map) Print

func (tm Map) Print(chroot, live bool)

Print renders a Map in a human-readable format

func (Map) Run

func (tm Map) Run(s Scope, names []string)

Run executes a list of triggers, where available

type Output

type Output struct {
	Name    string
	SubTask string
	Message string
	Status  Status
}

Output contains the details necessary to output the configuration details to the user.

type Remove

type Remove struct {
	Paths   []string `toml:"paths"`
	Exclude []string `toml:"exclude"`
}

Remove contains paths to be removed from the system. This supports globbing.

type Replace

type Replace struct {
	Paths   []string `toml:"paths"`
	Exclude []string `toml:"exclude"`
}

Replace contains details to replace a single argument with a path in the executed binary. This supports globbing.

type Scope

type Scope struct {
	Chroot bool
	Debug  bool
	DryRun bool
	Forced bool
	Live   bool
}

Scope sets limits of execution for a trigger

type Skip

type Skip struct {
	Chroot bool     `toml:"chroot,omitempty"`
	Live   bool     `toml:"live,omitempty"`
	Paths  []string `toml:"paths"`
}

Skip contains details for when the configuration will not be executed, due to existing paths, or possible flags passed. This supports globbing.

type Status

type Status int

Status indicates the state of the configuration.

const (
	// Skipped - The configuration will not be executed.
	Skipped Status = iota
	// Success - The configuration has been executed, without error.
	Success
	// Failure - The configuration was not be executed, due to error.
	Failure
)

type Trigger

type Trigger struct {
	Name   string
	Path   string
	Output []Output

	Description string            `toml:"description"`
	Check       *Check            `toml:"check,omitempty"`
	Skip        *Skip             `toml:"skip,omitempty"`
	Deps        *Deps             `toml:"deps,omitempty"`
	Env         map[string]string `toml:"env,omitempty"`
	Bins        []Bin             `toml:"bins,omitempty"`
	Removals    []Remove          `toml:"remove,omitempty"`
}

Trigger contains all the information for a configuration to be executed and output to the user.

func (*Trigger) CheckMatch

func (t *Trigger) CheckMatch() (m state.Map, ok bool)

CheckMatch will glob the paths and if the path does not exist in the system, an error is returned

func (*Trigger) ExecuteBins

func (t *Trigger) ExecuteBins(s Scope)

ExecuteBins generates and runs all of the necesarry Bin commands

func (*Trigger) Finish

func (t *Trigger) Finish(s Scope)

Finish is the last function to be executed by any trigger to output details to the user.

func (*Trigger) Load

func (t *Trigger) Load(path string) error

Load reads a Trigger configuration from a file and parses it

func (*Trigger) Remove

func (t *Trigger) Remove(s Scope) bool

Remove glob the paths and if it exists it will remove it from the system

func (*Trigger) Run

func (t *Trigger) Run(s Scope, prev, next state.Map) (ok bool)

Run will process a single configuration and scope.

func (*Trigger) ShouldSkip

func (t *Trigger) ShouldSkip(s Scope, check, diff state.Map) bool

ShouldSkip will process the skip and check elements of the configuration and see if it should not be executed.

func (*Trigger) Validate

func (t *Trigger) Validate() error

Validate checks for errors in a Trigger configuration

Jump to

Keyboard shortcuts

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