internal

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const EnvValuesPath = "VALUES_PATH"
View Source
const EnvValuesPathDefault = "etc/values.yaml"
View Source
const FilterJsonParse = "jsonParse"
View Source
const FilterReplace = "replace"
View Source
const FilterSplit = "split"
View Source
const FilterSplitLines = "splitLines"
View Source
const FilterYamlParse = "yamlParse"
View Source
const OpFile = "file"
View Source
const OpMongo = "mongo"
View Source
const OpNixShell = "nixShellCommand"
View Source
const OpSql = "sql"
View Source
const OpTemplate = "template"
View Source
const OpWait = "wait"
View Source
const VarParams = "Params"
View Source
const VarValues = "Values"

Variables

This section is empty.

Functions

func GetSequencePath

func GetSequencePath(seq string) (string, error)

func GetUsersPath

func GetUsersPath() string

func IsSequenceAllowed added in v0.1.1

func IsSequenceAllowed(seq string) bool

func PrototypeCheck

func PrototypeCheck(config map[string]any, schema string) error

func SetDefault

func SetDefault(config map[string]any, key string, value any) map[string]any

SetDefault checks whether the provided map contain the provided key. If it does not, it will set it with the provided default value

Types

type FileOp added in v0.4.0

type FileOp struct {
	Path     string
	BasePath string
	Raw      bool

	Result any
	// contains filtered or unexported fields
}

func NewFileOp added in v0.4.0

func NewFileOp(config map[string]any, scope *Scope) (*FileOp, error)

func (*FileOp) GetResult added in v0.4.0

func (o *FileOp) GetResult() any

func (*FileOp) Run added in v0.4.0

func (o *FileOp) Run(ctx context.Context) error

type Filter

type Filter struct {
	Type   string         `yaml:"type"`
	Config map[string]any `yaml:"config"`
}

Filter is the wrapping structure of all filters

func (*Filter) GetImplementation

func (f *Filter) GetImplementation() (IFilter, error)

GetImplementation will return the IFilter proper implementation

func (*Filter) Run

func (f *Filter) Run(ctx context.Context, input any) (any, error)

Run runs the filter

type IFilter

type IFilter interface {
	Run(ctx context.Context, input any) (any, error)
}

IFilter is the prototype of all filters

type IOperation

type IOperation interface {
	Run(ctx context.Context) error
	GetResult() any
}

IOperation is the interface for operations

type JsonParseFilter

type JsonParseFilter struct{}

JsonParseFilter is a filter that transforms text to a JSON structure

func NewJsonParseFilter

func NewJsonParseFilter() *JsonParseFilter

NewJsonParseFilter is the constructor for JsonParseFilter

func (*JsonParseFilter) Run

func (f *JsonParseFilter) Run(_ context.Context, input any) (any, error)

Run will run the filter, transforming the input and returning the transformed data

type MongoOp

type MongoOp struct {
	URI        string
	Find       map[string]any
	DB         string
	Collection string
	Timeout    time.Duration

	Result any
	// contains filtered or unexported fields
}

MongoOp is the MongoDB database

func NewMongoOp

func NewMongoOp(config map[string]any, scope *Scope) (*MongoOp, error)

NewMongoOp is the constructor for MongoOp

func (*MongoOp) GetResult

func (o *MongoOp) GetResult() any

GetResult returns a result

func (*MongoOp) Run

func (o *MongoOp) Run(ctx context.Context) error

Run will run the MongoDB query

type NixShellOp

type NixShellOp struct {
	Command string
	Stdin   bool
	Result  string
	Timeout time.Duration
	// contains filtered or unexported fields
}

NixShellOp is an operation that runs a *NIX command

func NewNixShellIOp

func NewNixShellIOp(config map[string]any, scope *Scope) (*NixShellOp, error)

NewNixShellIOp constructor for NixShellOp

func (*NixShellOp) GetResult

func (o *NixShellOp) GetResult() any

GetResult returns the result of the operation

func (*NixShellOp) Run

func (o *NixShellOp) Run(ctx context.Context) error

Run runs the operation

type ProcessResult

type ProcessResult struct {
	Description string            `json:"description"`
	Results     []StepResult      `json:"results"`
	Errors      map[string]string `json:"errors"`
}

ProcessResult is the final result of a sequence execution

func (*ProcessResult) ToJSON

func (r *ProcessResult) ToJSON() []byte

ToJSON will turn the Result data structure into a JSON string

type Proto

type Proto map[string]string

type RegexpReplaceFilter

type RegexpReplaceFilter struct {
	Regexp  *regexp.Regexp
	Replace string
}

RegexpReplaceFilter is a filter that will take an input and replace any matching pattern described by Regexp with the value of Replace

func NewRegexpReplaceFilter

func NewRegexpReplaceFilter(config map[string]any) (*RegexpReplaceFilter, error)

NewRegexpReplaceFilter is the constructor for RegexpReplaceFilter

func (*RegexpReplaceFilter) Run

func (f *RegexpReplaceFilter) Run(_ context.Context, input any) (any, error)

Run will run the filter, transforming the input and returning the transformed data

type Scope

type Scope struct {
	Scope   map[string]any
	Env     []string
	Results []StepResult
	Errors  map[string]string
}

Scope is the variable Scope of the sequence

func NewScope

func NewScope() Scope

NewScope is the constructor for Scope

func (*Scope) InsertParams

func (s *Scope) InsertParams(data map[string]any)

InsertParams inserts the params expressed as JSON into the Scope

func (*Scope) LoadEnvs

func (s *Scope) LoadEnvs(envs []string)

LoadEnvs loads the listed environment variables in the Scope

func (*Scope) PushResult

func (s *Scope) PushResult(name string, value any, hide bool)

PushResult will store the result into the Scope and in the "Results" structure

func (*Scope) Render

func (s *Scope) Render(ctx context.Context, data string) (string, error)

Render renders a string template, against the Scope

func (*Scope) RenderMap

func (s *Scope) RenderMap(ctx context.Context, config map[string]any) (map[string]any, error)

RenderMap will recursively traverse a map and try to render all strings it finds

func (*Scope) ToJSON

func (s *Scope) ToJSON() string

ToJSON marshals the Scope to JSON

func (*Scope) ToProcessResult

func (s *Scope) ToProcessResult() ProcessResult

ToProcessResult converts the internal representation of results, to a publishable version

type Sequence

type Sequence struct {
	Env          []string `yaml:"env"`
	Description  string   `yaml:"description"`
	Steps        []*Step  `yaml:"steps"`
	AcceptParams bool     `yaml:"accept_params"`
	Requires     any      `yaml:"requires"`
	Scope        *Scope
}

Sequence is a sequence of operations

func LoadSequence

func LoadSequence(filePath string) (Sequence, error)

LoadSequence loads a sequence from a file path

func (*Sequence) CheckRequires

func (s *Sequence) CheckRequires(data map[string]any) error

CheckRequires will check that the provided map has at least the fields described in the "Requires" list

func (*Sequence) Result

func (s *Sequence) Result() ProcessResult

Result will return publishable results for the sequence

func (*Sequence) Run

func (s *Sequence) Run(ctx context.Context)

Run will run the sequence

type SplitFilter

type SplitFilter struct {
	Sep string
}

SplitFilter splits a string into an array based on a separation character. If the input is an array, the output will be an array of arrays

func NewSplitFilter

func NewSplitFilter(config map[string]any) (*SplitFilter, error)

NewSplitFilter is the constructor for SplitFilter

func (*SplitFilter) Run

func (f *SplitFilter) Run(_ context.Context, input any) (any, error)

Run will run the filter, transforming the input and returning the transformed data

type SplitLinesFilter

type SplitLinesFilter struct{}

SplitLinesFilter takes the input as string and splits the lines, returning an array

func NewSplitLinesFilter

func NewSplitLinesFilter() *SplitLinesFilter

NewSplitLinesFilter is the constructor for SplitLinesFilter

func (*SplitLinesFilter) Run

func (f *SplitLinesFilter) Run(_ context.Context, input any) (any, error)

Run will run the SplitLinesFilter

type SqlOp

type SqlOp struct {
	Driver  string
	URI     string
	Select  string
	Timeout time.Duration
	Result  []map[string]any
	// contains filtered or unexported fields
}

SqlOp is the operation that runs SQL queries

func NewSqlOp

func NewSqlOp(config map[string]any, scope *Scope) (*SqlOp, error)

NewSqlOp constructor for SqlOp

func (*SqlOp) GetResult

func (o *SqlOp) GetResult() any

GetResult will return the result of the query

func (*SqlOp) Run

func (o *SqlOp) Run(ctx context.Context) error

Run runs the query

type Step

type Step struct {
	Name   string         `yaml:"name"`
	Type   string         `yaml:"type"`
	Config map[string]any `yaml:"config"`

	Filters []Filter `yaml:"filters"`
	Hide    bool     `yaml:"hide"`
	// contains filtered or unexported fields
}

Step is one step in a sequence

func (*Step) GetImplementation

func (s *Step) GetImplementation() (IOperation, error)

GetImplementation will return the proper IOperation implementation for the current step

func (*Step) Run

func (s *Step) Run(ctx context.Context) (any, error)

Run will run the step

type StepResult

type StepResult struct {
	Name  string `json:"name"`
	Value any    `json:"value"`
}

StepResult is the outcome of one step

type TemplateOp

type TemplateOp struct {
	Template string
	Result   string
	// contains filtered or unexported fields
}

TemplateOp is an operation that evaluates a template

func NewTemplateOp

func NewTemplateOp(config map[string]any, scope *Scope) (*TemplateOp, error)

NewTemplateOp is the constructor for TemplateOp

func (*TemplateOp) GetResult

func (o *TemplateOp) GetResult() any

GetResult returns the result

func (*TemplateOp) Run

func (o *TemplateOp) Run(ctx context.Context) error

Run runs the template

type WaitOp

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

WaitOp is an operation that pauses the sequence for a certain amount of time

func NewWaitOp

func NewWaitOp(config map[string]any) (*WaitOp, error)

NewWaitOp is the constructor for WaitOp

func (*WaitOp) GetResult

func (o *WaitOp) GetResult() any

GetResult will return the result, that's nothing more than an informative string

func (*WaitOp) Run

func (o *WaitOp) Run(_ context.Context) error

Run will run the wait command

type YamlParseFilter added in v0.4.0

type YamlParseFilter struct{}

YamlParseFilter is a filter that transforms text to a YAML structure

func NewYamlParseFilter added in v0.4.0

func NewYamlParseFilter() *YamlParseFilter

NewYamlParseFilter is the constructor for YamlParseFilter

func (*YamlParseFilter) Run added in v0.4.0

func (f *YamlParseFilter) Run(_ context.Context, input any) (any, error)

Run will run the filter, transforming the input and returning the transformed data

Jump to

Keyboard shortcuts

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