ops

package
v0.0.0-...-df570b3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFunctionNotFound = errors.New("Function with given id not found")
)

errors.

Functions

This section is empty.

Types

type Function

type Function func() Op

Function defines a interface for a function which returns a giving Op.

type Generator

type Generator func([]byte) (Op, error)

Generator defines a interface for a function which returns a giving Op.

type GeneratorRegistry

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

GeneratorRegistry implements a structure that handles registration and ochestration of spells.

func NewGeneratorRegistry

func NewGeneratorRegistry() *GeneratorRegistry

NewGeneratorRegistry returns a new instance of the GeneratorsRegistry.

func (*GeneratorRegistry) CreateFromBytes

func (ng *GeneratorRegistry) CreateFromBytes(id string, config []byte) (Op, error)

CreateFromBytes returns a new spell from the provided configuration

func (*GeneratorRegistry) CreateWithJSON

func (ng *GeneratorRegistry) CreateWithJSON(id string, config interface{}) (Op, error)

CreateWithJSON returns a new spell from the provided configuration map which is first converted into JSON then loaded using the CreateFromBytes function.

func (*GeneratorRegistry) CreateWithTOML

func (ng *GeneratorRegistry) CreateWithTOML(id string, config interface{}) (Op, error)

CreateWithTOML returns a new spell from the provided configuration map which is first converted into JSON then loaded using the CreateFromBytes function.

func (*GeneratorRegistry) MustCreateFromBytes

func (ng *GeneratorRegistry) MustCreateFromBytes(id string, config []byte) Op

MustCreateFromBytes panics if giving function for id is not found.

func (*GeneratorRegistry) Register

func (ng *GeneratorRegistry) Register(id string, fun Generator) bool

Register adds the giving function into the list of available functions for instanction.

func (*GeneratorRegistry) RegisterJSON

func (ng *GeneratorRegistry) RegisterJSON(id string, fun Function) bool

RegisterJSON adds the giving function into the list of available functions for instanction, where it's config would be loaded using json as the config unmarshaller.

func (*GeneratorRegistry) RegisterTOML

func (ng *GeneratorRegistry) RegisterTOML(id string, fun Function) bool

RegisterTOML adds the giving function into the list of available functions for instanction, where it's config would be loaded using toml as the config unmarshaller.

type MultiRunner

type MultiRunner struct {
	Then Op
	Pre  []Op
	Post []Op
}

MultiRunner will run necessary commands to update apt-get for a debian/ubuntu system.

func (MultiRunner) Exec

func (gn MultiRunner) Exec(ctx context.Context, m metrics.Metrics) error

Exec executes giving spells in a before-now-after sequence.

type Op

type Op interface {
	Exec(context.Context, metrics.Metrics) error
}

Op defines an interface which expose an exec method.

Jump to

Keyboard shortcuts

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