config

package
v0.0.0-...-ecdd562 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package config holds our basic translation from a TOML configuration file to a usable struct.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Required are required values that must be passed in.
	Required []Required
	// CreateVars are a list of variables to create. This operation is done before any
	// sequence has run, but it does allow use of variables stored in the vals map.
	CreateVars []*CreateVar

	Seqs []toml.Primitive
	// contains filtered or unexported fields
}

Config holds our configuration from the configuration file.

func FromFile

func FromFile(fsys gfs.Writer, p string, vals map[string]string) (*Config, error)

FromFile returns a Config from a file "p" in filesystem "fsys". This validates all the runners are correct, that all nodes referenced are present and validates that we have a valid DAG.

func (*Config) Root

func (c *Config) Root() *Sequence

Root returns the root node.

func (*Config) Sequences

func (c *Config) Sequences() []*Sequence

type CreateVar

type CreateVar struct {
	// Name is the unique name of the CreateVar sequence.
	Name string
	// Key is the to save the variable in.
	Key string
	// Value is the value to save. This can contain template variables that reference keys
	// stored in our val map.
	Value string
}

CreateVar creates a variable.

func (*CreateVar) Exec

func (c *CreateVar) Exec(fsys fs.FS, vals map[string]string) error

func (*CreateVar) Sequence

func (c *CreateVar) Sequence() string

type Required

type Required struct {
	// Name is the name of the value that must be passed.
	Name string
	// Regex is the regexp.Regexp that must match for the value to be valid.
	// If not set, the value is not checked.
	Regex string
}

Required is a required value that must be passed in before anything is executed.

type Runner

type Runner struct {
	// Name is the name of this Runner. (Required)
	Name string
	// Cmd is the command to execute. You may use {{.KeyName}} for value substitution that comes from the passed
	// map. All "\n" and "\" characters are turned into spaces before parsing. (Required)
	Cmd string
	// Sleep indicates the amount of time to sleep before executing this command.
	Sleep duration
	// Retries is the number of retries to attempt if this fails. Failure is marked with any non-0 return code.
	Retries int
	// RetrySleep is the time to sleep between retries.
	RetrySleep duration
	// ValueKey is the unique key to store the STDOUT of this command in. This value will have TrimSpace() called on it
	// before it is stored.
	ValueKey string
}

Runner represents a runner node in the DAG.

func (*Runner) Sequence

func (r *Runner) Sequence() string

type Sequence

type Sequence struct {
	// contains filtered or unexported fields
}

Sequence represents a sequenced action to perform. This is either a CreateVar, Runner or WriteFile.

func (*Sequence) Item

func (s *Sequence) Item() interface{}

type WriteFile

type WriteFile struct {
	// Name is the unique name of the CreateVar sequence.
	Name string
	// Path is where to store the file.
	Path string
	// Value is the value to write to the file. This can contain template variables that reference keys
	// stored in our val map.
	Value string
}

WriteFile writes a file to disk.

func (*WriteFile) Exec

func (w *WriteFile) Exec(wr gfs.Writer, vals map[string]string) error

func (*WriteFile) Sequence

func (w *WriteFile) Sequence() string

Jump to

Keyboard shortcuts

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