operator

package
v0.0.0-...-b94449b Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package operator is an interface for defining arbitrary operators, which gather state and make changes to an environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadState

func ReadState(data *InfoData, stateDir string) (state.State, error)

func SaveState

func SaveState(data *InfoData, st state.State, stateDir string) error

Types

type ChangeDetector

type ChangeDetector interface {
	Changed(a, b state.State) (bool, error)
}

ChangeDetector allows an operator to override the conditions under which a state has changed.

type Command

type Command struct {
	*cobra.Command
	ApplyArgs CommandArgFunc
	Target    interface{}
}

type CommandArgFunc

type CommandArgFunc func(cmd *cobra.Command, args []string, target interface{}) error

type Context

type Context struct {
	context.Context

	Opts      interface{}
	FS        FS
	PlanDir   opfs.PlanDir
	Templates *templates.Templates
}

func NewContext

func NewContext(ctx context.Context, fs FS, planDir opfs.PlanDir, tmpl *templates.Templates) Context

func (Context) GotState

func (c Context) GotState() bool

func (Context) Value

func (c Context) Value(key interface{}) interface{}

func (Context) WithGotState

func (c Context) WithGotState(gotState bool) Context

func (Context) WithSubplan

func (c Context) WithSubplan(spdir string) Context

func (Context) WithValue

func (c Context) WithValue(key, val interface{}) Context

type DesiredStater

type DesiredStater interface {
	DesiredState(octx Context) (state.State, error)
}

DesiredStater can be implemented by operators to make it possible to skip operator.Run, mark the state unchanged, and still write the resulting state. When this is implemented, the planner will run it before executing the operator, and if the requested state (as determined by DesiredState()) matches the current state, plan application will continue as if the operator was executed.

type FS

type FS interface {
	fs.StatFS
	fs.GlobFS
	fs.ReadDirFS
	fs.ReadFileFS
	Join(paths ...string) string
}

type Info

type Info interface {
	Name() string
	Data() *InfoData
	TextSummary(w io.Writer) error
}

type InfoData

type InfoData struct {
	OpName  string   `json:"name"`
	Command *Command `json:"command"`
}

func (*InfoData) Copy

func (id *InfoData) Copy() *InfoData

func (*InfoData) Data

func (id *InfoData) Data() *InfoData

func (*InfoData) Encode

func (id *InfoData) Encode(w io.Writer) error

func (*InfoData) Name

func (id *InfoData) Name() string

func (*InfoData) TextSummary

func (id *InfoData) TextSummary(w io.Writer) error

type Interface

type Interface interface {
	Info() Info
	GetState(octx Context) (state.State, error)
	Run(octx Context) error
}

type Noop

type Noop struct{}

func (Noop) GetState

func (op Noop) GetState(octx Context) (state.State, error)

func (Noop) Info

func (op Noop) Info() Info

func (Noop) Run

func (op Noop) Run(octx Context) error

type PlanEntry

type PlanEntry struct {
	Name string          `json:"name"`
	Args json.RawMessage `json:"args,omitempty"`
}

type Validator

type Validator interface {
	Validate(octx Context, targ interface{}, evaluated bool) error
}

Validator can be implemented by operators to validate arguments before execution. If implemented, Validate can be run multiple times. If evaluated is false, the arguments shell script variables are not expanded -- ie if the argument in the shell script is "$mydir/myfile", that is what the command target args will be on the operation. If true, the arguments shell operators are expanded.

Directories

Path Synopsis
Package facts manages "facts", which are data gathered from the environment of the agent.
Package facts manages "facts", which are data gathered from the environment of the agent.
Package fileop contains filesystem-related operators.
Package fileop contains filesystem-related operators.
Package gitop contains operators that use git.
Package gitop contains operators that use git.
Package opfs is an fs implementation that supports stat, reads, and globbing.
Package opfs is an fs implementation that supports stat, reads, and globbing.
Package pkgop contains operators for using package managers.
Package pkgop contains operators for using package managers.
Package planop contains a dependency operator and other operations on plans.
Package planop contains a dependency operator and other operations on plans.
Package shellop contains shell operators.
Package shellop contains shell operators.
Package templateop contains template operations.
Package templateop contains template operations.
Package templates contains a template manager.
Package templates contains a template manager.
Package userop contains user operators.
Package userop contains user operators.

Jump to

Keyboard shortcuts

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