Documentation ¶
Overview ¶
Package resources provides the resource framework and idempotent primitives.
Index ¶
- Constants
- Variables
- func AutoEdges(g *pgraph.Graph) error
- func AutoGroup(g *pgraph.Graph, ag AutoGrouper)
- func GetGID(group string) (int, error)
- func GetUID(username string) (int, error)
- func LangFieldNameToStructFieldName(kind string) (map[string]string, error)
- func LangFieldNameToStructType(kind string) (map[string]*types.Type, error)
- func LowerStructFieldNameToFieldName(res Res) (map[string]string, error)
- func RegisterResource(kind string, fn func() Res)
- func RegisteredResourcesNames() []string
- func ResToB64(res Res) (string, error)
- func ReturnSvcInFileList(fileList []string) []string
- func SemaSize(id string) int
- func StructKindToFieldNameTypeMap(kind string) (map[string]*types.Type, error)
- func StructTagToFieldName(res Res) (map[string]string, error)
- func TypeCmp(a, b reflect.Value) error
- func UIDExistsInUIDs(uid ResUID, uids []ResUID) bool
- func VertexMerge(g *pgraph.Graph, v1, v2 pgraph.Vertex, ...) error
- type AugeasRes
- func (obj *AugeasRes) CheckApply(apply bool) (bool, error)
- func (obj *AugeasRes) Compare(r Res) bool
- func (obj *AugeasRes) Default() Res
- func (obj *AugeasRes) GroupCmp(r Res) bool
- func (obj *AugeasRes) Init() error
- func (obj *AugeasRes) UIDs() []ResUID
- func (obj *AugeasRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *AugeasRes) Validate() error
- func (obj *AugeasRes) Watch() error
- type AugeasSet
- type AugeasUID
- type AutoEdge
- type AutoGrouper
- type AwsEc2Res
- func (obj *AwsEc2Res) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *AwsEc2Res) Close() error
- func (obj *AwsEc2Res) Compare(r Res) bool
- func (obj *AwsEc2Res) Default() Res
- func (obj *AwsEc2Res) GroupCmp(r Res) bool
- func (obj *AwsEc2Res) Init() error
- func (obj *AwsEc2Res) UIDs() []ResUID
- func (obj *AwsEc2Res) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *AwsEc2Res) Validate() error
- func (obj *AwsEc2Res) Watch() error
- type AwsEc2UID
- type Base
- type BaseRes
- func (obj *BaseRes) AutoEdges() (AutoEdge, error)
- func (obj *BaseRes) BackPoke()
- func (obj *BaseRes) Close() error
- func (obj *BaseRes) CollectPattern(pattern string)
- func (obj *BaseRes) Compare(res Res) bool
- func (obj *BaseRes) Data() *ResData
- func (obj *BaseRes) Event() error
- func (obj *BaseRes) Events() chan *event.Event
- func (obj *BaseRes) Exit()
- func (obj *BaseRes) GetGroup() []Res
- func (obj *BaseRes) GetKind() string
- 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) Meta() *MetaParams
- func (obj *BaseRes) OKTimestamp() bool
- func (obj *BaseRes) Poke() error
- func (obj *BaseRes) Poll() error
- func (obj *BaseRes) Process() error
- func (obj *BaseRes) ProcessExit()
- func (obj *BaseRes) ReadEvent(ev *event.Event) (exit *error, send bool)
- func (obj *BaseRes) Refresh() bool
- func (obj *BaseRes) RefreshPending() bool
- func (obj *BaseRes) Reset()
- func (obj *BaseRes) Running() error
- func (obj *BaseRes) SendEvent(ev event.Kind, err error) error
- func (obj *BaseRes) SendRecv(res Res) (map[string]bool, error)
- func (obj *BaseRes) SetDownstreamRefresh(b bool)
- 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) SetRecv(recv map[string]*Send)
- func (obj *BaseRes) SetRefresh(b bool)
- func (obj *BaseRes) SetState(state ResState)
- func (obj *BaseRes) SetUpstreamRefresh(b bool)
- func (obj *BaseRes) Setup(mgraph *MGraph, vertex pgraph.Vertex, res Res)
- func (obj *BaseRes) Started() <-chan struct{}
- func (obj *BaseRes) Starter(b bool)
- func (obj *BaseRes) StateOK(b bool)
- func (obj *BaseRes) Stopped() <-chan struct{}
- func (obj *BaseRes) String() string
- func (obj *BaseRes) Timestamp() int64
- func (obj *BaseRes) UpdateTimestamp() int64
- func (obj *BaseRes) Validate() error
- func (obj *BaseRes) VarDir(extra string) (string, error)
- func (obj *BaseRes) Worker() error
- func (obj *BaseRes) Working() *bool
- type BaseUID
- type DiskBool
- type Edge
- type ExecRes
- func (obj *ExecRes) AutoEdges() (AutoEdge, error)
- func (obj *ExecRes) BufioChanScanner(scanner *bufio.Scanner) (chan string, chan error)
- func (obj *ExecRes) CheckApply(apply bool) (bool, error)
- func (obj *ExecRes) Compare(r 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() error
- type ExecResAutoEdges
- type ExecUID
- type FileInfo
- type FileRes
- func (obj *FileRes) AutoEdges() (AutoEdge, error)
- func (obj *FileRes) CheckApply(apply bool) (checkOK bool, _ error)
- func (obj *FileRes) CollectPattern(pattern string)
- func (obj *FileRes) Compare(r 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() error
- type FileResAutoEdges
- type FileUID
- type Fs
- type GraphRes
- func (obj *GraphRes) CheckApply(apply bool) (bool, error)
- func (obj *GraphRes) Close() error
- func (obj *GraphRes) Compare(r Res) bool
- func (obj *GraphRes) Default() Res
- func (obj *GraphRes) Init() error
- func (obj *GraphRes) UIDs() []ResUID
- func (obj *GraphRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *GraphRes) Validate() error
- func (obj *GraphRes) Watch() error
- type GraphUID
- type GroupRes
- func (obj *GroupRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *GroupRes) Compare(r Res) bool
- func (obj *GroupRes) Default() Res
- func (obj *GroupRes) GroupCmp(r Res) bool
- func (obj *GroupRes) Init() error
- func (obj *GroupRes) UIDs() []ResUID
- func (obj *GroupRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *GroupRes) Validate() error
- func (obj *GroupRes) Watch() error
- type GroupUID
- type HostnameRes
- func (obj *HostnameRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *HostnameRes) Compare(r 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() error
- type HostnameUID
- type KVRes
- func (obj *KVRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *KVRes) Compare(r Res) bool
- func (obj *KVRes) Default() Res
- func (obj *KVRes) GroupCmp(r Res) bool
- func (obj *KVRes) Init() error
- func (obj *KVRes) UIDs() []ResUID
- func (obj *KVRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *KVRes) Validate() error
- func (obj *KVRes) Watch() error
- type KVResSkipCmpStyle
- type KVUID
- type MGraph
- type MetaParams
- type MsgRes
- func (obj *MsgRes) CheckApply(apply bool) (bool, error)
- func (obj *MsgRes) Compare(r 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() error
- type MsgUID
- type NonReachabilityGrouper
- type NoopRes
- func (obj *NoopRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *NoopRes) Compare(r 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() error
- type NoopUID
- type NspawnRes
- func (obj *NspawnRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *NspawnRes) Compare(r 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() error
- type NspawnUID
- type PasswordRes
- func (obj *PasswordRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *PasswordRes) Compare(r 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() error
- type PasswordUID
- type PkgFileUID
- type PkgRes
- func (obj *PkgRes) AutoEdges() (AutoEdge, error)
- func (obj *PkgRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *PkgRes) Compare(r 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() error
- type PkgResAutoEdges
- type PkgUID
- type PrintRes
- func (obj *PrintRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *PrintRes) Compare(r Res) bool
- func (obj *PrintRes) Default() Res
- func (obj *PrintRes) GroupCmp(r Res) bool
- func (obj *PrintRes) Init() error
- func (obj *PrintRes) UIDs() []ResUID
- func (obj *PrintRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *PrintRes) Validate() error
- func (obj *PrintRes) Watch() error
- type PrintUID
- type Res
- type ResData
- type ResState
- type ResUID
- type ResourceSlice
- type Send
- type SentinelErr
- type StatefulBool
- type SvcRes
- func (obj *SvcRes) AutoEdges() (AutoEdge, error)
- func (obj *SvcRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *SvcRes) Compare(r 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() error
- type SvcResAutoEdges
- type SvcUID
- type TestRes
- func (obj *TestRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *TestRes) Compare(r Res) bool
- func (obj *TestRes) Default() Res
- func (obj *TestRes) GroupCmp(r Res) bool
- func (obj *TestRes) Init() error
- func (obj *TestRes) UIDs() []ResUID
- func (obj *TestRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *TestRes) Validate() error
- func (obj *TestRes) Watch() error
- type TestUID
- type TimerRes
- func (obj *TimerRes) CheckApply(apply bool) (bool, error)
- func (obj *TimerRes) Compare(r 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() error
- type TimerUID
- type UserRes
- func (obj *UserRes) AutoEdges() (AutoEdge, error)
- func (obj *UserRes) CheckApply(apply bool) (checkOK bool, err error)
- func (obj *UserRes) Compare(r Res) bool
- func (obj *UserRes) Default() Res
- func (obj *UserRes) GroupCmp(r Res) bool
- func (obj *UserRes) Init() error
- func (obj *UserRes) UIDs() []ResUID
- func (obj *UserRes) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (obj *UserRes) Validate() error
- func (obj *UserRes) Watch() error
- type UserResAutoEdges
- type UserUID
- type VirtAuth
- type VirtRes
- func (obj *VirtRes) CheckApply(apply bool) (bool, error)
- func (obj *VirtRes) Close() error
- func (obj *VirtRes) Compare(r 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() error
- type VirtUID
- type World
Constants ¶
const ( // AwsPrefix is a const which gets prepended onto object names. We can only use // alphanumeric chars, underscores and hyphens for sns topics and cloud watch rules. AwsPrefix = "_mgmt-" // Ec2Prefix is added to the names of sns and cloudwatch objects. Ec2Prefix = AwsPrefix + "ec2-" // SnsPrefix gets prepended onto the sns topic. SnsPrefix = Ec2Prefix + "sns-" // SnsTopicName is the name of the sns topic created by snsMakeTopic. SnsTopicName = SnsPrefix + "events" // SnsSubscriptionProto is used to tell sns that the subscriber uses the http protocol. // TODO: add https support SnsSubscriptionProto = "http" // SnsServerShutdownTimeout is the maximum number of seconds to wait for the http server to shutdown gracefully. SnsServerShutdownTimeout = 30 // SnsPolicy is the topic attribute that defines the security policy for the topic. SnsPolicy = "Policy" // SnsPolicySid is the friendly name of the policy statement. SnsPolicySid = CwePrefix + "publish" // SnsPolicyEffect allows the action(s) defined in the policy statement. SnsPolicyEffect = "Allow" // SnsPolicyService is the cloudwatch events security principal that we are granting the permission to. SnsPolicyService = "events.amazonaws.com" // SnsPolicyAction is the specific permission we are granting in the policy. SnsPolicyAction = "SNS:Publish" // SnsCertURLRegex is used to make sure we only download certificates // from amazon. This regex will match "https://sns.***.amazonaws.com/" // where *** represents any combination of words and hyphens, and will // match any aws region name, eg: ca-central-1. SnsCertURLRegex = `(^https:\/\/sns\.([\w\-])+\.amazonaws.com\/)` // CwePrefix gets prepended onto the cloudwatch rule name. CwePrefix = Ec2Prefix + "cw-" // CweRuleName is the name of the rule created by makeCloudWatchRule. CweRuleName = CwePrefix + "state" // CweRuleSource describes the resource type to monitor for cloudwatch events. CweRuleSource = "aws.ec2" // CweRuleDetailType describes the specific type of events to trigger cloudwatch. CweRuleDetailType = "EC2 Instance State-change Notification" // CweTargetID is used to tell cloudwatch events to target the sns service. CweTargetID = "sns" // CweTargetJSON is the json field that cloudwatch will send to our endpoint so we don't get more than we need. CweTargetJSON = "$.detail" // AwsErrExceededWaitAttempts is the awserr.Message() that gets sent with // the ResourceStateNotReady awserr.Code() when the waiters time out. AwsErrExceededWaitAttempts = "exceeded wait attempts" // AwsErrIncorrectInstanceState is the error returned when an action // cannot be completed due to the current instance state. AwsErrIncorrectInstanceState = "IncorrectInstanceState" )
const ( // DefaultMaxCPUs is the default number of possible cpu "slots" used. DefaultMaxCPUs = 32 // MaxShutdownDelayTimeout is the max time we wait for a vm to shutdown. MaxShutdownDelayTimeout = 60 * 5 // seconds // ShortPollInterval is how often we poll when expecting an event. ShortPollInterval = 5 // seconds )
const (
// NS is a namespace for augeas operations
NS = "Xmgmt"
)
const SemaSep = ":"
SemaSep is the trailing separator to split the semaphore id from the size.
const (
// StructTag is the key we use in struct field names for key mapping.
StructTag = "lang"
)
Variables ¶
var AwsRegions = []string{
"ap-northeast-1",
"ap-northeast-2",
"ap-south-1",
"ap-southeast-1",
"ap-southeast-2",
"ca-central-1",
"cn-north-1",
"eu-central-1",
"eu-west-1",
"eu-west-2",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-gov-west-1",
"us-west-1",
"us-west-2",
}
AwsRegions is a list of all AWS regions generated using ec2.DescribeRegions. cn-north-1 and us-gov-west-1 are not returned, probably due to security. List available at http://docs.aws.amazon.com/general/latest/gr/rande.html
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 AutoGroup ¶
func AutoGroup(g *pgraph.Graph, ag AutoGrouper)
AutoGroup runs the auto grouping on the graph and prints out log messages.
func GetGID ¶
GetGID returns the GID of a group. It supports a GID or a group name. Caller should first check group is not empty. It will return an error if it can't lookup the GID or group name.
func GetUID ¶
GetUID returns the UID of an user. It supports an UID or an username. Caller should first check user is not empty. It will return an error if it can't lookup the UID or username.
func LangFieldNameToStructFieldName ¶
LangFieldNameToStructFieldName returns the mapping from lang (AST) field names to field name as used in the struct. The logic here is a bit strange; if the resource has struct tags, then it uses those, otherwise it falls back to using the lower case versions of things. It might be clever to combine the two so that tagged fields are used as such, and others are used in lowercase, but this is currently not implemented. TODO: should this behaviour be changed?
func LangFieldNameToStructType ¶
LangFieldNameToStructType returns the mapping from lang (AST) field names, and the expected type in our type system for each.
func LowerStructFieldNameToFieldName ¶
LowerStructFieldNameToFieldName returns a mapping from the lower case version of each field name to the actual field name. It only returns public fields. It returns an error if it finds a collision.
func RegisterResource ¶
RegisterResource registers a new resource by providing a constructor function that returns a resource object ready to be unmarshalled from YAML.
func RegisteredResourcesNames ¶
func RegisteredResourcesNames() []string
RegisteredResourcesNames returns the kind of the registered resources.
func ReturnSvcInFileList ¶
ReturnSvcInFileList returns a list of svc names for matches like: `/usr/lib/systemd/system/*.service`.
func SemaSize ¶
SemaSize returns the size integer associated with the semaphore id. It defaults to 1 if not found.
func StructKindToFieldNameTypeMap ¶
StructKindToFieldNameTypeMap returns a map from field name to expected type in the lang type system.
func StructTagToFieldName ¶
StructTagToFieldName returns a mapping from recommended alias to actual field name. It returns an error if it finds a collision. It uses the `lang` tags.
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.
func VertexMerge ¶
func VertexMerge(g *pgraph.Graph, v1, v2 pgraph.Vertex, vertexMergeFn func(pgraph.Vertex, pgraph.Vertex) (pgraph.Vertex, error), edgeMergeFn func(pgraph.Edge, pgraph.Edge) pgraph.Edge) error
VertexMerge merges v2 into v1 by reattaching the edges where appropriate, and then by deleting v2 from the graph. Since more than one edge between two vertices is not allowed, duplicate edges are merged as well. an edge merge function can be provided if you'd like to control how you merge the edges!
Types ¶
type AugeasRes ¶
type AugeasRes struct { BaseRes `yaml:",inline"` // File is the path to the file targeted by this resource. File string `yaml:"file"` // Lens is the lens used by this resource. If specified, mgmt // will lower the augeas overhead by only loading that lens. Lens string `yaml:"lens"` // Sets is a list of changes that will be applied to the file, in the form of // ["path", "value"]. mgmt will run augeas.Get() before augeas.Set(), to // prevent changing the file when it is not needed. Sets []AugeasSet `yaml:"sets"` // contains filtered or unexported fields }
AugeasRes is a resource that enables you to use the augeas resource. Currently only allows you to change simple files (e.g sshd_config).
func (*AugeasRes) CheckApply ¶
CheckApply method for Augeas resource.
func (*AugeasRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
type AugeasSet ¶
type AugeasSet struct { Path string `yaml:"path"` // The relative path to the value to be changed. Value string `yaml:"value"` // The value to be set on the given Path. }
AugeasSet represents a key/value pair of settings to be applied.
type AugeasUID ¶
type AugeasUID struct { BaseUID // contains filtered or unexported fields }
AugeasUID is the UID struct for AugeasRes.
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 AutoGrouper ¶
type AutoGrouper interface {
// contains filtered or unexported methods
}
AutoGrouper is the required interface to implement for an autogroup algorithm.
type AwsEc2Res ¶
type AwsEc2Res struct { BaseRes `yaml:",inline"` State string `yaml:"state"` // state: running, stopped, terminated Region string `yaml:"region"` // region must match an element of AwsRegions Type string `yaml:"type"` // type of ec2 instance, eg: t2.micro ImageID string `yaml:"imageid"` // imageid must be available on the chosen region WatchEndpoint string `yaml:"watchendpoint"` // the public url of the sns endpoint, eg: http://server:12345/ WatchListenAddr string `yaml:"watchlistenaddr"` // the local address or port that the sns listens on, eg: 10.0.0.0:23456 or 23456 // ErrorOnMalformedPost controls whether or not malformed HTTP post // requests, that cause JSON decoder errors, will also make the engine // shut down. If ErrorOnMalformedPost set to true and an error occurs, // Watch() will return the error and the engine will shut down. ErrorOnMalformedPost bool `yaml:"erroronmalformedpost"` // UserData is used to run bash and cloud-init commands on first launch. // See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html // for documantation and examples. UserData string `yaml:"userdata"` // store read-only values for send/recv. PublicIPv4 string PrivateIPv4 string InstanceID string // contains filtered or unexported fields }
AwsEc2Res is an AWS EC2 resource. In order to create a client session, your AWS credentials must be present in ~/.aws - For detailed instructions see http://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html
func (*AwsEc2Res) CheckApply ¶
CheckApply method for AwsEc2 resource.
func (*AwsEc2Res) Close ¶
Close cleans up when we're done. This is needed to delete some of the AWS objects created for the SNS endpoint.
func (*AwsEc2Res) 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 (*AwsEc2Res) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
type AwsEc2UID ¶
type AwsEc2UID struct { BaseUID // contains filtered or unexported fields }
AwsEc2UID is the UID struct for AwsEc2Res.
type Base ¶
type Base interface { fmt.Stringer // String() string GetName() string // can't be named "Name()" because of struct field SetName(string) SetKind(string) GetKind() string Meta() *MetaParams Events() chan *event.Event Data() *ResData Working() *bool Setup(*MGraph, pgraph.Vertex, Res) Reset() Exit() GetState() ResState SetState(ResState) Timestamp() int64 UpdateTimestamp() int64 Event() error SendEvent(event.Kind, 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 SetRecv(map[string]*Send) 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() error // notify the engine that Watch started Started() <-chan struct{} // returns when the resource has started Stopped() <-chan struct{} // returns when the resource has stopped Starter(bool) Poll() error // poll alternative to watching :( Worker() error }
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 { Res Res // pointer to full res Graph *MGraph // pointer to graph I'm currently in Vertex pgraph.Vertex // pointer to vertex I currently am Recv map[string]*Send // mapping of key to receive on from value Kind string Name string `yaml:"name"` MetaParams MetaParams `yaml:"meta"` // struct of all the metaparams // contains filtered or unexported fields }
BaseRes is the base struct that gets used in every resource.
func (*BaseRes) AutoEdges ¶
AutoEdges returns the AutoEdge interface. By default, none are created. This should be implemented by the specific resource to be used. This base method does not need to be called by the resource specific implementing method.
func (*BaseRes) BackPoke ¶
func (obj *BaseRes) BackPoke()
BackPoke pokes the pre-requisites that are stale and need to run before I can run.
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) Exit ¶
func (obj *BaseRes) Exit()
Exit the resource. Wrapper function to keep the logic in one place for now.
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) OKTimestamp ¶
OKTimestamp returns true if this element can run right now?
func (*BaseRes) Poll ¶
Poll is the watch replacement for when we want to poll, which outputs events.
func (*BaseRes) Process ¶
Process is the primary function to execute for a particular vertex in the graph.
func (*BaseRes) ProcessExit ¶
func (obj *BaseRes) ProcessExit()
ProcessExit causes the innerWorker to close and waits until it does so.
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) RefreshPending ¶
RefreshPending determines if any previous nodes have a refresh pending here. If this is true, it means I am expected to apply a refresh when I next run.
func (*BaseRes) Reset ¶
func (obj *BaseRes) Reset()
Reset from Setup. These can get called for different vertices in parallel.
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) SetDownstreamRefresh ¶
SetDownstreamRefresh sets the refresh value to any downstream vertices.
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) SetUpstreamRefresh ¶
SetUpstreamRefresh sets the refresh value to any upstream vertices.
func (*BaseRes) Setup ¶
Setup does some work which must happen before the Worker starts. It happens once per Worker startup. It can happen in parallel with other Setup calls, so add locks around any operation that's not thread-safe.
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) Stopped ¶
func (obj *BaseRes) Stopped() <-chan struct{}
Stopped returns a channel that closes when the worker has finished running.
func (*BaseRes) UpdateTimestamp ¶
UpdateTimestamp updates the timestamp and returns the new value.
func (*BaseRes) VarDir ¶
VarDir returns the path to a working directory for the resource. It will try and create the directory first, and return an error if this failed.
type BaseUID ¶
type BaseUID struct { Name string // name and kind are the values of where this is coming from Kind string Reversed *bool // piggyback edge information here }
The BaseUID struct is used to provide a unique resource identifier.
func (*BaseUID) IFF ¶
IFF looks at two UID's and if and only if they are equivalent, returns true. If they are not equivalent, it returns false. Most resources will want to override this method, since it does the important work of actually discerning if two resources are identical in function.
func (*BaseUID) IsReversed ¶
IsReversed is part of the ResUID interface, and true means this resource happens before the generator.
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 Edge ¶
type Edge struct { Name string Notify bool // should we send a refresh notification along this edge? // contains filtered or unexported fields }
Edge is a struct that represents a graph's edge.
func (*Edge) Compare ¶
Compare returns true if two edges are equivalent. Otherwise it returns false.
func (*Edge) SetRefresh ¶
SetRefresh sets the pending refresh status of this edge.
type ExecRes ¶
type ExecRes struct { BaseRes `yaml:",inline"` 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 User string `yaml:"user"` // the (optional) user to use to execute the command Group string `yaml:"group"` // the (optional) group to use to execute the command Output *string // all cmd output, read only, do not set! Stdout *string // the cmd stdout, read only, do not set! Stderr *string // the cmd stderr, read only, do not set! }
ExecRes is an exec resource for running commands.
func (*ExecRes) AutoEdges ¶
AutoEdges returns the AutoEdge interface. In this case the systemd units.
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 ExecResAutoEdges ¶
type ExecResAutoEdges struct {
// contains filtered or unexported fields
}
ExecResAutoEdges holds the state of the auto edge generator.
func (*ExecResAutoEdges) Next ¶
func (obj *ExecResAutoEdges) Next() []ResUID
Next returns the next automatic edge.
func (*ExecResAutoEdges) Test ¶
func (obj *ExecResAutoEdges) Test(input []bool) bool
Test gets results of the earlier Next() call, & returns if we should continue!
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 (usually defaults to name) Dirname string `yaml:"dirname"` // override the path dirname Basename string `yaml:"basename"` // override the path 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?) Owner string `yaml:"owner"` Group string `yaml:"group"` Mode string `yaml:"mode"` Recurse bool `yaml:"recurse"` Force bool `yaml:"force"` // contains filtered or unexported fields }
FileRes is a file and directory resource. Dirs are defined by names ending in a slash.
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 Fs ¶
type Fs interface { //fmt.Stringer // TODO: add this method? afero.Fs // TODO: why doesn't this interface exist in the os pkg? URI() string // returns the URI for this file system //DirExists(path string) (bool, error) //Exists(path string) (bool, error) //FileContainsAnyBytes(filename string, subslices [][]byte) (bool, error) //FileContainsBytes(filename string, subslice []byte) (bool, error) //FullBaseFsPath(basePathFs *BasePathFs, relativePath string) string //GetTempDir(subPath string) string //IsDir(path string) (bool, error) //IsEmpty(path string) (bool, error) //NeuterAccents(s string) string //ReadAll(r io.Reader) ([]byte, error) // not needed ReadDir(dirname string) ([]os.FileInfo, error) ReadFile(filename string) ([]byte, error) //SafeWriteReader(path string, r io.Reader) (err error) TempDir(dir, prefix string) (name string, err error) TempFile(dir, prefix string) (f afero.File, err error) // slightly different from upstream //UnicodeSanitize(s string) string //Walk(root string, walkFn filepath.WalkFunc) error WriteFile(filename string, data []byte, perm os.FileMode) error }
Fs is an interface that represents this file system API that we support. TODO: this should be in the gapi package or elsewhere.
type GraphRes ¶
type GraphRes struct { BaseRes `yaml:",inline"` Graph *pgraph.Graph `yaml:"graph"` // TODO: how do we suck in a graph via yaml? // contains filtered or unexported fields }
GraphRes is a resource that recursively runs a sub graph of resources. TODO: should we name this SubGraphRes instead? TODO: we could also flatten "sub graphs" into the main graph to avoid this, and this could even be done with a graph transformation called flatten, similar to where autogroup and autoedges run. XXX: this resource is not complete, and hasn't even been tested
func (*GraphRes) CheckApply ¶
CheckApply method for Graph resource. XXX: not implemented
func (*GraphRes) 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 (*GraphRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
func (*GraphRes) Watch ¶
Watch is the primary listener for this resource and it outputs events. XXX: should this use mgraph.Start/Pause? if so then what does CheckApply do? XXX: we should probably refactor the core engine to make this work, which will hopefully lead us to a more elegant core that is easier to understand
type GraphUID ¶
type GraphUID struct {
BaseUID
}
GraphUID is a unique representation for a GraphRes object.
type GroupRes ¶
type GroupRes struct { BaseRes `yaml:",inline"` State string `yaml:"state"` // state: exists, absent GID *uint32 `yaml:"gid"` // the group's gid // contains filtered or unexported fields }
GroupRes is a user group resource.
func (*GroupRes) CheckApply ¶
CheckApply method for Group resource.
func (*GroupRes) 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 (*GroupRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
type GroupUID ¶
type GroupUID struct { BaseUID // contains filtered or unexported fields }
GroupUID is the UID struct for GroupRes.
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 (*HostnameRes) CheckApply ¶
func (obj *HostnameRes) CheckApply(apply bool) (checkOK bool, err error)
CheckApply method for Hostname resource.
func (*HostnameRes) Compare ¶
func (obj *HostnameRes) Compare(r 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.
func (*HostnameRes) Watch ¶
func (obj *HostnameRes) Watch() error
Watch is the primary listener for this resource and it outputs events.
type HostnameUID ¶
type HostnameUID struct { BaseUID // contains filtered or unexported fields }
HostnameUID is the UID struct for HostnameRes.
type KVRes ¶
type KVRes struct { BaseRes `yaml:",inline"` // XXX: shouldn't the name be the key? Key string `yaml:"key"` // key to set Value *string `yaml:"value"` // value to set (nil to delete) SkipLessThan bool `yaml:"skiplessthan"` // skip updates as long as stored value is greater SkipCmpStyle KVResSkipCmpStyle `yaml:"skipcmpstyle"` // how to do the less than cmp }
KVRes is a resource which writes a key/value pair into cluster wide storage. It will ensure that the key is set to the requested value. The one exception is that if you use the SkipLessThan parameter, then it will only replace the stored value with the requested value if it is greater than that stored one. This allows the KV resource to be used in fast acting, finite state machines which have monotonically increasing state values that represent progression. The one exception is that when this resource receives a refresh signal, then it will set the value to be the exact one if they are not identical already.
func (*KVRes) CheckApply ¶
CheckApply method for Password resource. Does nothing, returns happy!
func (*KVRes) 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 (*KVRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
type KVResSkipCmpStyle ¶
type KVResSkipCmpStyle int
KVResSkipCmpStyle represents the different styles of comparison when using SkipLessThan.
const ( SkipCmpStyleInt KVResSkipCmpStyle = iota SkipCmpStyleString )
These are the different allowed comparison styles. Most folks will want SkipCmpStyleInt.
type KVUID ¶
type KVUID struct { BaseUID // contains filtered or unexported fields }
KVUID is the UID struct for KVRes.
type MGraph ¶
type MGraph struct { //Graph *pgraph.Graph *pgraph.Graph // wrap a graph, and use its methods directly Data *ResData FastPause bool Debug bool // contains filtered or unexported fields }
MGraph is a meta graph structure used to encapsulate a generic graph structure alongside some non-generic elements.
func (*MGraph) Exit ¶
func (obj *MGraph) Exit()
Exit sends exit events to the graph in a topological sort order.
func (*MGraph) Pause ¶
Pause sends pause events to the graph in a topological sort order. If you set the fastPause argument to true, then it will ask future propagation waves to not run through the graph before exiting, and instead will exit much quicker.
func (*MGraph) SemaUnlock ¶
SemaUnlock releases the list of semaphores in the graph.
func (*MGraph) Start ¶
Start is a main kick to start the graph. It goes through in reverse topological sort order so that events can't hit un-started vertices.
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 Sema []string `yaml:"sema"` // metaparam, list of semaphore ids (id | id:count) }
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 (*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 NonReachabilityGrouper ¶
type NonReachabilityGrouper struct {
// contains filtered or unexported fields
}
NonReachabilityGrouper is the most straight-forward algorithm for grouping. TODO: this algorithm may not be correct in all cases. replace if needed!
type NoopRes ¶
type NoopRes struct { BaseRes `yaml:",inline"` Comment string `lang:"comment" yaml:"comment"` // extra field for example purposes }
NoopRes is a no-op resource that does nothing.
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 (*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 (*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(r 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.
func (*PasswordRes) Watch ¶
func (obj *PasswordRes) Watch() error
Watch is the primary listener for this resource and it outputs events.
type PasswordUID ¶
type PasswordUID struct { BaseUID // contains filtered or unexported fields }
PasswordUID is the UID struct for PasswordRes.
type PkgFileUID ¶
type PkgFileUID struct { BaseUID // contains filtered or unexported fields }
PkgFileUID is the UID struct for PkgRes files.
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 (*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 main UID struct for PkgRes.
type PrintRes ¶
type PrintRes struct { BaseRes `lang:"" yaml:",inline"` Msg string `lang:"msg" yaml:"msg"` // the message to display }
PrintRes is a resource that is useful for printing a message to the screen. It will also display a message when it receives a notification. It supports automatic grouping.
func (*PrintRes) CheckApply ¶
CheckApply method for Print resource. Does nothing, returns happy!
func (*PrintRes) 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 (*PrintRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
type PrintUID ¶
type PrintUID struct { BaseUID // contains filtered or unexported fields }
PrintUID is the UID struct for PrintRes.
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() error // send on channel to signal process() events CheckApply(apply bool) (checkOK bool, err error) AutoEdges() (AutoEdge, error) Compare(Res) bool // FIXME: rename to: `Cmp(Res) error` CollectPattern(string) // XXX: temporary until Res collection is more advanced }
Res is the minimum interface you need to implement to define a new resource.
func NewNamedResource ¶
NewNamedResource returns an empty resource object from a registered kind. It also sets the name. It is a wrapper around NewResource. It also errors if the name is empty.
func NewResource ¶
NewResource returns an empty resource object from a registered kind. It errors if the resource kind doesn't exist.
type ResData ¶
type ResData struct { Hostname string // uuid for the host //Noop bool Converger converger.Converger Prometheus *prometheus.Prometheus World World Prefix string // the prefix to be used for the pgraph namespace Debug bool Logf func(format string, v ...interface{}) }
ResData is the set of input values passed into the pgraph for the resources.
type ResState ¶
type ResState int
The ResState type represents the current activity state of each resource.
type ResUID ¶
type ResUID interface { GetName() string GetKind() string fmt.Stringer // String() string IFF(ResUID) bool IsReversed() 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 ResourceSlice ¶
type ResourceSlice []Res
ResourceSlice is a linear list of resources. It can be sorted.
func (ResourceSlice) Len ¶
func (rs ResourceSlice) Len() int
func (ResourceSlice) Less ¶
func (rs ResourceSlice) Less(i, j int) bool
func (ResourceSlice) Swap ¶
func (rs ResourceSlice) Swap(i, j int)
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 SentinelErr ¶
type SentinelErr struct {
// contains filtered or unexported fields
}
SentinelErr is a sentinal as an error type that wraps an arbitrary error.
func (*SentinelErr) Error ¶
func (obj *SentinelErr) Error() string
Error is the required method to fulfill the error type.
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 Session bool `yaml:"session"` // user session (true) or system? }
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 TestRes ¶
type TestRes struct { BaseRes `lang:"" yaml:",inline"` Bool bool `lang:"bool" yaml:"bool"` Str string `lang:"str" yaml:"str"` // can't name it String because of String() Int int `lang:"int" yaml:"int"` Int8 int8 `lang:"int8" yaml:"int8"` Int16 int16 `lang:"int16" yaml:"int16"` Int32 int32 `lang:"int32" yaml:"int32"` Int64 int64 `lang:"int64" yaml:"int64"` Uint uint `lang:"uint" yaml:"uint"` Uint8 uint8 `lang:"uint8" yaml:"uint8"` Uint16 uint16 `lang:"uint16" yaml:"uint16"` Uint32 uint32 `lang:"uint32" yaml:"uint32"` Uint64 uint64 `lang:"uint64" yaml:"uint64"` //Uintptr uintptr `yaml:"uintptr"` Byte byte `lang:"byte" yaml:"byte"` // alias for uint8 Rune rune `lang:"rune" yaml:"rune"` // alias for int32, represents a Unicode code point Float32 float32 `lang:"float32" yaml:"float32"` Float64 float64 `lang:"float64" yaml:"float64"` Complex64 complex64 `lang:"complex64" yaml:"complex64"` Complex128 complex128 `lang:"complex128" yaml:"complex128"` BoolPtr *bool `lang:"boolptr" yaml:"bool_ptr"` StringPtr *string `lang:"stringptr" yaml:"string_ptr"` // TODO: tag name? Int64Ptr *int64 `lang:"int64ptr" yaml:"int64ptr"` Int8Ptr *int8 `lang:"int8ptr" yaml:"int8ptr"` Uint8Ptr *uint8 `lang:"uint8ptr" yaml:"uint8ptr"` // probably makes no sense, but is legal Int8PtrPtrPtr ***int8 `lang:"int8ptrptrptr" yaml:"int8ptrptrptr"` SliceString []string `lang:"slicestring" yaml:"slicestring"` MapIntFloat map[int64]float64 `lang:"mapintfloat" yaml:"mapintfloat"` MixedStruct struct { // contains filtered or unexported fields } `lang:"mixedstruct" yaml:"mixedstruct"` Interface interface{} `lang:"interface" yaml:"interface"` AnotherStr string `lang:"anotherstr" yaml:"anotherstr"` ValidateBool bool `lang:"validatebool" yaml:"validate_bool"` // set to true to cause a validate error ValidateError string `lang:"validateerror" yaml:"validate_error"` // set to cause a validate error AlwaysGroup bool `lang:"alwaysgroup" yaml:"always_group"` // set to true to cause auto grouping CompareFail bool `lang:"comparefail" yaml:"compare_fail"` // will compare fail? Comment string `lang:"comment" yaml:"comment"` }
TestRes is a resource that is mostly harmless and is used for internal tests.
func (*TestRes) CheckApply ¶
CheckApply method for Test resource. Does nothing, returns happy!
func (*TestRes) 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 (*TestRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
type TestUID ¶
type TestUID struct { BaseUID // contains filtered or unexported fields }
TestUID is the UID struct for TestRes.
type TimerRes ¶
type TimerRes struct { BaseRes `yaml:",inline"` Interval uint32 `yaml:"interval"` // interval between runs in seconds // contains filtered or unexported fields }
TimerRes is a timer resource for time based events. It outputs an event every interval seconds.
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 UserRes ¶
type UserRes struct { BaseRes `yaml:",inline"` State string `yaml:"state"` // state: exists, absent UID *uint32 `yaml:"uid"` // uid must be unique unless AllowDuplicateUID is true GID *uint32 `yaml:"gid"` // gid of the user's primary group Group *string `yaml:"group"` // name of the user's primary group Groups []string `yaml:"groups"` // list of supplemental groups HomeDir *string `yaml:"homedir"` // path to the user's home directory AllowDuplicateUID bool `yaml:"allowduplicateuid"` // allow duplicate uid // contains filtered or unexported fields }
UserRes is a user account resource.
func (*UserRes) AutoEdges ¶
AutoEdges returns edges from the user resource to each group found in its definition. The groups can be in any of the three applicable fields (GID, Group and Groups.) If the user exists, reversed ensures the edge goes from group to user, and if the user is absent the edge goes from user to group. This ensures that we don't add users to groups that don't exist or delete groups before we delete their members.
func (*UserRes) CheckApply ¶
CheckApply method for User resource.
func (*UserRes) 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 (*UserRes) UnmarshalYAML ¶
UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.
type UserResAutoEdges ¶
type UserResAutoEdges struct { UIDs []ResUID // contains filtered or unexported fields }
UserResAutoEdges holds the state of the auto edge generator.
func (*UserResAutoEdges) Next ¶
func (obj *UserResAutoEdges) Next() []ResUID
Next returns the next automatic edge.
func (*UserResAutoEdges) Test ¶
func (obj *UserResAutoEdges) Test(input []bool) bool
Test gets results of the earlier Next() call, & returns if we should continue.
type UserUID ¶
type UserUID struct { BaseUID // contains filtered or unexported fields }
UserUID is the UID struct for UserRes.
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"` MaxCPUs uint `yaml:"maxcpus"` 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"` HotCPUs bool `yaml:"hotcpus"` // allow hotplug of cpus? // FIXME: values here should be enum's! RestartOnDiverge string `yaml:"restartondiverge"` // restart policy: "ignore", "ifneeded", "error" RestartOnRefresh bool `yaml:"restartonrefresh"` // restart on refresh? // 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 (*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) 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.
type World ¶
type World interface { ResWatch() chan error ResExport([]Res) error // FIXME: should this method take a "filter" data struct instead of many args? ResCollect(hostnameFilter, kindFilter []string) ([]Res, error) StrWatch(namespace string) chan error StrIsNotExist(error) bool StrGet(namespace string) (string, error) StrSet(namespace, value string) error StrDel(namespace string) error // XXX: add the exchange primitives in here directly? StrMapWatch(namespace string) chan error StrMapGet(namespace string) (map[string]string, error) StrMapSet(namespace, value string) error StrMapDel(namespace string) error Scheduler(namespace string, opts ...scheduler.Option) (*scheduler.Result, error) Fs(uri string) (Fs, error) }
World is an interface to the rest of the different graph state. It allows the GAPI to store state and exchange information throughout the cluster. It is the interface each machine uses to communicate with the rest of the world.
Source Files ¶
- actions.go
- augeas.go
- autoedge.go
- autogroup.go
- aws_ec2.go
- edge.go
- exec.go
- file.go
- graph.go
- group.go
- hostname.go
- interfaces.go
- kv.go
- metaparams.go
- mgraph.go
- msg.go
- noop.go
- nspawn.go
- password.go
- pkg.go
- print.go
- refresh.go
- resources.go
- semaphore.go
- sendrecv.go
- svc.go
- test.go
- timer.go
- uid.go
- user.go
- util.go
- virt.go
Directories ¶
Path | Synopsis |
---|---|
Package packagekit provides an interface to interact with packagekit.
|
Package packagekit provides an interface to interact with packagekit. |