Documentation
¶
Overview ¶
Package resources provides the resource framework and idempotent primitives.
Index ¶
- Variables
- func ResToB64(res Res) (string, error)
- func ReturnSvcInFileList(fileList []string) []string
- func TypeCmp(a, b reflect.Value) error
- func UIDExistsInUIDs(uid ResUID, uids []ResUID) bool
- type AutoEdge
- type Base
- type BaseRes
- func (obj *BaseRes) AssociateData(data *Data)
- func (obj *BaseRes) Close() error
- func (obj *BaseRes) CollectPattern(pattern string)
- func (obj *BaseRes) Compare(res Res) bool
- func (obj *BaseRes) Converger() converger.Converger
- func (obj *BaseRes) ConvergerUID() converger.ConvergerUID
- func (obj *BaseRes) Event(processChan chan *event.Event) error
- func (obj *BaseRes) Events() chan *event.Event
- func (obj *BaseRes) GetGroup() []Res
- func (obj *BaseRes) GetName() string
- func (obj *BaseRes) GetState() ResState
- func (obj *BaseRes) GroupCmp(res Res) bool
- func (obj *BaseRes) GroupRes(res Res) error
- func (obj *BaseRes) Init() error
- func (obj *BaseRes) IsGrouped() bool
- func (obj *BaseRes) IsStateOK() bool
- func (obj *BaseRes) IsWorking() bool
- func (obj *BaseRes) Kind() string
- func (obj *BaseRes) Meta() *MetaParams
- func (obj *BaseRes) Poll(processChan chan *event.Event) error
- func (obj *BaseRes) ReadEvent(ev *event.Event) (exit *error, send bool)
- func (obj *BaseRes) Refresh() bool
- func (obj *BaseRes) RegisterConverger()
- func (obj *BaseRes) Running(processChan chan *event.Event) error
- func (obj *BaseRes) SendEvent(ev event.EventName, err error) error
- func (obj *BaseRes) SendRecv(res Res) (map[string]bool, error)
- func (obj *BaseRes) SetGroup(g []Res)
- func (obj *BaseRes) SetGrouped(b bool)
- func (obj *BaseRes) SetKind(kind string)
- func (obj *BaseRes) SetName(name string)
- func (obj *BaseRes) SetRefresh(b bool)
- func (obj *BaseRes) SetState(state ResState)
- func (obj *BaseRes) SetWorking(b bool)
- func (obj *BaseRes) Started() <-chan struct{}
- func (obj *BaseRes) Starter(b bool)
- func (obj *BaseRes) StateOK(b bool)
- func (obj *BaseRes) UnregisterConverger()
- func (obj *BaseRes) Validate() error
- func (obj *BaseRes) VarDir(extra string) (string, error)
- type BaseUID
- type Data
- type DiskBool
- type ExecRes
- func (obj *ExecRes) AutoEdges() AutoEdge
- func (obj *ExecRes) BufioChanScanner(scanner *bufio.Scanner) (chan string, chan error)
- func (obj *ExecRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *ExecRes) Compare(res Res) bool
- func (obj *ExecRes) Default() Res
- func (obj *ExecRes) GroupCmp(r Res) bool
- func (obj *ExecRes) Init() error
- func (obj *ExecRes) UIDs() []ResUID
- func (obj *ExecRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *ExecRes) Validate() error
- func (obj *ExecRes) Watch(processChan chan *event.Event) error
- type ExecUID
- type FileInfo
- type FileRes
- func (obj *FileRes) AutoEdges() AutoEdge
- func (obj *FileRes) CheckApply(apply bool) (checkOK bool, _ error)
- func (obj *FileRes) CollectPattern(pattern string)
- func (obj *FileRes) Compare(res Res) bool
- func (obj *FileRes) Default() Res
- func (obj *FileRes) GetPath() string
- func (obj *FileRes) GroupCmp(r Res) bool
- func (obj *FileRes) Init() error
- func (obj *FileRes) UIDs() []ResUID
- func (obj *FileRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *FileRes) Validate() error
- func (obj *FileRes) Watch(processChan chan *event.Event) error
- type FileResAutoEdges
- type FileUID
- type HostnameRes
- func (obj *HostnameRes) AutoEdges() AutoEdge
- func (obj *HostnameRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *HostnameRes) Compare(res Res) bool
- func (obj *HostnameRes) Default() Res
- func (obj *HostnameRes) GroupCmp(r Res) bool
- func (obj *HostnameRes) Init() error
- func (obj *HostnameRes) UIDs() []ResUID
- func (obj *HostnameRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *HostnameRes) Validate() error
- func (obj *HostnameRes) Watch(processChan chan *event.Event) error
- type HostnameUID
- type MetaParams
- type MsgRes
- func (obj *MsgRes) AutoEdges() AutoEdge
- func (obj *MsgRes) CheckApply(apply bool) (bool, error)
- func (obj *MsgRes) Compare(res Res) bool
- func (obj *MsgRes) Default() Res
- func (obj *MsgRes) Init() error
- func (obj *MsgRes) UIDs() []ResUID
- func (obj *MsgRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *MsgRes) Validate() error
- func (obj *MsgRes) Watch(processChan chan *event.Event) error
- type MsgUID
- type NoopRes
- func (obj *NoopRes) AutoEdges() AutoEdge
- func (obj *NoopRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *NoopRes) Compare(res Res) bool
- func (obj *NoopRes) Default() Res
- func (obj *NoopRes) GroupCmp(r Res) bool
- func (obj *NoopRes) Init() error
- func (obj *NoopRes) UIDs() []ResUID
- func (obj *NoopRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *NoopRes) Validate() error
- func (obj *NoopRes) Watch(processChan chan *event.Event) error
- type NoopUID
- type NspawnRes
- func (obj *NspawnRes) AutoEdges() AutoEdge
- func (obj *NspawnRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *NspawnRes) Compare(res Res) bool
- func (obj *NspawnRes) Default() Res
- func (obj *NspawnRes) GroupCmp(r Res) bool
- func (obj *NspawnRes) Init() error
- func (obj *NspawnRes) UIDs() []ResUID
- func (obj *NspawnRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *NspawnRes) Validate() error
- func (obj *NspawnRes) Watch(processChan chan *event.Event) error
- type NspawnUID
- type PasswordRes
- func (obj *PasswordRes) AutoEdges() AutoEdge
- func (obj *PasswordRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *PasswordRes) Compare(res Res) bool
- func (obj *PasswordRes) Default() Res
- func (obj *PasswordRes) GroupCmp(r Res) bool
- func (obj *PasswordRes) Init() error
- func (obj *PasswordRes) UIDs() []ResUID
- func (obj *PasswordRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *PasswordRes) Validate() error
- func (obj *PasswordRes) Watch(processChan chan *event.Event) error
- type PasswordUID
- type PkgRes
- func (obj *PkgRes) AutoEdges() AutoEdge
- func (obj *PkgRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *PkgRes) Compare(res Res) bool
- func (obj *PkgRes) Default() Res
- func (obj *PkgRes) GroupCmp(r Res) bool
- func (obj *PkgRes) Init() error
- func (obj *PkgRes) UIDs() []ResUID
- func (obj *PkgRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *PkgRes) Validate() error
- func (obj *PkgRes) Watch(processChan chan *event.Event) error
- type PkgResAutoEdges
- type PkgUID
- type Res
- type ResState
- type ResUID
- type Send
- type StatefulBool
- type SvcRes
- func (obj *SvcRes) AutoEdges() AutoEdge
- func (obj *SvcRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *SvcRes) Compare(res Res) bool
- func (obj *SvcRes) Default() Res
- func (obj *SvcRes) GroupCmp(r Res) bool
- func (obj *SvcRes) Init() error
- func (obj *SvcRes) UIDs() []ResUID
- func (obj *SvcRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *SvcRes) Validate() error
- func (obj *SvcRes) Watch(processChan chan *event.Event) error
- type SvcResAutoEdges
- type SvcUID
- type TimerRes
- func (obj *TimerRes) AutoEdges() AutoEdge
- func (obj *TimerRes) CheckApply(apply bool) (bool, error)
- func (obj *TimerRes) Compare(res Res) bool
- func (obj *TimerRes) Default() Res
- func (obj *TimerRes) Init() error
- func (obj *TimerRes) UIDs() []ResUID
- func (obj *TimerRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *TimerRes) Validate() error
- func (obj *TimerRes) Watch(processChan chan *event.Event) error
- type TimerUID
- type VirtAuth
- type VirtRes
- func (obj *VirtRes) AutoEdges() AutoEdge
- func (obj *VirtRes) CheckApply(apply bool) (bool, error)
- func (obj *VirtRes) CollectPattern(string)
- func (obj *VirtRes) Compare(res Res) bool
- func (obj *VirtRes) Default() Res
- func (obj *VirtRes) GroupCmp(r Res) bool
- func (obj *VirtRes) Init() error
- func (obj *VirtRes) UIDs() []ResUID
- func (obj *VirtRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *VirtRes) Validate() error
- func (obj *VirtRes) Watch(processChan chan *event.Event) error
- type VirtUID
Constants ¶
This section is empty.
Variables ¶
var DefaultMetaParams = MetaParams{ AutoEdge: true, AutoGroup: true, Noop: false, Retry: 0, Delay: 0, Poll: 0, Limit: rate.Inf, Burst: 0, }
DefaultMetaParams are the defaults to be used for undefined metaparams.
var ErrResourceInsufficientParameters = errors.New(
"Insufficient parameters for this resource")
ErrResourceInsufficientParameters is returned when the configuration of the resource is insufficient for the resource to do any useful work.
Functions ¶
func ReturnSvcInFileList ¶
ReturnSvcInFileList returns a list of svc names for matches like: `/usr/lib/systemd/system/*.service`.
func TypeCmp ¶
TypeCmp compares two reflect values to see if they are the same Kind. It can look into a ptr Kind to see if the underlying pair of ptr's can TypeCmp too!
func UIDExistsInUIDs ¶
UIDExistsInUIDs wraps the IFF method when used with a list of UID's.
Types ¶
type AutoEdge ¶
type AutoEdge interface { Next() []ResUID // call to get list of edges to add Test([]bool) bool // call until false }
The AutoEdge interface is used to implement the autoedges feature.
type Base ¶
type Base interface { GetName() string // can't be named "Name()" because of struct field SetName(string) SetKind(string) Kind() string Meta() *MetaParams Events() chan *event.Event AssociateData(*Data) IsWorking() bool SetWorking(bool) Converger() converger.Converger RegisterConverger() UnregisterConverger() ConvergerUID() converger.ConvergerUID GetState() ResState SetState(ResState) Event(chan *event.Event) error SendEvent(event.EventName, error) error ReadEvent(*event.Event) (*error, bool) Refresh() bool // is there a pending refresh to run? SetRefresh(bool) // set the refresh state of this resource SendRecv(Res) (map[string]bool, error) // send->recv data passing function IsStateOK() bool StateOK(b bool) GroupCmp(Res) bool // TODO: is there a better name for this? GroupRes(Res) error // group resource (arg) into self IsGrouped() bool // am I grouped? SetGrouped(bool) // set grouped bool GetGroup() []Res // return everyone grouped inside me SetGroup([]Res) VarDir(string) (string, error) Running(chan *event.Event) error // notify the engine that Watch started Started() <-chan struct{} // returns when the resource has started Starter(bool) Poll(chan *event.Event) error // poll alternative to watching :( }
The Base interface is everything that is common to all resources. Everything here only needs to be implemented once, in the BaseRes.
type BaseRes ¶
type BaseRes struct { Name string `yaml:"name"` MetaParams MetaParams `yaml:"meta"` // struct of all the metaparams Recv map[string]*Send // mapping of key to receive on from value // contains filtered or unexported fields }
BaseRes is the base struct that gets used in every resource.
func (*BaseRes) AssociateData ¶
AssociateData associates some data with the object in question.
func (*BaseRes) CollectPattern ¶
CollectPattern is used for resource collection.
func (*BaseRes) Compare ¶
Compare is the base compare method, which also handles the metaparams cmp.
func (*BaseRes) Converger ¶
Converger returns the converger object used by the system. It can be used to register new convergers if needed.
func (*BaseRes) ConvergerUID ¶
func (obj *BaseRes) ConvergerUID() converger.ConvergerUID
ConvergerUID returns the ConvergerUID for the resource. This should be called by the Watch method of the resource to set the converged state.
func (*BaseRes) GroupCmp ¶
GroupCmp compares two resources and decides if they're suitable for grouping You'll probably want to override this method when implementing a resource...
func (*BaseRes) Init ¶
Init initializes structures like channels if created without New constructor.
func (*BaseRes) Meta ¶
func (obj *BaseRes) Meta() *MetaParams
Meta returns the MetaParams as a reference, which we can then get/set on.
func (*BaseRes) Poll ¶
Poll is the watch replacement for when we want to poll, which outputs events.
func (*BaseRes) ReadEvent ¶
ReadEvent processes events when a select gets one, and handles the pause code too! The return values specify if we should exit and poke respectively.
func (*BaseRes) Refresh ¶
Refresh returns the pending state of a notification. It should only be called in the CheckApply portion of a resource where a refresh should be acted upon.
func (*BaseRes) RegisterConverger ¶
func (obj *BaseRes) RegisterConverger()
RegisterConverger sets up the cuid for the resource. This is a helper function for the engine, and shouldn't be called by the resources directly.
func (*BaseRes) Running ¶
Running is called by the Watch method of the resource once it has started up. This signals to the engine to kick off the initial CheckApply resource check.
func (*BaseRes) SendEvent ¶
SendEvent pushes an event into the message queue for a particular vertex.
func (*BaseRes) SendRecv ¶
SendRecv pulls in the sent values into the receive slots. It is called by the receiver and must be given as input the full resource struct to receive on.
func (*BaseRes) SetGrouped ¶
SetGrouped sets a flag to tell if we are grouped.
func (*BaseRes) SetRefresh ¶
SetRefresh sets the pending state of a notification. It should only be called by the mgmt engine.
func (*BaseRes) SetWorking ¶
SetWorking tracks the state of if Worker() function is running.
func (*BaseRes) Started ¶
func (obj *BaseRes) Started() <-chan struct{}
Started returns a channel that closes when the resource has started up.
func (*BaseRes) Starter ¶
Starter sets the starter bool. This defines if a vertex has an indegree of 0. If we have an indegree of 0, we'll need to be a poke initiator in the graph.
func (*BaseRes) UnregisterConverger ¶
func (obj *BaseRes) UnregisterConverger()
UnregisterConverger tears down the cuid for the resource. This is a helper function for the engine, and shouldn't be called by the resources directly.
type BaseUID ¶
type BaseUID struct {
// contains filtered or unexported fields
}
The BaseUID struct is used to provide a unique resource identifier.
type Data ¶
type Data struct { //Hostname string // uuid for the host //Noop bool Converger converger.Converger Prefix string // the prefix to be used for the pgraph namespace Debug bool }
Data is the set of input values passed into the pgraph for the resources.
type DiskBool ¶
type DiskBool struct {
Path string // path to token
}
DiskBool stores a boolean variable on disk for stateful access across runs. The absence of the path is treated as false. If the path contains a special value, then it is treated as true. All the other non-error cases are false.
type ExecRes ¶
type ExecRes struct { BaseRes `yaml:",inline"` State string `yaml:"state"` // state: exists/present?, absent, (undefined?) Cmd string `yaml:"cmd"` // the command to run Shell string `yaml:"shell"` // the (optional) shell to use to run the cmd Timeout int `yaml:"timeout"` // the cmd timeout in seconds WatchCmd string `yaml:"watchcmd"` // the watch command to run WatchShell string `yaml:"watchshell"` // the (optional) shell to use to run the watch cmd IfCmd string `yaml:"ifcmd"` // the if command to run IfShell string `yaml:"ifshell"` // the (optional) shell to use to run the if cmd PollInt int `yaml:"pollint"` // the poll interval for the ifcmd }
ExecRes is an exec resource for running commands.
func NewExecRes ¶
func NewExecRes(name, cmd, shell string, timeout int, watchcmd, watchshell, ifcmd, ifshell string, pollint int, state string) (*ExecRes, error)
NewExecRes is a constructor for this resource. It also calls Init() for you.
func (*ExecRes) AutoEdges ¶
AutoEdges returns the AutoEdge interface. In this case no autoedges are used.
func (*ExecRes) BufioChanScanner ¶
BufioChanScanner wraps the scanner output in a channel.
func (*ExecRes) CheckApply ¶
CheckApply checks the resource state and applies the resource if the bool input is true. It returns error info and if the state check passed or not. TODO: expand the IfCmd to be a list of commands
func (*ExecRes) UIDs ¶
UIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.
func (*ExecRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
type FileInfo ¶
type FileInfo struct { os.FileInfo // embed AbsPath string // smart variant RelPath string // smart variant }
FileInfo is an enhanced variant of the traditional os.FileInfo struct. It can store both the absolute and the relative paths (when built from our ReadDir), and those two paths contain a trailing slash when they refer to a directory.
type FileRes ¶
type FileRes struct { BaseRes `yaml:",inline"` Path string `yaml:"path"` // path variable (should default to name) Dirname string `yaml:"dirname"` Basename string `yaml:"basename"` Content *string `yaml:"content"` // nil to mark as undefined Source string `yaml:"source"` // file path for source content State string `yaml:"state"` // state: exists/present?, absent, (undefined?) Recurse bool `yaml:"recurse"` Force bool `yaml:"force"` // contains filtered or unexported fields }
FileRes is a file and directory resource.
func NewFileRes ¶
func NewFileRes(name, path, dirname, basename string, content *string, source, state string, recurse, force bool) (*FileRes, error)
NewFileRes is a constructor for this resource. It also calls Init() for you.
func (*FileRes) AutoEdges ¶
AutoEdges generates a simple linear sequence of each parent directory from the bottom up!
func (*FileRes) CheckApply ¶
CheckApply checks the resource state and applies the resource if the bool input is true. It returns error info and if the state check passed or not.
func (*FileRes) CollectPattern ¶
CollectPattern applies the pattern for collection resources.
func (*FileRes) GetPath ¶
GetPath returns the actual path to use for this resource. It computes this after analysis of the Path, Dirname and Basename values. Dirs end with slash.
func (*FileRes) UIDs ¶
UIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.
func (*FileRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
func (*FileRes) Watch ¶
Watch is the primary listener for this resource and it outputs events. This one is a file watcher for files and directories. Modify with caution, it is probably important to write some test cases first! If the Watch returns an error, it means that something has gone wrong, and it must be restarted. On a clean exit it returns nil. FIXME: Also watch the source directory when using obj.Source !!!
type FileResAutoEdges ¶
type FileResAutoEdges struct {
// contains filtered or unexported fields
}
FileResAutoEdges holds the state of the auto edge generator.
func (*FileResAutoEdges) Next ¶
func (obj *FileResAutoEdges) Next() []ResUID
Next returns the next automatic edge.
func (*FileResAutoEdges) Test ¶
func (obj *FileResAutoEdges) Test(input []bool) bool
Test gets results of the earlier Next() call, & returns if we should continue!
type FileUID ¶
type FileUID struct { BaseUID // contains filtered or unexported fields }
FileUID is the UID struct for FileRes.
type HostnameRes ¶
type HostnameRes struct { BaseRes `yaml:",inline"` Hostname string `yaml:"hostname"` PrettyHostname string `yaml:"pretty_hostname"` StaticHostname string `yaml:"static_hostname"` TransientHostname string `yaml:"transient_hostname"` // contains filtered or unexported fields }
HostnameRes is a resource that allows setting and watching the hostname.
StaticHostname is the one configured in /etc/hostname or a similar file. It is chosen by the local user. It is not always in sync with the current host name as returned by the gethostname() system call.
TransientHostname is the one configured via the kernel's sethostbyname(). It can be different from the static hostname in case DHCP or mDNS have been configured to change the name based on network information.
PrettyHostname is a free-form UTF8 host name for presentation to the user.
Hostname is the fallback value for all 3 fields above, if only Hostname is specified, it will set all 3 fields to this value.
func NewHostnameRes ¶
func NewHostnameRes(name, staticHostname, transientHostname, prettyHostname string) (*HostnameRes, error)
NewHostnameRes is a constructor for this resource. It also calls Init() for you.
func (*HostnameRes) AutoEdges ¶
func (obj *HostnameRes) AutoEdges() AutoEdge
AutoEdges returns the AutoEdge interface. In this case no autoedges are used.
func (*HostnameRes) CheckApply ¶
func (obj *HostnameRes) CheckApply(apply bool) (checkOK bool, err error)
CheckApply method for Hostname resource.
func (*HostnameRes) Compare ¶
func (obj *HostnameRes) Compare(res Res) bool
Compare two resources and return if they are equivalent.
func (*HostnameRes) Default ¶
func (obj *HostnameRes) Default() Res
Default returns some sensible defaults for this resource.
func (*HostnameRes) GroupCmp ¶
func (obj *HostnameRes) GroupCmp(r Res) bool
GroupCmp returns whether two resources can be grouped together or not.
func (*HostnameRes) Init ¶
func (obj *HostnameRes) Init() error
Init runs some startup code for this resource.
func (*HostnameRes) UIDs ¶
func (obj *HostnameRes) UIDs() []ResUID
UIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.
func (*HostnameRes) UnmarshalYAML ¶
func (obj *HostnameRes) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
func (*HostnameRes) Validate ¶
func (obj *HostnameRes) Validate() error
Validate if the params passed in are valid data.
type HostnameUID ¶
type HostnameUID struct { BaseUID // contains filtered or unexported fields }
HostnameUID is the UID struct for HostnameRes.
type MetaParams ¶
type MetaParams struct { AutoEdge bool `yaml:"autoedge"` // metaparam, should we generate auto edges? AutoGroup bool `yaml:"autogroup"` // metaparam, should we auto group? Noop bool `yaml:"noop"` // NOTE: there are separate Watch and CheckApply retry and delay values, // but I've decided to use the same ones for both until there's a proper // reason to want to do something differently for the Watch errors. Retry int16 `yaml:"retry"` // metaparam, number of times to retry on error. -1 for infinite Delay uint64 `yaml:"delay"` // metaparam, number of milliseconds to wait between retries Poll uint32 `yaml:"poll"` // metaparam, number of seconds between poll intervals, 0 to watch Limit rate.Limit `yaml:"limit"` // metaparam, number of events per second to allow through Burst int `yaml:"burst"` // metaparam, number of events to allow in a burst }
MetaParams is a struct will all params that apply to every resource.
func (*MetaParams) UnmarshalYAML ¶
func (obj *MetaParams) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML is the custom unmarshal handler for the MetaParams struct. It is primarily useful for setting the defaults.
type MsgRes ¶
type MsgRes struct { BaseRes `yaml:",inline"` Body string `yaml:"body"` Priority string `yaml:"priority"` Fields map[string]string `yaml:"fields"` Journal bool `yaml:"journal"` // enable systemd journal output Syslog bool `yaml:"syslog"` // enable syslog output // contains filtered or unexported fields }
MsgRes is a resource that writes messages to logs.
func NewMsgRes ¶
func NewMsgRes(name, body, priority string, journal, syslog bool, fields map[string]string) (*MsgRes, error)
NewMsgRes is a constructor for this resource.
func (*MsgRes) CheckApply ¶
CheckApply method for Msg resource. Every check leads to an apply, meaning that the message is flushed to the journal.
func (*MsgRes) UIDs ¶
UIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.
func (*MsgRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
type MsgUID ¶
type MsgUID struct { BaseUID // contains filtered or unexported fields }
MsgUID is a unique representation for a MsgRes object.
type NoopRes ¶
type NoopRes struct { BaseRes `yaml:",inline"` Comment string `yaml:"comment"` // extra field for example purposes }
NoopRes is a no-op resource that does nothing.
func NewNoopRes ¶
NewNoopRes is a constructor for this resource. It also calls Init() for you.
func (*NoopRes) AutoEdges ¶
AutoEdges returns the AutoEdge interface. In this case no autoedges are used.
func (*NoopRes) CheckApply ¶
CheckApply method for Noop resource. Does nothing, returns happy!
func (*NoopRes) UIDs ¶
UIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.
func (*NoopRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
type NoopUID ¶
type NoopUID struct { BaseUID // contains filtered or unexported fields }
NoopUID is the UID struct for NoopRes.
type NspawnRes ¶
type NspawnRes struct { BaseRes `yaml:",inline"` State string `yaml:"state"` // contains filtered or unexported fields }
NspawnRes is an nspawn container resource
func NewNspawnRes ¶
NewNspawnRes is the constructor for this resource
func (*NspawnRes) AutoEdges ¶
AutoEdges returns the AutoEdge interface in this case no autoedges are used
func (*NspawnRes) CheckApply ¶
CheckApply is run to check the state and, if apply is true, to apply the necessary changes to reach the desired state. this is run before Watch and again if watch finds a change occurring to the state
func (*NspawnRes) UIDs ¶
UIDs includes all params to make a unique identification of this object most resources only return one although some resources can return multiple
func (*NspawnRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
type NspawnUID ¶
type NspawnUID struct { // NOTE: there is also a name variable in the BaseUID struct, this is // information about where this UID came from, and is unrelated to the // information about the resource we're matching. That data which is // used in the IFF function, is what you see in the struct fields here BaseUID // contains filtered or unexported fields }
NspawnUID is a unique resource identifier
type PasswordRes ¶
type PasswordRes struct { BaseRes `yaml:",inline"` // FIXME: is uint16 too big? Length uint16 `yaml:"length"` // number of characters to return Saved bool // this caches the password in the clear locally CheckRecovery bool // recovery from integrity checks by re-generating Password *string // the generated password, read only, do not set! // contains filtered or unexported fields }
PasswordRes is a no-op resource that returns a random password string.
func NewPasswordRes ¶
func NewPasswordRes(name string, length uint16) (*PasswordRes, error)
NewPasswordRes is a constructor for this resource. It also calls Init() for you.
func (*PasswordRes) AutoEdges ¶
func (obj *PasswordRes) AutoEdges() AutoEdge
AutoEdges returns the AutoEdge interface. In this case no autoedges are used.
func (*PasswordRes) CheckApply ¶
func (obj *PasswordRes) CheckApply(apply bool) (checkOK bool, err error)
CheckApply method for Password resource. Does nothing, returns happy!
func (*PasswordRes) Compare ¶
func (obj *PasswordRes) Compare(res Res) bool
Compare two resources and return if they are equivalent.
func (*PasswordRes) Default ¶
func (obj *PasswordRes) Default() Res
Default returns some sensible defaults for this resource.
func (*PasswordRes) GroupCmp ¶
func (obj *PasswordRes) GroupCmp(r Res) bool
GroupCmp returns whether two resources can be grouped together or not.
func (*PasswordRes) Init ¶
func (obj *PasswordRes) Init() error
Init generates a new password for this resource if one was not provided. It will save this into a local file. It will load it back in from previous runs.
func (*PasswordRes) UIDs ¶
func (obj *PasswordRes) UIDs() []ResUID
UIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.
func (*PasswordRes) UnmarshalYAML ¶
func (obj *PasswordRes) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
func (*PasswordRes) Validate ¶
func (obj *PasswordRes) Validate() error
Validate if the params passed in are valid data.
type PasswordUID ¶
type PasswordUID struct { BaseUID // contains filtered or unexported fields }
PasswordUID is the UID struct for PasswordRes.
type PkgRes ¶
type PkgRes struct { BaseRes `yaml:",inline"` State string `yaml:"state"` // state: installed, uninstalled, newest, <version> AllowUntrusted bool `yaml:"allowuntrusted"` // allow untrusted packages to be installed? AllowNonFree bool `yaml:"allownonfree"` // allow nonfree packages to be found? AllowUnsupported bool `yaml:"allowunsupported"` // allow unsupported packages to be found? // contains filtered or unexported fields }
PkgRes is a package resource for packagekit.
func NewPkgRes ¶
func NewPkgRes(name, state string, allowuntrusted, allownonfree, allowunsupported bool) (*PkgRes, error)
NewPkgRes is a constructor for this resource. It also calls Init() for you.
func (*PkgRes) AutoEdges ¶
AutoEdges produces an object which generates a minimal pkg file optimization sequence of edges.
func (*PkgRes) CheckApply ¶
CheckApply checks the resource state and applies the resource if the bool input is true. It returns error info and if the state check passed or not.
func (*PkgRes) GroupCmp ¶
GroupCmp returns whether two resources can be grouped together or not. can these two resources be merged ? (aka does this resource support doing so?) will resource allow itself to be grouped _into_ this obj?
func (*PkgRes) UIDs ¶
UIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.
func (*PkgRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
func (*PkgRes) Watch ¶
Watch is the primary listener for this resource and it outputs events. It uses the PackageKit UpdatesChanged signal to watch for changes. TODO: https://github.com/hughsie/PackageKit/issues/109 TODO: https://github.com/hughsie/PackageKit/issues/110
type PkgResAutoEdges ¶
type PkgResAutoEdges struct {
// contains filtered or unexported fields
}
PkgResAutoEdges holds the state of the auto edge generator.
func (*PkgResAutoEdges) Next ¶
func (obj *PkgResAutoEdges) Next() []ResUID
Next returns the next automatic edge.
func (*PkgResAutoEdges) Test ¶
func (obj *PkgResAutoEdges) Test(input []bool) bool
Test gets results of the earlier Next() call, & returns if we should continue!
type PkgUID ¶
type PkgUID struct { BaseUID // contains filtered or unexported fields }
PkgUID is the UID struct for PkgRes.
type Res ¶
type Res interface { Base // include everything from the Base interface Default() Res // return a struct with sane defaults as a Res Validate() error Init() error Close() error UIDs() []ResUID // most resources only return one Watch(chan *event.Event) error // send on channel to signal process() events CheckApply(apply bool) (checkOK bool, err error) AutoEdges() AutoEdge Compare(Res) bool CollectPattern(string) // XXX: temporary until Res collection is more advanced }
Res is the minimum interface you need to implement to define a new resource.
type ResState ¶
type ResState int
The ResState type represents the current activity state of each resource.
type ResUID ¶
type ResUID interface { GetName() string Kind() string IFF(ResUID) bool Reversed() bool // true means this resource happens before the generator }
ResUID is a unique identifier for a resource, namely it's name, and the kind ("type").
type Send ¶
type Send struct { Res Res // a handle to the resource which is sending a value Key string // the key in the resource that we're sending Changed bool // set to true if this key was updated, read only! }
Send points to a value that a resource will send.
type StatefulBool ¶
type StatefulBool interface { Get() (bool, error) // get value of token Set() error // set token to true Del() error // rm token if it exists }
StatefulBool is an interface for storing a boolean flag in a permanent spot.
type SvcRes ¶
type SvcRes struct { BaseRes `yaml:",inline"` State string `yaml:"state"` // state: running, stopped, undefined Startup string `yaml:"startup"` // enabled, disabled, undefined }
SvcRes is a service resource for systemd units.
func (*SvcRes) AutoEdges ¶
AutoEdges returns the AutoEdge interface. In this case the systemd units.
func (*SvcRes) CheckApply ¶
CheckApply checks the resource state and applies the resource if the bool input is true. It returns error info and if the state check passed or not.
func (*SvcRes) UIDs ¶
UIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.
func (*SvcRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
type SvcResAutoEdges ¶
type SvcResAutoEdges struct {
// contains filtered or unexported fields
}
SvcResAutoEdges holds the state of the auto edge generator.
func (*SvcResAutoEdges) Next ¶
func (obj *SvcResAutoEdges) Next() []ResUID
Next returns the next automatic edge.
func (*SvcResAutoEdges) Test ¶
func (obj *SvcResAutoEdges) Test(input []bool) bool
Test gets results of the earlier Next() call, & returns if we should continue!
type SvcUID ¶
type SvcUID struct { // NOTE: there is also a name variable in the BaseUID struct, this is // information about where this UID came from, and is unrelated to the // information about the resource we're matching. That data which is // used in the IFF function, is what you see in the struct fields here. BaseUID // contains filtered or unexported fields }
SvcUID is the UID struct for SvcRes.
type TimerRes ¶
type TimerRes struct { BaseRes `yaml:",inline"` Interval uint32 `yaml:"interval"` // Interval : Interval between runs // contains filtered or unexported fields }
TimerRes is a timer resource for time based events.
func NewTimerRes ¶
NewTimerRes is a constructor for this resource. It also calls Init() for you.
func (*TimerRes) AutoEdges ¶
AutoEdges returns the AutoEdge interface. In this case no autoedges are used.
func (*TimerRes) CheckApply ¶
CheckApply method for Timer resource. Triggers a timer reset on notify.
func (*TimerRes) UIDs ¶
UIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.
func (*TimerRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
type TimerUID ¶
type TimerUID struct { BaseUID // contains filtered or unexported fields }
TimerUID is the UID struct for TimerRes.
type VirtRes ¶
type VirtRes struct { BaseRes `yaml:",inline"` URI string `yaml:"uri"` // connection uri, eg: qemu:///session State string `yaml:"state"` // running, paused, shutoff Transient bool `yaml:"transient"` // defined (false) or undefined (true) CPUs uint `yaml:"cpus"` Memory uint64 `yaml:"memory"` // in KBytes OSInit string `yaml:"osinit"` // init used by lxc Boot []string `yaml:"boot"` // boot order. values: fd, hd, cdrom, network Disk []diskDevice `yaml:"disk"` CDRom []cdRomDevice `yaml:"cdrom"` Network []networkDevice `yaml:"network"` Filesystem []filesystemDevice `yaml:"filesystem"` Auth *VirtAuth `yaml:"auth"` // contains filtered or unexported fields }
VirtRes is a libvirt resource. A transient virt resource, which has its state set to `shutoff` is one which does not exist. The parallel equivalent is a file resource which removes a particular path.
func NewVirtRes ¶
func NewVirtRes(name string, uri, state string, transient bool, cpus uint, memory uint64, osinit string) (*VirtRes, error)
NewVirtRes is a constructor for this resource. It also calls Init() for you.
func (*VirtRes) AutoEdges ¶
AutoEdges returns the AutoEdge interface. In this case no autoedges are used.
func (*VirtRes) CheckApply ¶
CheckApply checks the resource state and applies the resource if the bool input is true. It returns error info and if the state check passed or not.
func (*VirtRes) CollectPattern ¶
CollectPattern applies the pattern for collection resources.
func (*VirtRes) UIDs ¶
UIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.
func (*VirtRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package packagekit provides an interface to interact with packagekit.
|
Package packagekit provides an interface to interact with packagekit. |