resources

package
v0.0.0-...-2561dba Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: GPL-3.0 Imports: 93 Imported by: 8

Documentation

Overview

Package resources contains the implementations of all the core resources.

Index

Constants

View Source
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"
)
View Source
const (
	// OnCalendar is a systemd-timer trigger, whose behaviour is defined in
	// 'man systemd-timer', and whose format is defined in the 'Calendar
	// Events' section of 'man systemd-time'.
	OnCalendar = "OnCalendar"
	// OnActiveSec is a systemd-timer trigger, whose behaviour is defined in
	// 'man systemd-timer', and whose format is a time span as defined in
	// 'man systemd-time'.
	OnActiveSec = "OnActiveSec"
	// OnBootSec is a systemd-timer trigger, whose behaviour is defined in
	// 'man systemd-timer', and whose format is a time span as defined in
	// 'man systemd-time'.
	OnBootSec = "OnBootSec"
	// OnStartupSec is a systemd-timer trigger, whose behaviour is defined in
	// 'man systemd-timer', and whose format is a time span as defined in
	// 'man systemd-time'.
	OnStartupSec = "OnStartupSec"
	// OnUnitActiveSec is a systemd-timer trigger, whose behaviour is defined
	// in 'man systemd-timer', and whose format is a time span as defined in
	// 'man systemd-time'.
	OnUnitActiveSec = "OnUnitActiveSec"
	// OnUnitInactiveSec is a systemd-timer trigger, whose behaviour is defined
	// in 'man systemd-timer', and whose format is a time span as defined in
	// 'man systemd-time'.
	OnUnitInactiveSec = "OnUnitInactiveSec"
)
View Source
const (
	// ContainerRunning is the running container state.
	ContainerRunning = "running"
	// ContainerStopped is the stopped container state.
	ContainerStopped = "stopped"
	// ContainerRemoved is the removed container state.
	ContainerRemoved = "removed"
)
View Source
const (
	// KindFile is the kind string used to identify this resource.
	KindFile = "file"
	// ParamFileState is the name of the state field parameter.
	ParamFileState = "state"
	// FileStateExists is the string that represents that the file should be
	// present.
	FileStateExists = "exists"
	// FileStateAbsent is the string that represents that the file should
	// not exist.
	FileStateAbsent = "absent"
	// FileStateUndefined means the file state has not been specified.
	// TODO: consider moving to *string and express this state as a nil.
	FileStateUndefined = ""

	// FileModeAllowAssign specifies whether we only use ugo=rwx style
	// assignment (false) or if we also allow ugo+-rwx style too (true). I
	// think that it's possibly illogical to allow imperative mode
	// specifiers in a declarative language, so let's leave it off for now.
	FileModeAllowAssign = false
)
View Source
const (
	// KindFirewalld is the kind string used to identify this resource.
	KindFirewalld = "firewalld"

	// ParamFirewalldState is the name of the state field parameter.
	ParamFirewalldState = "state"

	// FirewalldStateExists is the string that represents that the service,
	// or port, or other setting should be present.
	FirewalldStateExists = "exists"

	// FirewalldStateAbsent is the string that represents that the service,
	// or port, or other setting should not exist.
	FirewalldStateAbsent = "absent"

	// FirewalldStateUndefined means the file state has not been specified.
	// TODO: consider moving to *string and express this state as a nil.
	FirewalldStateUndefined = ""

	// ErrInvalidZone is a firewalld error from dbus.
	ErrInvalidZone = engine.Error("invalid zone")

	// ErrInvalidPort is a firewalld error from dbus.
	ErrInvalidPort = engine.Error("invalid port")

	// ErrInvalidService is a firewalld error from dbus.
	ErrInvalidService = engine.Error("invalid service")

	// ErrInvalidProtocol is a firewalld error from dbus.
	ErrInvalidProtocol = engine.Error("invalid protocol")

	// ErrInvalidCommand is a firewalld error from dbus.
	ErrInvalidCommand = engine.Error("invalid command")

	// ErrMissingProtocol is a firewalld error from dbus.
	ErrMissingProtocol = engine.Error("missing protocol")

	// ErrAlreadyEnabled is a firewalld error from dbus.
	ErrAlreadyEnabled = engine.Error("already enabled")

	// ErrNotEnabled is a firewalld error from dbus.
	ErrNotEnabled = engine.Error("not enabled")
)
View Source
const (
	// HetznerStateUndefined leaves the state undefined by default. This state
	// is always treated as converged. Changes to other params are only applied
	// when the server is in a state that is compatible with the operations
	// needed to make that change.
	HetznerStateUndefined = ""
	// HetznerStateExists indicates that the server must exist, without
	// differentiation between "off", "running" or any transient states.
	// If the server was absent, a new server is created in "off" state, with
	// one exception: if the last observed state before a rebuild was "running"
	// or "starting", rebuildServer will set the new server to "running".
	HetznerStateExists = "exists"
	// HetznerStateRunning indicates that the server must be powered on. If the
	// server was absent, a new server is created in "running" state.
	HetznerStateRunning = "running"
	// HetznerStateOff indicates that the server must be powered off. If the
	// server was absent, a new server is created in "off" state.
	HetznerStateOff = "off"
	// HetznerStateAbsent indicates that the server must be deleted/absent. If
	// the server already existed, it is deleted. Note that this deletion is
	// always executed if the "absent" state is explicitly specified!
	HetznerStateAbsent = "absent"

	// HetznerAllowRebuildError blocks any server rebuild requests in CheckApply
	// and exits with an error. These rebuild requests occur when other resource
	// params require a destructive rebuild to reach resource convergence. The
	// error option is used by default to prevent unexpected server deletions.
	HetznerAllowRebuildError = ""
	// HetznerAllowRebuildIgnore blocks any server rebuild requests in
	// CheckApply, but does not throw any errors. Instead, CheckApply must skip
	// this rebuild, and continue further steps if possible. Use this option to
	// prevent unexpected server deletions, without disrupting the mcl script.
	HetznerAllowRebuildIgnore = "ignore"
	// HetznerAllowRebuildIfNeeded allows server rebuilds within CheckApply.
	// This is needed when the specified serverspecs are not (yet) aligned with
	// the active instance. Use this option only if you are sure that you are
	// not destroying any critical data or services!
	HetznerAllowRebuildIfNeeded = "ifneeded"

	// HetznerServerRescueDisabled disables rescue mode by default.
	HetznerServerRescueDisabled = ""
	// HetznerServerRescueTypeLinux32 is used to enable rescue mode with a
	// linux32 image type.
	HetznerServerRescueTypeLinux32 = "linux32"
	// HetznerServerRescueTypeLinux64 is used to enable rescue mode with a
	// linux64 image type.
	HetznerServerRescueTypeLinux64 = "linux64"
	// HetznerServerRescueTypeFreeBSD64 is used to enable rescue mode with a
	// freebsd64 image type.
	HetznerServerRescueTypeFreeBSD64 = "freebsd64"

	// HetznerPollLimit sets a lower limit on polling interval in seconds.
	// Since the Hetzner API supports requests at up to 3600 requests per hour,
	// this limit is set to prevent rate limit errors in long term operation.
	// NOTE: polling the same Hetzner project from multiple clients will require
	// a larger polling interval to prevent the same rate limit error, since
	// these requests all add to the query count of their shared project. It is
	// recommended to use a polling interval of at least N seconds, with N the
	// number of active hetzner:vm instances of the same project.
	// NOTE: high rates of change to other params will require additional API
	// queries at CheckApply. Increase the polling interval again to prevent
	// rate limit errors if frequent updates are expected.
	HetznerPollLimit = 1

	// HetznerWaitIntervalLimit sets a lower limit on wait intervals in seconds.
	// High request rates are allowed, but risk causing rate limit errors.
	HetznerWaitIntervalLimit = 0

	// HetznerWaitIntervalDefault sets a default wait interval in seconds.
	// NOTE: use larger intervals when using many resources under the same
	// Hetzner project, or when expecting consistently high rates of change to
	// other resource parameters.
	HetznerWaitIntervalDefault = 5

	// HetznerWaitTimeoutDefault sets a default timeout limit in seconds.
	HetznerWaitTimeoutDefault = 60 * 5
)
View Source
const (
	// KindNet is the kind string used to identify this resource.
	KindNet = "net"

	// ParamNetState is the name of the state field parameter.
	ParamNetState = "state"

	// NetStateUp is the string that represents that the net state should be
	// up. This is the on interface state.
	NetStateUp = "up"

	// NetStateDown is the string that represents that the net state should
	// be down. This is the off interface state.
	NetStateDown = "down"

	// NetStateUndefined means the net state has not been specified.
	// TODO: consider moving to *string and express this state as a nil.
	NetStateUndefined = ""

	// IfacePrefix is the prefix used to identify unit files for managed
	// links.
	IfacePrefix = "mgmt-"
)
View Source
const (
	// PkgStateInstalled is the string that represents that the package
	// should be installed.
	PkgStateInstalled = "installed"

	// PkgStateUninstalled is the string that represents that the package
	// should be uninstalled.
	PkgStateUninstalled = "uninstalled"

	// PkgStateNewest is the string that represents that the package should
	// be installed in the newest available version.
	PkgStateNewest = "newest"
)
View Source
const (
	SystemdUnitModeReplace            = "replace"
	SystemdUnitModeFail               = "fail"
	SystemdUnitModeIsolate            = "isolate"
	SystemdUnitModeIgnoreDependencies = "ignore-dependencies"
	SystemdUnitModeIgnoreRequirements = "ignore-requirements"
)

The SystemdUnitMode* constants do the following from the docs:

The mode needs to be one of replace, fail, isolate, ignore-dependencies, ignore-requirements. If "replace" the call will start the unit and its dependencies, possibly replacing already queued jobs that conflict with this. If "fail" the call will start the unit and its dependencies, but will fail if this would change an already queued job. If "isolate" the call will start the unit in question and terminate all units that aren't dependencies of it. If "ignore-dependencies" it will start a unit but ignore all its dependencies. If "ignore-requirements" it will start a unit but only ignore the requirement dependencies. It is not recommended to make use of the latter two options.

View Source
const (
	SystemdUnitResultDone       = "done"
	SystemdUnitResultCanceled   = "canceled"
	SystemdUnitResultTimeout    = "timeout"
	SystemdUnitResultFailed     = "failed"
	SystemdUnitResultDependency = "dependency"
	SystemdUnitResultSkipped    = "skipped"
)

The SystemdUnitResult* constants do the following from the docs:

If the provided channel is non-nil, a result string will be sent to it upon job completion: one of done, canceled, timeout, failed, dependency, skipped. "done" indicates successful execution of a job. "canceled" indicates that a job has been canceled before it finished execution. "timeout" indicates that the job timeout was reached. "failed" indicates that the job failed. "dependency" indicates that a job this job has been depending on failed and the job hence has been removed too. "skipped" indicates that a job was skipped because it didn't apply to the units current state.

View Source
const (
	// SysctlConfDir is the directory to store persistent sysctl files in.
	SysctlConfDir = "/etc/sysctl.d/"

	// SysctlConfPrefix is the prefix we prepend to any automatically chosen
	// filename that we put in the /etc/sysctl.d/ directory.
	// TODO: What prefix should we use if any?
	SysctlConfPrefix = "99-"
)
View Source
const (
	// TftpDefaultTimeout is the default timeout in seconds for server
	// connections.
	TftpDefaultTimeout = 5

	// TftpUseSecureJoin specifies that we should add in a "secure join" lib
	// so that we avoid the ../../etc/passwd and symlink problems.
	TftpUseSecureJoin = true
)
View Source
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
)
View Source
const (
	// VirtBuilderCmdPath is the path to the virt-builder binary. For now,
	// this is the same on any Linux machine, so it's a constant.
	VirtBuilderCmdPath = "/usr/bin/virt-builder"

	// VirtBuilderBinDir is the directory to copy our binary to in the vm.
	VirtBuilderBinDir = "/usr/local/bin/"
)
View Source
const (
	// DHCPDefaultLeaseTime is the default lease time used when one was not
	// specified explicitly.
	DHCPDefaultLeaseTime = "10m" // common default from dhcpd
)
View Source
const (
	// HTTPUseSecureJoin specifies that we should add in a "secure join" lib
	// so that we avoid the ../../etc/passwd and symlink problems.
	HTTPUseSecureJoin = true
)
View Source
const (
	// NS is a namespace for augeas operations
	NS = "Xmgmt"
)

Variables

View Source
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

View Source
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 InstallOnePackage

func InstallOnePackage(ctx context.Context, name string) error

InstallOnePackage is a helper function which uses the minimum resource mechanics to install a single package. Keep this up-to-date with the resource internals since we may make some concessions in this helper function in that we don't call the full API.

func ReturnSvcInFileList

func ReturnSvcInFileList(fileList []string) []string

ReturnSvcInFileList returns a list of svc names for matches like: `/usr/lib/systemd/system/*.service`.

Types

type AugeasRes

type AugeasRes struct {
	traits.Base // add the base methods without re-implementation

	// File is the path to the file targeted by this resource.
	File string `lang:"file" 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 `lang:"lens" 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 `lang:"sets" 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

func (obj *AugeasRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for Augeas resource.

func (*AugeasRes) Cleanup

func (obj *AugeasRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*AugeasRes) Cmp

func (obj *AugeasRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*AugeasRes) Default

func (obj *AugeasRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*AugeasRes) Init

func (obj *AugeasRes) Init(init *engine.Init) error

Init initializes the resource.

func (*AugeasRes) UIDs

func (obj *AugeasRes) UIDs() []engine.ResUID

UIDs includes all params to make a unique identification of this object.

func (*AugeasRes) UnmarshalYAML

func (obj *AugeasRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*AugeasRes) Validate

func (obj *AugeasRes) Validate() error

Validate if the params passed in are valid data.

func (*AugeasRes) Watch

func (obj *AugeasRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events. This was taken from the File resource. FIXME: DRY - This is taken from the file resource

type AugeasSet

type AugeasSet struct {
	Path  string `lang:"path" yaml:"path"`   // The relative path to the value to be changed.
	Value string `lang:"value" yaml:"value"` // The value to be set on the given Path.
}

AugeasSet represents a key/value pair of settings to be applied.

func (*AugeasSet) Cmp

func (obj *AugeasSet) Cmp(set *AugeasSet) error

Cmp compares this set with another one.

type AugeasUID

type AugeasUID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

AugeasUID is the UID struct for AugeasRes.

type AwsEc2Res

type AwsEc2Res struct {
	traits.Base // add the base methods without re-implementation
	traits.Sendable

	// State must be running, stopped, or terminated.
	State string `lang:"state" yaml:"state"`

	// Region must match one of the AwsRegions. This list is static at the
	// moment.
	Region string `lang:"region" yaml:"region"`

	// Type of ec2 instance, eg: t2.micro for example.
	Type string `lang:"type" yaml:"type"`

	// ImageID to use, and note that it must be available on the chosen
	// region.
	ImageID string `lang:"imageid" yaml:"imageid"`

	// WatchEndpoint is the public url of the sns endpoint, eg:
	// http://server:12345/ for example.
	WatchEndpoint string `lang:"watchendpoint" yaml:"watchendpoint"`

	// WatchListenAddr is the local address or port that the sns listens on,
	// eg: 10.0.0.0:23456 or 23456.
	WatchListenAddr string `lang:"watchlistenaddr" yaml:"watchlistenaddr"`

	// 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 `lang:"erroronmalformedpost" 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 `lang:"userdata" 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

func (obj *AwsEc2Res) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for AwsEc2 resource.

func (*AwsEc2Res) Cleanup

func (obj *AwsEc2Res) Cleanup() error

Cleanup cleans up when we're done. This is needed to delete some of the AWS objects created for the SNS endpoint.

func (*AwsEc2Res) Cmp

func (obj *AwsEc2Res) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*AwsEc2Res) Default

func (obj *AwsEc2Res) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*AwsEc2Res) Init

func (obj *AwsEc2Res) Init(init *engine.Init) error

Init initializes the resource.

func (*AwsEc2Res) UIDs

func (obj *AwsEc2Res) UIDs() []engine.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 (*AwsEc2Res) UnmarshalYAML

func (obj *AwsEc2Res) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*AwsEc2Res) Validate

func (obj *AwsEc2Res) Validate() error

Validate if the params passed in are valid data.

func (*AwsEc2Res) Watch

func (obj *AwsEc2Res) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type AwsEc2UID

type AwsEc2UID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

AwsEc2UID is the UID struct for AwsEc2Res.

type CDRomDevice

type CDRomDevice struct {
	Source string `lang:"source" yaml:"source"`
	Type   string `lang:"type" yaml:"type"`
}

CDRomDevice represents a CDRom device that is attached to the virt machine.

func (*CDRomDevice) Cmp

func (obj *CDRomDevice) Cmp(dev *CDRomDevice) error

Cmp compares two CDRomDevice's and returns an error if they are not equivalent.

func (*CDRomDevice) GetXML

func (obj *CDRomDevice) GetXML(idx int) string

GetXML returns the XML representation of this device.

type ConfigEtcdRes

type ConfigEtcdRes struct {
	traits.Base // add the base methods without re-implementation

	// IdealClusterSize is the requested minimum size of the cluster. If you
	// set this to zero, it will cause a cluster wide shutdown if
	// AllowSizeShutdown is true. If it's not true, then it will cause a
	// validation error.
	IdealClusterSize uint16 `lang:"idealclustersize"`
	// AllowSizeShutdown is a required safety flag that you must set to true
	// if you want to allow causing a cluster shutdown by setting
	// IdealClusterSize to zero.
	AllowSizeShutdown bool `lang:"allow_size_shutdown"`
	// contains filtered or unexported fields
}

ConfigEtcdRes is a resource that sets mgmt's etcd configuration.

func (*ConfigEtcdRes) CheckApply

func (obj *ConfigEtcdRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for Noop resource. Does nothing, returns happy!

func (*ConfigEtcdRes) Cleanup

func (obj *ConfigEtcdRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*ConfigEtcdRes) Cmp

func (obj *ConfigEtcdRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*ConfigEtcdRes) Default

func (obj *ConfigEtcdRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*ConfigEtcdRes) Init

func (obj *ConfigEtcdRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*ConfigEtcdRes) Interrupt

func (obj *ConfigEtcdRes) Interrupt() error

Interrupt is called to ask the execution of this resource to end early.

func (*ConfigEtcdRes) UnmarshalYAML

func (obj *ConfigEtcdRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*ConfigEtcdRes) Validate

func (obj *ConfigEtcdRes) Validate() error

Validate if the params passed in are valid data.

func (*ConfigEtcdRes) Watch

func (obj *ConfigEtcdRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type ConsulKVRes

type ConsulKVRes struct {
	traits.Base

	// Key is the name of the key. Defaults to the name of the resource.
	Key string `lang:"key" yaml:"key"`

	// Value is the value for the key.
	Value string `lang:"value" yaml:"value"`

	// Scheme is the URI scheme for the Consul server. Default: http.
	Scheme string `lang:"scheme" yaml:"scheme"`

	// Address is the address of the Consul server. Default: 127.0.0.1:8500.
	Address string `lang:"address" yaml:"address"`

	// Token is used to provide an ACL token to use for this resource.
	Token string `lang:"token" yaml:"token"`
	// contains filtered or unexported fields
}

ConsulKVRes is a resource that writes a value into a Consul datastore. The name of the resource can either be the key name, or the concatenation of the server address and the key name: http://127.0.0.1:8500/my-key. If the param keys are specified, then those are used. If the Name cannot be properly parsed by url.Parse, then it will be considered as the Key's value. If the Key is specified explicitly, then we won't use anything from the Name.

func (*ConsulKVRes) CheckApply

func (obj *ConsulKVRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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 (*ConsulKVRes) Cleanup

func (obj *ConsulKVRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*ConsulKVRes) Cmp

func (obj *ConsulKVRes) Cmp(r engine.Res) error

Cmp compares two resources and return if they are equivalent.

func (*ConsulKVRes) Default

func (obj *ConsulKVRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*ConsulKVRes) Init

func (obj *ConsulKVRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*ConsulKVRes) Validate

func (obj *ConsulKVRes) Validate() error

Validate if the params passed in are valid data.

func (*ConsulKVRes) Watch

func (obj *ConsulKVRes) Watch(ctx context.Context) error

Watch is the listener and main loop for this resource and it outputs events.

type CronRes

type CronRes struct {
	traits.Base
	traits.Edgeable
	traits.Recvable
	traits.Refreshable // needed because we embed a svc res

	// Unit is the name of the systemd service unit. It is only necessary to
	// set if you want to specify a service with a different name than the
	// resource.
	Unit string `lang:"unit" yaml:"unit"`

	// State must be 'exists' or 'absent'.
	State string `lang:"state" yaml:"state"`

	// Startup specifies what should happen on startup. Values can be:
	// enabled, disabled, and undefined (empty string). We default to
	// enabled.
	Startup string `lang:"startup" yaml:"startup"`

	// Session, if true, creates the timer as the current user, rather than
	// root. The service it points to must also be a user unit. It defaults
	// to false.
	Session bool `lang:"session" yaml:"session"`

	// Trigger is the type of timer. Valid types are 'OnCalendar',
	// 'OnActiveSec'. 'OnBootSec'. 'OnStartupSec'. 'OnUnitActiveSec', and
	// 'OnUnitInactiveSec'. For more information see 'man systemd.timer'.
	Trigger string `lang:"trigger" yaml:"trigger"`

	// Time must be used with all triggers. For 'OnCalendar', it must be in
	// the format defined in 'man systemd-time' under the heading 'Calendar
	// Events'. For all other triggers, time should be a valid time span as
	// defined in 'man systemd-time'
	Time string `lang:"time" yaml:"time"`

	// AccuracySec is the accuracy of the timer in systemd-time time span
	// format. It defaults to one minute.
	AccuracySec string `lang:"accuracysec" yaml:"accuracysec"`

	// RandomizedDelaySec delays the timer by a randomly selected, evenly
	// distributed amount of time between 0 and the specified time value.
	// The value must be a valid systemd-time time span.
	RandomizedDelaySec string `lang:"randomizeddelaysec" yaml:"randomizeddelaysec"`

	// Persistent, if true, means the time when the service unit was last
	// triggered is stored on disk. When the timer is activated, the service
	// unit is triggered immediately if it would have been triggered at
	// least once during the time when the timer was inactive. It defaults
	// to false.
	Persistent bool `lang:"persistent" yaml:"persistent"`

	// WakeSystem, if true, will cause the system to resume from suspend,
	// should it be suspended and if the system supports this. It defaults
	// to false.
	WakeSystem bool `lang:"wakesystem" yaml:"wakesystem"`

	// RemainAfterElapse, if true, means an elapsed timer will stay loaded,
	// and its state remains queriable. If false, an elapsed timer unit that
	// cannot elapse anymore is unloaded. It defaults to true.
	RemainAfterElapse bool `lang:"remainafterelapse" yaml:"remainafterelapse"`
	// contains filtered or unexported fields
}

CronRes is a systemd-timer cron resource. TODO: If we want to have an actual `crond` resource, name it LegacyCron.

func (*CronRes) AutoEdges

func (obj *CronRes) AutoEdges() (engine.AutoEdge, error)

AutoEdges returns the AutoEdge interface.

func (*CronRes) CheckApply

func (obj *CronRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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 (*CronRes) Cleanup

func (obj *CronRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*CronRes) Cmp

func (obj *CronRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*CronRes) Default

func (obj *CronRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*CronRes) Init

func (obj *CronRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*CronRes) UIDs

func (obj *CronRes) UIDs() []engine.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 (*CronRes) UnitFilePath

func (obj *CronRes) UnitFilePath() (string, error)

UnitFilePath returns the path to the systemd-timer unit file.

func (*CronRes) UnmarshalYAML

func (obj *CronRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*CronRes) Validate

func (obj *CronRes) Validate() error

Validate if the params passed in are valid data.

func (*CronRes) Watch

func (obj *CronRes) Watch(ctx context.Context) error

Watch for state changes and sends a message to the bus if there is a change.

type CronUID

type CronUID 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.
	engine.BaseUID
	// contains filtered or unexported fields
}

CronUID is a unique resource identifier.

func (*CronUID) IFF

func (obj *CronUID) IFF(uid engine.ResUID) bool

IFF aka if and only if they are equivalent, return true. If not, false.

type DHCPHostRes

type DHCPHostRes struct {
	traits.Base // add the base methods without re-implementation
	//traits.Edgeable // XXX: add autoedge support
	traits.Groupable // can be grouped into DHCPServerRes

	// Server is the name of the dhcp server resource to group this into. If
	// it is omitted, and there is only a single dhcp resource, then it will
	// be grouped into it automatically. If there is more than one main dhcp
	// resource being used, then the grouping behaviour is *undefined* when
	// this is not specified, and it is not recommended to leave this blank!
	Server string `lang:"server" yaml:"server"`

	// Mac is the mac address of the host in lower case and separated with
	// colons.
	Mac string `lang:"mac" yaml:"mac"`

	// IP is the IPv4 address with the CIDR suffix. The suffix is required
	// because it specifies the netmask to be used in the DHCPv4 protocol.
	// For example, you might specify 192.0.2.42/24 which represents a mask
	// of 255.255.255.0 that will be sent.
	IP string `lang:"ip" yaml:"ip"`

	// NBP is the network boot program URL. This is used for the tftp server
	// name and the boot file name. For example, you might use:
	// tftp://192.0.2.13/pxelinux.0 for a common bios, pxe boot setup. Note
	// that the "scheme" prefix is required, and that it's impossible to
	// specify a file that doesn't begin with a leading slash. If you wish
	// to specify a "root less" file (common for legacy tftp setups) then
	// you can use this feature in conjunction with the NBPPath parameter.
	// For DHCPv4, the scheme must be "tftp".
	NBP string `lang:"nbp" yaml:"nbp"`

	// NBPPath overrides the path that is sent for the nbp protocols. By
	// default it is taken from parsing a URL in NBP, but this can override
	// that. This is useful if you require a path that doesn't start with a
	// slash. This is sometimes desirable for legacy tftp setups.
	NBPPath string `lang:"nbp_path" yaml:"nbp_path"`
	// contains filtered or unexported fields
}

DHCPHostRes is a representation of a static host assignment in DHCP.

func (*DHCPHostRes) CheckApply

func (obj *DHCPHostRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply never has anything to do for this resource, so it always succeeds.

func (*DHCPHostRes) Cleanup

func (obj *DHCPHostRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*DHCPHostRes) Cmp

func (obj *DHCPHostRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*DHCPHostRes) Default

func (obj *DHCPHostRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*DHCPHostRes) Init

func (obj *DHCPHostRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*DHCPHostRes) UnmarshalYAML

func (obj *DHCPHostRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*DHCPHostRes) Validate

func (obj *DHCPHostRes) Validate() error

Validate checks if the resource data structure was populated correctly.

func (*DHCPHostRes) Watch

func (obj *DHCPHostRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events. This particular one does absolutely nothing but block until we've received a done signal.

type DHCPRangeRes

type DHCPRangeRes struct {
	traits.Base // add the base methods without re-implementation
	//traits.Edgeable // XXX: add autoedge support?
	traits.Groupable // can be grouped into DHCPServerRes

	// Server is the name of the dhcp server resource to group this into. If
	// it is omitted, and there is only a single dhcp resource, then it will
	// be grouped into it automatically. If there is more than one main dhcp
	// resource being used, then the grouping behaviour is *undefined* when
	// this is not specified, and it is not recommended to leave this blank!
	Server string `lang:"server" yaml:"server"`

	// Network is the network number and cidr to determine the range. For
	// example, the common network range of 192.168.42.1 to 192.168.42.255
	// should have a network field here of 192.168.42.0/24. You can either
	// specify this field or `from` and `to`, but not a different
	// combination. If you don't specify any of these fields, then the
	// resource name will be parsed as if it was used here.
	Network string `lang:"network" yaml:"network"`

	// From is the start address in the range inclusive. If it is specified
	// in cidr notation, then the `mask` field must not be used. Otherwise
	// it must be used. In both situations the cidr or mask must be
	// consistent with the `to` field. If this field is used, you must not
	// use the `network` field.
	From string `lang:"from" yaml:"from"`

	// To is the end address in the range inclusive. If it is specified in
	// cidr notation, then the `mask` field must not be used. Otherwise it
	// must be used. In both situations the cidr or mask must be consistent
	// with the `from` field. If this field is used, you must not use the
	// `network` field.
	To string `lang:"to" yaml:"to"`

	// Mask is the cidr or netmask of ip addresses in the specified range.
	// This field must only be used if both `from` and `to` are specified,
	// and if neither of them specify a cidr suffix. If neither do, then the
	// mask here can be in either dotted format or, preferably, in cidr
	// format by starting with a slash.
	Mask string `lang:"mask" yaml:"mask"`

	// Skip is a list ip's in either cidr or standalone representation which
	// will be skipped and not allocated.
	Skip []string `lang:"skip" yaml:"skip"`

	// Persist should be true if you want to persist the lease information
	// to disk so that a new (or changed) invocation of this resource with
	// the same name, will regain that existing initial state at startup.
	// TODO: Add a new param to persist the data to etcd in the world API so
	// that we could have redundant dhcp servers which share the same state.
	// This would require having a distributed allocator through etcd too!
	// TODO: Consider adding a new param to erase the persisted record
	// database if any field param changes, as opposed to just looking at
	// the name field alone.
	// XXX: This is currently not implemented.
	Persist bool `lang:"persist" yaml:"persist"`

	// NBP is the network boot program URL. This is used for the tftp server
	// name and the boot file name. For example, you might use:
	// tftp://192.0.2.13/pxelinux.0 for a common bios, pxe boot setup. Note
	// that the "scheme" prefix is required, and that it's impossible to
	// specify a file that doesn't begin with a leading slash. If you wish
	// to specify a "root less" file (common for legacy tftp setups) then
	// you can use this feature in conjunction with the NBPPath parameter.
	// For DHCPv4, the scheme must be "tftp".
	NBP string `lang:"nbp" yaml:"nbp"`

	// NBPPath overrides the path that is sent for the nbp protocols. By
	// default it is taken from parsing a URL in NBP, but this can override
	// that. This is useful if you require a path that doesn't start with a
	// slash. This is sometimes desirable for legacy tftp setups.
	NBPPath string `lang:"nbp_path" yaml:"nbp_path"`
	// contains filtered or unexported fields
}

DHCPRangeRes is a representation of a range allocator in DHCP. To declare a range you must specify either the `network` field or the `from` and `to` fields as ip with cidr's, or `from` and `to` fields without cidr's but with the `mask` field as either a dotted netmask or a `/number` field. If you specify none of these, then the resource name will be interpreted the same way that the `network` field os. The last ip in the range (which is often used as a broadcast address) is never allocated. TODO: Add a setting to determine if we should allocate the last address.

func (*DHCPRangeRes) CheckApply

func (obj *DHCPRangeRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply never has anything to do for this resource, so it always succeeds.

func (*DHCPRangeRes) Cleanup

func (obj *DHCPRangeRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*DHCPRangeRes) Cmp

func (obj *DHCPRangeRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*DHCPRangeRes) Default

func (obj *DHCPRangeRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*DHCPRangeRes) Init

func (obj *DHCPRangeRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*DHCPRangeRes) UnmarshalYAML

func (obj *DHCPRangeRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*DHCPRangeRes) Validate

func (obj *DHCPRangeRes) Validate() error

Validate checks if the resource data structure was populated correctly.

func (*DHCPRangeRes) Watch

func (obj *DHCPRangeRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events. This particular one does absolutely nothing but block until we've received a done signal.

type DHCPServerRes

type DHCPServerRes struct {
	traits.Base      // add the base methods without re-implementation
	traits.Edgeable  // TODO: add autoedge support
	traits.Groupable // can have DHCPHostRes and more, grouped into it

	// Address is the listen address to use for the dhcp server. It is
	// common to use `:67` (the standard) to listen on UDP port 67 on all
	// addresses.
	Address string `lang:"address" yaml:"address"`

	// Interface is interface to bind to. For example `eth0` for the common
	// case. You may leave this field blank to not run any specific binding.
	// XXX: You need to actually specify an interface here at the moment. :(
	// BUG: https://github.com/insomniacslk/dhcp/issues/372
	Interface string `lang:"interface" yaml:"interface"`

	// ServerID is a unique IPv4 identifier for this server as specified in
	// the DHCPv4 protocol. It is almost always the IP address of the DHCP
	// server. If you don't specify this, then we will attempt to determine
	// it from the specified interface. If it is set to the empty string,
	// then this won't be set in the DHCP protocol, and your DHCP server
	// might not work as you intend. Otherwise, if a valid value is
	// specified, then this will be used as long as it validates correctly.
	// Please note that if you attempt to automatically determine this from
	// the specified interface, then this only happens at runtime when the
	// first DHCP request needs this or during CheckApply, either of which
	// could fail if for some reason it is not available.
	ServerID *string `lang:"serverid" yaml:"serverid"`

	// LeaseTime is the default lease duration in a format that is parseable
	// by the golang time.ParseDuration function, for example "60s" or "10m"
	// or "1h42m13s". If it is unspecified, then a default will be used. If
	// the empty string is specified, then no lease time will be set in the
	// DHCP protocol, and your DHCP server might not work as you intend.
	LeaseTime *string `lang:"leasetime" yaml:"leasetime"`

	// DNS represents a list of DNS servers to offer to the DHCP client.
	// XXX: Is it mandatory? https://github.com/insomniacslk/dhcp/issues/359
	DNS []string `lang:"dns" yaml:"dns"`

	// Routers represents a list of routers to offer to the DHCP client. It
	// is most common to only specify one unless you know what you're doing.
	Routers []string `lang:"routers" yaml:"routers"`

	// NBP is the network boot program URL. This is used for the tftp server
	// name and the boot file name. For example, you might use:
	// tftp://192.0.2.13/pxelinux.0 for a common bios, pxe boot setup. Note
	// that the "scheme" prefix is required, and that it's impossible to
	// specify a file that doesn't begin with a leading slash. If you wish
	// to specify a "root less" file (common for legacy tftp setups) then
	// you can use this feature in conjunction with the NBPPath parameter.
	// For DHCPv4, the scheme must be "tftp". This values is used as the
	// default for all dhcp:host resources. You can specify this here, and
	// the NBPPath per-resource and they will successfully combine.
	NBP string `lang:"nbp" yaml:"nbp"`
	// contains filtered or unexported fields
}

DHCPServerRes is a simple dhcp server resource. It responds to dhcp client requests, but does not actually apply any state. The name is used as the address to listen on, unless the Address field is specified, and in that case it is used instead. The resource can offer up dhcp client leases from any number of dhcp:host resources which will get autogrouped into this resource at runtime.

This server is not meant as a featureful replacement for the venerable dhcpd, but rather as a simple, dynamic, integrated alternative for bootstrapping new machines and clusters in an elegant way.

TODO: Add autoedges between the Interface and any identically named NetRes.

func (*DHCPServerRes) CheckApply

func (obj *DHCPServerRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply never has anything to do for this resource, so it always succeeds. It does however check that certain runtime requirements (such as the Root dir existing if one was specified) are fulfilled.

func (*DHCPServerRes) Cleanup

func (obj *DHCPServerRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*DHCPServerRes) Cmp

func (obj *DHCPServerRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*DHCPServerRes) Copy

func (obj *DHCPServerRes) Copy() engine.CopyableRes

Copy copies the resource. Don't call it directly, use engine.ResCopy instead. TODO: should this copy internal state?

func (*DHCPServerRes) Default

func (obj *DHCPServerRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*DHCPServerRes) GroupCmp

func (obj *DHCPServerRes) GroupCmp(r engine.GroupableRes) error

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 (*DHCPServerRes) Init

func (obj *DHCPServerRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*DHCPServerRes) UnmarshalYAML

func (obj *DHCPServerRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*DHCPServerRes) Validate

func (obj *DHCPServerRes) Validate() error

Validate checks if the resource data structure was populated correctly.

func (*DHCPServerRes) Watch

func (obj *DHCPServerRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type DeployTar

type DeployTar struct {
	traits.Base // add the base methods without re-implementation

	// Path, which defaults to the name if not specified, represents the
	// destination path for the compressed file being created. It must be an
	// absolute path, and as a result must start with a slash. Since it is a
	// file, it must not end with a slash.
	Path string `lang:"path" yaml:"path"`

	// Format is the header format to use. If you change this, then the
	// file will get rearchived. The strange thing is that it seems the
	// header format is stored for each individual file. The available
	// values are: const.res.tar.format.unknown, const.res.tar.format.ustar,
	// const.res.tar.format.pax, and const.res.tar.format.gnu which have
	// values of 0, 2, 4, and 8 respectively.
	Format int `lang:"format" yaml:"format"`
	// contains filtered or unexported fields
}

DeployTar is a resource that archives a deploy filesystem using tar, thus combining them into a single file. The name of the resource is the path to the resultant archive file. The input comes from the current deploy. This uses hashes to determine if something was changed, so as a result, this may not be suitable if you can create a sha256 hash collision. TODO: support send/recv to send the output instead of writing to a file? TODO: This resource is very similar to the tar resource. Update that one if this changes, or consider porting this to use that as a composite resource. TODO: consider using a `deploy.get_archive()` function to make a .tar, and a file resource to store those contents on disk with whatever mode we want...

func (*DeployTar) CheckApply

func (obj *DeployTar) CheckApply(ctx context.Context, apply bool) (bool, error)

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. This is where we actually do the archiving into a tar file work when needed.

func (*DeployTar) Cleanup

func (obj *DeployTar) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*DeployTar) Cmp

func (obj *DeployTar) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*DeployTar) Default

func (obj *DeployTar) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*DeployTar) Init

func (obj *DeployTar) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*DeployTar) UnmarshalYAML

func (obj *DeployTar) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*DeployTar) Validate

func (obj *DeployTar) Validate() error

Validate if the params passed in are valid data.

func (*DeployTar) Watch

func (obj *DeployTar) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type DiskDevice

type DiskDevice struct {
	Source string `lang:"source" yaml:"source"`
	Type   string `lang:"type" yaml:"type"`
}

DiskDevice represents a disk that is attached to the virt machine.

func (*DiskDevice) Cmp

func (obj *DiskDevice) Cmp(dev *DiskDevice) error

Cmp compares two DiskDevice's and returns an error if they are not equivalent.

func (*DiskDevice) GetXML

func (obj *DiskDevice) GetXML(idx int) string

GetXML returns the XML representation of this device.

type DockerContainerRes

type DockerContainerRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Edgeable

	// State of the container must be running, stopped, or removed.
	State string `lang:"state" yaml:"state"`

	// Image is a docker image, or image:tag.
	Image string `lang:"image" yaml:"image"`

	// Cmd is a command, or list of commands to run on the container.
	Cmd []string `lang:"cmd" yaml:"cmd"`

	// Env is a list of environment variables. E.g. ["VAR=val",].
	Env []string `lang:"env" yaml:"env"`

	// Ports is a map of port bindings. E.g. {"tcp" => {80 => 8080},}.
	Ports map[string]map[int64]int64 `lang:"ports" yaml:"ports"`

	// APIVersion allows you to override the host's default client API
	// version.
	APIVersion string `lang:"apiversion" yaml:"apiversion"`

	// Force, if true, this will destroy and redeploy the container if the
	// image is incorrect.
	Force bool `lang:"force" yaml:"force"`
	// contains filtered or unexported fields
}

DockerContainerRes is a docker container resource.

func (*DockerContainerRes) AutoEdges

func (obj *DockerContainerRes) AutoEdges() (engine.AutoEdge, error)

AutoEdges returns edges to any docker:image resource that matches the image specified in the docker:container resource definition.

func (*DockerContainerRes) CheckApply

func (obj *DockerContainerRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for Docker resource.

func (*DockerContainerRes) Cleanup

func (obj *DockerContainerRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*DockerContainerRes) Cmp

func (obj *DockerContainerRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*DockerContainerRes) Default

func (obj *DockerContainerRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*DockerContainerRes) Init

func (obj *DockerContainerRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*DockerContainerRes) UIDs

func (obj *DockerContainerRes) UIDs() []engine.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 (*DockerContainerRes) UnmarshalYAML

func (obj *DockerContainerRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*DockerContainerRes) Validate

func (obj *DockerContainerRes) Validate() error

Validate if the params passed in are valid data.

func (*DockerContainerRes) Watch

func (obj *DockerContainerRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type DockerContainerResAutoEdges

type DockerContainerResAutoEdges struct {
	UIDs []engine.ResUID
	// contains filtered or unexported fields
}

DockerContainerResAutoEdges holds the state of the auto edge generator.

func (*DockerContainerResAutoEdges) Next

Next returnes the next automatic edge.

func (*DockerContainerResAutoEdges) Test

func (obj *DockerContainerResAutoEdges) Test(input []bool) bool

Test gets results of the earlier Next() call, & returns if we should continue.

type DockerContainerUID

type DockerContainerUID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

DockerContainerUID is the UID struct for DockerContainerRes.

type DockerImageRes

type DockerImageRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Edgeable

	// State of the image must be exists or absent.
	State string `lang:"state" yaml:"state"`

	// APIVersion allows you to override the host's default client API
	// version.
	APIVersion string `lang:"apiversion" yaml:"apiversion"`
	// contains filtered or unexported fields
}

DockerImageRes is a docker image resource. The resource's name must be a docker image in any supported format (url, image, or image:tag).

func (*DockerImageRes) AutoEdges

func (obj *DockerImageRes) AutoEdges() (engine.AutoEdge, error)

AutoEdges returns the AutoEdge interface.

func (*DockerImageRes) CheckApply

func (obj *DockerImageRes) CheckApply(ctx context.Context, apply bool) (checkOK bool, err error)

CheckApply method for Docker resource.

func (*DockerImageRes) Cleanup

func (obj *DockerImageRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*DockerImageRes) Cmp

func (obj *DockerImageRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*DockerImageRes) Default

func (obj *DockerImageRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*DockerImageRes) Init

func (obj *DockerImageRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*DockerImageRes) UIDs

func (obj *DockerImageRes) UIDs() []engine.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 (*DockerImageRes) UnmarshalYAML

func (obj *DockerImageRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*DockerImageRes) Validate

func (obj *DockerImageRes) Validate() error

Validate if the params passed in are valid data.

func (*DockerImageRes) Watch

func (obj *DockerImageRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type DockerImageUID

type DockerImageUID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

DockerImageUID is the UID struct for DockerImageRes.

func (*DockerImageUID) IFF

func (obj *DockerImageUID) IFF(uid engine.ResUID) bool

IFF aka if and only if they are equivalent, return true. If not, false.

type ExecRes

type ExecRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Edgeable
	traits.Sendable

	// Cmd is the command to run. If this is not specified, we use the name.
	// Remember that if you're not using `Shell` (the default) then adding
	// single quotes around args make them part of the actual values. IOW,
	// if your command is: "touch '/tmp/foo'", then (1) it probably won't be
	// able to find the "touch" command (use /usr/bin/touch instead) and (2)
	// the file won't be in the /tmp/ directory, it will be an oddly named
	// file that contains two single quotes, and it will likely error since
	// the dir path doesn't exist. In general, it's best to use the `Args`
	// field instead of including them here.
	// XXX: if not using shell, don't allow args here, force them to args!
	Cmd string `lang:"cmd" yaml:"cmd"`

	// Args is a list of args to pass to Cmd. This can be used *instead* of
	// passing the full command and args as a single string to Cmd. It can
	// only be used when a Shell is *not* specified. The advantage of this
	// is that you don't have to worry about escape characters.
	Args []string `lang:"args" yaml:"args"`

	// Cwd is the dir to run the command in. If empty, then this will use
	// the working directory of the calling process. (This process is mgmt,
	// not the process being run here.) Keep in mind that if you're running
	// this command as a user that does not have perms to the current
	// directory, you may wish to set this to `/` to avoid hitting an error
	// such as: `could not change directory to "/root": Permission denied`.
	Cwd string `lang:"cwd" yaml:"cwd"`

	// Shell is the (optional) shell to use to run the cmd. If you specify
	// this, then you can't use the Args parameter.
	Shell string `lang:"shell" yaml:"shell"`

	// Timeout is the number of seconds to wait before sending a Kill to the
	// running command. If the Kill is received before the process exits,
	// then this be treated as an error.
	Timeout uint64 `lang:"timeout" yaml:"timeout"`

	// Env allows the user to specify environment variables for script
	// execution. These are taken using a map of format of VAR_NAME -> value.
	Env map[string]string `lang:"env" yaml:"env"`

	// WatchCmd is the command to run to detect event changes. Each line of
	// output from this command is treated as an event.
	WatchCmd string `lang:"watchcmd" yaml:"watchcmd"`

	// WatchCwd is the Cwd for the WatchCmd. See the docs for Cwd.
	WatchCwd string `lang:"watchcwd" yaml:"watchcwd"`

	// WatchShell is the Shell for the WatchCmd. See the docs for Shell.
	WatchShell string `lang:"watchshell" yaml:"watchshell"`

	// IfCmd is the command that runs to guard against running the Cmd. If
	// this command succeeds, then Cmd *will* be run. If this command
	// returns a non-zero result, then the Cmd will not be run. Any error
	// scenario or timeout will cause the resource to error.
	IfCmd string `lang:"ifcmd" yaml:"ifcmd"`

	// IfCwd is the Cwd for the IfCmd. See the docs for Cwd.
	IfCwd string `lang:"ifcwd" yaml:"ifcwd"`

	// IfShell is the Shell for the IfCmd. See the docs for Shell.
	IfShell string `lang:"ifshell" yaml:"ifshell"`

	// Creates is the absolute file path to check for before running the
	// main cmd. If this path exists, then the cmd will not run. More
	// precisely we attempt to `stat` the file, so it must succeed for a
	// skip. This also adds a watch on this path which re-checks things when
	// it changes.
	Creates string `lang:"creates" yaml:"creates"`

	// DoneCmd is the command that runs after the regular Cmd runs
	// successfully. This is a useful pattern to avoid the shelling out to
	// bash simply to do `$cmd && echo done > /tmp/donefile`. If this
	// command errors, it behaves as if the normal Cmd had errored.
	DoneCmd string `lang:"donecmd" yaml:"donecmd"`

	// DoneCwd is the Cwd for the DoneCmd. See the docs for Cwd.
	DoneCwd string `lang:"donecwd" yaml:"donecwd"`

	// DoneShell is the Shell for the DoneCmd. See the docs for Shell.
	DoneShell string `lang:"doneshell" yaml:"doneshell"`

	// User is the (optional) user to use to execute the command. It is used
	// for any command being run.
	User string `lang:"user" yaml:"user"`

	// Group is the (optional) group to use to execute the command. It is
	// used for any command being run.
	Group string `lang:"group" yaml:"group"`
	// contains filtered or unexported fields
}

ExecRes is an exec resource for running commands.

func (*ExecRes) AutoEdges

func (obj *ExecRes) AutoEdges() (engine.AutoEdge, error)

AutoEdges returns the AutoEdge interface. In this case the systemd units.

func (*ExecRes) CheckApply

func (obj *ExecRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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) Cleanup

func (obj *ExecRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*ExecRes) Cmp

func (obj *ExecRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*ExecRes) Default

func (obj *ExecRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*ExecRes) Init

func (obj *ExecRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*ExecRes) Interrupt

func (obj *ExecRes) Interrupt() error

Interrupt is called to ask the execution of this resource to end early.

func (*ExecRes) Sends

func (obj *ExecRes) Sends() interface{}

Sends represents the default struct of values we can send using Send/Recv.

func (*ExecRes) UIDs

func (obj *ExecRes) UIDs() []engine.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 (*ExecRes) UnmarshalYAML

func (obj *ExecRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*ExecRes) Validate

func (obj *ExecRes) Validate() error

Validate if the params passed in are valid data.

func (*ExecRes) Watch

func (obj *ExecRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

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() []engine.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 ExecSends

type ExecSends struct {
	// Output is the combined stdout and stderr of the command.
	Output *string `lang:"output"`
	// Stdout is the stdout of the command.
	Stdout *string `lang:"stdout"`
	// Stderr is the stderr of the command.
	Stderr *string `lang:"stderr"`
}

ExecSends is the struct of data which is sent after a successful Apply.

type ExecUID

type ExecUID struct {
	engine.BaseUID
	Cmd      string
	WatchCmd string
	IfCmd    string
	DoneCmd  string
}

ExecUID is the UID struct for ExecRes.

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.

func ReadDir

func ReadDir(path string) ([]FileInfo, error)

ReadDir reads a directory path, and returns a list of enhanced FileInfo's.

type FileRes

type FileRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Edgeable
	traits.GraphQueryable // allow others to query this res in the res graph
	//traits.Groupable // TODO: implement this
	traits.Recvable
	traits.Reversible

	// Path, which defaults to the name if not specified, represents the
	// destination path for the file or directory being managed. It must be
	// an absolute path, and as a result must start with a slash.
	Path string `lang:"path" yaml:"path"`

	// Dirname is used to override the path dirname. (The directory
	// portion.)
	Dirname string `lang:"dirname" yaml:"dirname"`

	// Basename is used to override the path basename. (The file portion.)
	Basename string `lang:"basename" yaml:"basename"`

	// State specifies the desired state of the file. It can be either
	// `exists` or `absent`. If you do not specify this, we will not be able
	// to create or remove a file if it might be logical for another
	// param to require that. Instead it will error. This means that this
	// field is not implied by specifying some content or a mode.
	State string `lang:"state" yaml:"state"`

	// Content specifies the file contents to use. If this is nil, they are
	// left undefined. It cannot be combined with the Source or Fragments
	// parameters.
	Content *string `lang:"content" yaml:"content"`

	// Source specifies the source contents for the file resource. It cannot
	// be combined with the Content or Fragments parameters. It must be an
	// absolute path, and it can point to a file or a directory. If it
	// points to a file, then that will will be copied throuh directly. If
	// it points to a directory, then it will copy the directory "rsync
	// style" onto the file destination. As a result, if this is a file,
	// then the main file res must be a file, and if it is a directory, then
	// this must be a directory. To meaningfully copy a full directory, you
	// also need to specify the Recurse parameter, which is currently
	// required. If you want an existing dir to be turned into a file (or
	// vice-versa) instead of erroring, then you'll also need to specify the
	// Force parameter. If source is undefined and the file path is a
	// directory, then a directory will be created. If left undefined, and
	// combined with the Purge option too, then any unmanaged file in this
	// dir will be removed.
	Source string `lang:"source" yaml:"source"`

	// Fragments specifies that the file is built from a list of individual
	// files. If one of the files is a directory, then the list of files in
	// that directory are the fragments to combine. Multiple of these can be
	// used together, although most simple cases will probably only either
	// involve a single directory path or a fixed list of individual files.
	// All paths are absolute and as a result must start with a slash. The
	// directories (if any) must end with a slash as well. This cannot be
	// combined with the Content or Source parameters. If a file with param
	// is reversed, the reversed file is one that has `Content` set instead.
	// Automatic edges will be added from these fragments. This currently
	// isn't recursive in that if a fragment is a directory, this only
	// searches one level deep at the moment.
	Fragments []string `lang:"fragments" yaml:"fragments"`

	// Owner specifies the file owner. You can specify either the string
	// name, or a string representation of the owner integer uid.
	Owner string `lang:"owner" yaml:"owner"`

	// Group specifies the file group. You can specify either the string
	// name, or a string representation of the group integer gid.
	Group string `lang:"group" yaml:"group"`

	// Mode is the mode of the file as a string representation of the octal
	// form or symbolic form.
	Mode string `lang:"mode" yaml:"mode"`

	// Recurse specifies if you want to work recursively on the resource. It
	// is used when copying a source directory, or to determine if a watch
	// should be recursive or not. When making a directory, this is required
	// if you'd need the parent directories to be made as well. (Analogous
	// to the `mkdir -p` option.)
	// FIXME: There are some unimplemented cases where we should look at it.
	Recurse bool `lang:"recurse" yaml:"recurse"`

	// Force must be set if we want to perform an unusual operation, such as
	// changing a file into a directory or vice-versa.
	Force bool `lang:"force" yaml:"force"`

	// Purge specifies that when true, any unmanaged file in this file
	// directory will be removed. As a result, this file resource must be a
	// directory. This isn't particularly meaningful if you don't also set
	// Recurse to true. This doesn't work with Content or Fragments.
	Purge bool `lang:"purge" yaml:"purge"`
	// contains filtered or unexported fields
}

FileRes is a file and directory resource. Dirs are defined by names ending in a slash.

func (*FileRes) AutoEdges

func (obj *FileRes) AutoEdges() (engine.AutoEdge, error)

AutoEdges generates a simple linear sequence of each parent directory from the bottom up!

func (*FileRes) CheckApply

func (obj *FileRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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) Cleanup

func (obj *FileRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*FileRes) Cmp

func (obj *FileRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*FileRes) CollectPattern

func (obj *FileRes) CollectPattern(pattern string)

CollectPattern applies the pattern for collection resources.

func (*FileRes) Copy

func (obj *FileRes) Copy() engine.CopyableRes

Copy copies the resource. Don't call it directly, use engine.ResCopy instead. TODO: should this copy internal state?

func (*FileRes) Default

func (obj *FileRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*FileRes) GraphQueryAllowed

func (obj *FileRes) GraphQueryAllowed(opts ...engine.GraphQueryableOption) error

GraphQueryAllowed returns nil if you're allowed to query the graph. This function accepts information about the requesting resource so we can determine the access with some form of fine-grained control.

func (*FileRes) Init

func (obj *FileRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*FileRes) Reversed

func (obj *FileRes) Reversed() (engine.ReversibleRes, error)

Reversed returns the "reverse" or "reciprocal" resource. This is used to "clean" up after a previously defined resource has been removed.

func (*FileRes) UIDs

func (obj *FileRes) UIDs() []engine.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 (*FileRes) UnmarshalYAML

func (obj *FileRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*FileRes) Validate

func (obj *FileRes) Validate() error

Validate reports any problems with the struct definition.

func (*FileRes) Watch

func (obj *FileRes) Watch(ctx context.Context) error

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.

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() []engine.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 {
	engine.BaseUID
	// contains filtered or unexported fields
}

FileUID is the UID struct for FileRes.

func (*FileUID) IFF

func (obj *FileUID) IFF(uid engine.ResUID) bool

IFF aka if and only if they are equivalent, return true. If not, false.

type FilesystemDevice

type FilesystemDevice struct {
	Access   string `lang:"access" yaml:"access"`
	Source   string `lang:"source" yaml:"source"`
	Target   string `lang:"target" yaml:"target"`
	ReadOnly bool   `lang:"read_only" yaml:"read_only"`
}

FilesystemDevice represents a filesystem that is attached to the virt machine.

func (*FilesystemDevice) Cmp

func (obj *FilesystemDevice) Cmp(dev *FilesystemDevice) error

Cmp compares two FilesystemDevice's and returns an error if they are not equivalent.

func (*FilesystemDevice) GetXML

func (obj *FilesystemDevice) GetXML(idx int) string

GetXML returns the XML representation of this device.

type FirewalldRes

type FirewalldRes struct {
	traits.Base // add the base methods without re-implementation

	// Zone is the name of the zone to manage. If unspecified, we will
	// attempt to get the default zone automatically. In this situation, it
	// is possible that this default changes over time if it is acted upon
	// by external tools that use firewalld.
	Zone string `lang:"zone" yaml:"zone"`

	// State is the desired state.
	State string `lang:"state" yaml:"state"`

	// Services are the list of services to manage to the desired state.
	// These are single lower case strings like `dhcp`, and `tftp`.
	Services []string `lang:"services" yaml:"services"`

	// Ports are the list of port/protocol combinations to manage to the
	// desired state. These are strings of port number (slash) protocol like
	// `4280/tcp` and `38/udp`.
	Ports []string `lang:"ports" yaml:"ports"`
	// contains filtered or unexported fields
}

FirewalldRes is a simple resource to interact with the firewalld service. It is not a replacement for a modern, robust tool like `shorewall`, but it has its uses such as for small, desktop use cases. The API of this resource might change to either add new features, split this into multiple resources, or to optimize the execution if it turns out to be too expensive to run large amounts of these as-is. The name variable currently has no useful purpose. Keep in mind that this resource requires root permissions to be able change the firewall settings and to monitor for changes. The change detection uses the nftables monitor facility.

func (*FirewalldRes) CheckApply

func (obj *FirewalldRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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 (*FirewalldRes) Cleanup

func (obj *FirewalldRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*FirewalldRes) Cmp

func (obj *FirewalldRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*FirewalldRes) Default

func (obj *FirewalldRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*FirewalldRes) Init

func (obj *FirewalldRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*FirewalldRes) UnmarshalYAML

func (obj *FirewalldRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*FirewalldRes) Validate

func (obj *FirewalldRes) Validate() error

Validate if the params passed in are valid data.

func (*FirewalldRes) Watch

func (obj *FirewalldRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events. This could have been implemented with an exec of `/usr/sbin/nft --json monitor`, but the wrapped polkit and difficulty getting permissions using capabilities and without using full root, was challenging. This is cleaner too.

type GroupRes

type GroupRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Edgeable

	// State is `exists` or `absent`.
	State string `lang:"state" yaml:"state"`

	// GID is the group's gid.
	GID *uint32 `lang:"gid" yaml:"gid"`
	// contains filtered or unexported fields
}

GroupRes is a user group resource.

func (*GroupRes) AutoEdges

func (obj *GroupRes) AutoEdges() (engine.AutoEdge, error)

AutoEdges returns the AutoEdge interface.

func (*GroupRes) CheckApply

func (obj *GroupRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for Group resource.

func (*GroupRes) Cleanup

func (obj *GroupRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*GroupRes) Cmp

func (obj *GroupRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*GroupRes) Default

func (obj *GroupRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*GroupRes) Init

func (obj *GroupRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*GroupRes) UIDs

func (obj *GroupRes) UIDs() []engine.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 (*GroupRes) UnmarshalYAML

func (obj *GroupRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*GroupRes) Validate

func (obj *GroupRes) Validate() error

Validate if the params passed in are valid data.

func (*GroupRes) Watch

func (obj *GroupRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type GroupUID

type GroupUID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

GroupUID is the UID struct for GroupRes.

func (*GroupUID) IFF

func (obj *GroupUID) IFF(uid engine.ResUID) bool

IFF aka if and only if they are equivalent, return true. If not, false.

type GzipRes

type GzipRes struct {
	traits.Base // add the base methods without re-implementation

	// Path, which defaults to the name if not specified, represents the
	// destination path for the compressed file being created. It must be an
	// absolute path, and as a result must start with a slash. Since it is a
	// file, it must not end with a slash.
	Path string `lang:"path" yaml:"path"`

	// Input represents the input file to be compressed. It must be an
	// absolute path, and as a result must start with a slash. Since it is a
	// file, it must not end with a slash. If this is specified, we use it,
	// otherwise we use the Content parameter.
	Input *string `lang:"input" yaml:"input"`

	// Content is the raw data to compress. If Input is not specified, then
	// we use this parameter. If you forget to specify both of these, then
	// you will compress zero-length data!
	// TODO: If this is also empty should we just error at Validate?
	// FIXME: Do we need []byte here? Do we need a binary type?
	Content string `lang:"content" yaml:"content"`

	// Level is the compression level to use. If you change this, then the
	// file will get recompressed. The available values are:
	// const.res.gzip.level.no_compression, const.res.gzip.level.best_speed,
	// const.res.gzip.level.best_compression,
	// const.res.gzip.level.default_compression, and
	// const.res.gzip.level.huffman_only.
	Level int `lang:"level" yaml:"level"`
	// contains filtered or unexported fields
}

GzipRes is a resource that compresses a path or some raw data using gzip. The name of the resource is the path to the resultant compressed file. The input can either come from a file path if specified with Input or it looks at the Content field for raw data. It uses hashes to determine if something was changed, so as a result, this may not be suitable if you can create a sha256 hash collision. TODO: support send/recv to send the output instead of writing to a file?

func (*GzipRes) CheckApply

func (obj *GzipRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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. This is where we actually do the compression work when needed.

func (*GzipRes) Cleanup

func (obj *GzipRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*GzipRes) Cmp

func (obj *GzipRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*GzipRes) Default

func (obj *GzipRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*GzipRes) Init

func (obj *GzipRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*GzipRes) UnmarshalYAML

func (obj *GzipRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*GzipRes) Validate

func (obj *GzipRes) Validate() error

Validate if the params passed in are valid data.

func (*GzipRes) Watch

func (obj *GzipRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type HTTPFileRes

type HTTPFileRes struct {
	traits.Base      // add the base methods without re-implementation
	traits.Edgeable  // XXX: add autoedge support
	traits.Groupable // can be grouped into HTTPServerRes

	// Server is the name of the http server resource to group this into. If
	// it is omitted, and there is only a single http resource, then it will
	// be grouped into it automatically. If there is more than one main http
	// resource being used, then the grouping behaviour is *undefined* when
	// this is not specified, and it is not recommended to leave this blank!
	Server string `lang:"server" yaml:"server"`

	// Filename is the name of the file this data should appear as on the
	// http server.
	Filename string `lang:"filename" yaml:"filename"`

	// Path is the absolute path to a file that should be used as the source
	// for this file resource. It must not be combined with the data field.
	// If this corresponds to a directory, then it will used as a root dir
	// that will be served as long as the resource name or Filename are also
	// a directory ending with a slash.
	Path string `lang:"path" yaml:"path"`

	// Data is the file content that should be used as the source for this
	// file resource. It must not be combined with the path field.
	// TODO: should this be []byte instead?
	Data string `lang:"data" yaml:"data"`
	// contains filtered or unexported fields
}

HTTPFileRes is a file that exists within an http server. The name is used as the public path of the file, unless the filename field is specified, and in that case it is used instead. The way this works is that it autogroups at runtime with an existing http resource, and in doing so makes the file associated with this resource available for serving from that http server.

func (*HTTPFileRes) AcceptHTTP

func (obj *HTTPFileRes) AcceptHTTP(req *http.Request) error

AcceptHTTP determines whether we will respond to this request. Return nil to accept, or any error to pass.

func (*HTTPFileRes) CheckApply

func (obj *HTTPFileRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply never has anything to do for this resource, so it always succeeds.

func (*HTTPFileRes) Cleanup

func (obj *HTTPFileRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*HTTPFileRes) Cmp

func (obj *HTTPFileRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*HTTPFileRes) Default

func (obj *HTTPFileRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*HTTPFileRes) Init

func (obj *HTTPFileRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*HTTPFileRes) ParentName

func (obj *HTTPFileRes) ParentName() string

ParentName is used to limit which resources autogroup into this one. If it's empty then it's ignored, otherwise it must match the Name of the parent to get grouped.

func (*HTTPFileRes) ServeHTTP

func (obj *HTTPFileRes) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP is the standard HTTP handler that will be used here.

func (*HTTPFileRes) UnmarshalYAML

func (obj *HTTPFileRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*HTTPFileRes) Validate

func (obj *HTTPFileRes) Validate() error

Validate checks if the resource data structure was populated correctly.

func (*HTTPFileRes) Watch

func (obj *HTTPFileRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events. This particular one does absolutely nothing but block until we've received a done signal.

type HTTPFlagRes

type HTTPFlagRes struct {
	traits.Base      // add the base methods without re-implementation
	traits.Edgeable  // XXX: add autoedge support
	traits.Groupable // can be grouped into HTTPServerRes
	traits.Sendable

	// Server is the name of the http server resource to group this into. If
	// it is omitted, and there is only a single http resource, then it will
	// be grouped into it automatically. If there is more than one main http
	// resource being used, then the grouping behaviour is *undefined* when
	// this is not specified, and it is not recommended to leave this blank!
	Server string `lang:"server" yaml:"server"`

	// Path is the path that this will present as on the http server.
	Path string `lang:"path" yaml:"path"`

	// Key is the querystring name that is used to capture a value as.
	Key string `lang:"key" yaml:"key"`
	// contains filtered or unexported fields
}

HTTPFlagRes is a special path that exists within an http server. The name is used as the public path of the flag, unless the path field is specified, and in that case it is used instead. The way this works is that it autogroups at runtime with an existing http resource, and in doing so makes the flag associated with this resource available to cause actions when it receives a request on that http server. If you create a flag which responds to the same type of request as an http:file resource or any other kind of resource, it is undefined behaviour which will answer the request. The most common clash will happen if both are present at the same path.

func (*HTTPFlagRes) AcceptHTTP

func (obj *HTTPFlagRes) AcceptHTTP(req *http.Request) error

AcceptHTTP determines whether we will respond to this request. Return nil to accept, or any error to pass.

func (*HTTPFlagRes) CheckApply

func (obj *HTTPFlagRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply never has anything to do for this resource, so it always succeeds.

func (*HTTPFlagRes) Cleanup

func (obj *HTTPFlagRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*HTTPFlagRes) Cmp

func (obj *HTTPFlagRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*HTTPFlagRes) Default

func (obj *HTTPFlagRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*HTTPFlagRes) Init

func (obj *HTTPFlagRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*HTTPFlagRes) ParentName

func (obj *HTTPFlagRes) ParentName() string

ParentName is used to limit which resources autogroup into this one. If it's empty then it's ignored, otherwise it must match the Name of the parent to get grouped.

func (*HTTPFlagRes) Sends

func (obj *HTTPFlagRes) Sends() interface{}

Sends represents the default struct of values we can send using Send/Recv.

func (*HTTPFlagRes) ServeHTTP

func (obj *HTTPFlagRes) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP is the standard HTTP handler that will be used here.

func (*HTTPFlagRes) UnmarshalYAML

func (obj *HTTPFlagRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*HTTPFlagRes) Validate

func (obj *HTTPFlagRes) Validate() error

Validate checks if the resource data structure was populated correctly.

func (*HTTPFlagRes) Watch

func (obj *HTTPFlagRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events. This particular one listens for events from incoming http requests to the flag, and notifies the engine so that CheckApply can then run and return the correct value on send/recv.

type HTTPFlagSends

type HTTPFlagSends struct {
	// Value is the received value being sent.
	Value *string `lang:"value"`
}

HTTPFlagSends is the struct of data which is sent after a successful Apply.

type HTTPProxyRes

type HTTPProxyRes struct {
	traits.Base      // add the base methods without re-implementation
	traits.Edgeable  // XXX: add autoedge support
	traits.Groupable // can be grouped into HTTPServerRes
	traits.Sendable

	// Server is the name of the http server resource to group this into. If
	// it is omitted, and there is only a single http resource, then it will
	// be grouped into it automatically. If there is more than one main http
	// resource being used, then the grouping behaviour is *undefined* when
	// this is not specified, and it is not recommended to leave this blank!
	Server string `lang:"server" yaml:"server"`

	// Path is the path that this presents as on the grouped http server. It
	// overrides the Name var if specified.
	Path string `lang:"path" yaml:"path"`

	// Sub is the string to remove from the start of the request, the path
	// of which is looking at the Name/Path field to see if it matches. If
	// it matches, it then translates to the destination server by removing
	// this `Sub` string from the start of the path request, and then
	// prepending on the `Head` field to get to the resultant proxy URL. If
	// this is empty, then nothing is subtracted.
	Sub string `lang:"sub" yaml:"sub"`

	// Head is the string to add on as a prefix to the new URL we are
	// building for the proxy. If this is empty, the proxy can't work, and
	// we can only rely on what is available in our local cache. This is
	// typically the protocol and hostname for the backing server.
	Head string `lang:"head" yaml:"head"`

	// Cache is an absolute path to a location on disk where cached files
	// can be stored. If this is empty then we will not cache any files.
	// TODO: We could add future in-memory stores, a checksum feature, etc
	Cache string `lang:"cache" yaml:"cache"`
	// contains filtered or unexported fields
}

HTTPProxyRes is a resource representing a special path that exists within an http server. The name is used as the public path of the endpoint, unless the path field is specified, and in that case it is used instead. The way this works is that it autogroups at runtime with an existing http resource, and in doing so makes the path associated with this resource available when serving files. When something under the path is accessed, this is pulled from the backing http server, which makes an http client connection if needed to pull the authoritative file down, saves it locally for future use, and then returns it to the original http client caller. On a subsequent call, if the cache was not invalidated, the file doesn't need to be fetched from the network. In effect, this works as a caching http proxy. If you create this as a resource which responds to the same type of request as an http:file resource or any other kind of resource, it is undefined behaviour which will answer the request. The most common clash will happen if both are present at the same path. This particular implementation stores some file data in memory as a convenience instead of streaming directly to clients. This makes locking much easier, but is wasteful. If you plan on using this for huge files and on systems with low amounts of memory, you might want to optimize this. The resultant proxy path is determined by subtracting the `Sub` field from the `Path` (and request path) and then appending the result to the `Head` field.

func (*HTTPProxyRes) AcceptHTTP

func (obj *HTTPProxyRes) AcceptHTTP(req *http.Request) error

AcceptHTTP determines whether we will respond to this request. Return nil to accept, or any error to pass.

func (*HTTPProxyRes) CheckApply

func (obj *HTTPProxyRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply never has anything to do for this resource, so it always succeeds.

func (*HTTPProxyRes) Cleanup

func (obj *HTTPProxyRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*HTTPProxyRes) Cmp

func (obj *HTTPProxyRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*HTTPProxyRes) Default

func (obj *HTTPProxyRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*HTTPProxyRes) Init

func (obj *HTTPProxyRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*HTTPProxyRes) ParentName

func (obj *HTTPProxyRes) ParentName() string

ParentName is used to limit which resources autogroup into this one. If it's empty then it's ignored, otherwise it must match the Name of the parent to get grouped.

func (*HTTPProxyRes) Sends

func (obj *HTTPProxyRes) Sends() interface{}

Sends represents the default struct of values we can send using Send/Recv.

func (*HTTPProxyRes) ServeHTTP

func (obj *HTTPProxyRes) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP is the standard HTTP handler that will be used here.

func (*HTTPProxyRes) UnmarshalYAML

func (obj *HTTPProxyRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*HTTPProxyRes) Validate

func (obj *HTTPProxyRes) Validate() error

Validate checks if the resource data structure was populated correctly.

func (*HTTPProxyRes) Watch

func (obj *HTTPProxyRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events. This particular one does absolutely nothing but block until we've received a done signal.

type HTTPProxySends

type HTTPProxySends struct {
	// Data is the received value being sent.
	// TODO: should this be []byte or *[]byte instead?
	Data *string `lang:"data"`
}

HTTPProxySends is the struct of data which is sent after a successful Apply.

type HTTPServerGroupableRes

type HTTPServerGroupableRes interface {
	engine.Res

	// ParentName is used to limit which resources autogroup into this one.
	// If it's empty then it's ignored, otherwise it must match the Name of
	// the parent to get grouped.
	ParentName() string

	// AcceptHTTP determines whether this will respond to this request.
	// Return nil to accept, or any error to pass. This should be
	// deterministic (pure) and fast.
	AcceptHTTP(req *http.Request) error

	// ServeHTTP is the standard HTTP handler that will be used for this.
	http.Handler // ServeHTTP(w http.ResponseWriter, req *http.Request)
}

HTTPServerGroupableRes is the interface that you must implement if you want to allow a resource the ability to be grouped into the http server resource. As an added safety, the Kind must also begin with "http:", and not have more than one colon, or it must begin with http:server:, and not have any further colons to avoid accidents of unwanted grouping.

type HTTPServerRes

type HTTPServerRes struct {
	traits.Base      // add the base methods without re-implementation
	traits.Edgeable  // XXX: add autoedge support
	traits.Groupable // can have HTTPFileRes and others grouped into it

	// Address is the listen address to use for the http server. It is
	// common to use `:80` (the standard) to listen on TCP port 80 on all
	// addresses.
	Address string `lang:"address" yaml:"address"`

	// Timeout is the maximum duration in seconds to use for unspecified
	// timeouts. In other words, when this value is specified, it is used as
	// the value for the other *Timeout values when they aren't used. Put
	// another way, this makes it easy to set all the different timeouts
	// with a single parameter.
	Timeout *uint64 `lang:"timeout" yaml:"timeout"`

	// ReadTimeout is the maximum duration in seconds for reading during the
	// http request. If it is zero, then there is no timeout. If this is
	// unspecified, then the value of Timeout is used instead if it is set.
	// For more information, see the golang net/http Server documentation.
	ReadTimeout *uint64 `lang:"read_timeout" yaml:"read_timeout"`

	// WriteTimeout is the maximum duration in seconds for writing during
	// the http request. If it is zero, then there is no timeout. If this is
	// unspecified, then the value of Timeout is used instead if it is set.
	// For more information, see the golang net/http Server documentation.
	WriteTimeout *uint64 `lang:"write_timeout" yaml:"write_timeout"`

	// ShutdownTimeout is the maximum duration in seconds to wait for the
	// server to shutdown gracefully before calling Close. By default it is
	// nice to let client connections terminate gracefully, however it might
	// take longer than we are willing to wait, particularly if one is long
	// polling or running a very long download. As a result, you can set a
	// timeout here. The default is zero which means it will wait
	// indefinitely. The shutdown process can also be cancelled by the
	// interrupt handler which this resource supports. If this is
	// unspecified, then the value of Timeout is used instead if it is set.
	ShutdownTimeout *uint64 `lang:"shutdown_timeout" yaml:"shutdown_timeout"`

	// Root is the root directory that we should serve files from. If it is
	// not specified, then it is not used. Any http file resources will have
	// precedence over anything in here, in case the same path exists twice.
	// TODO: should we have a flag to determine the precedence rules here?
	Root string `lang:"root" yaml:"root"`
	// contains filtered or unexported fields
}

HTTPServerRes is an http server resource. It serves files, but does not actually apply any state. The name is used as the address to listen on, unless the Address field is specified, and in that case it is used instead. This resource can offer up files for serving that are specified either inline in this resource by specifying an http root, or as http:file resources which will get autogrouped into this resource at runtime. The two methods can be combined as well.

This server also supports autogrouping some more magical resources into it. For example, the http:flag and http:ui resources add in magic endpoints.

This server is not meant as a featureful replacement for the venerable and modern httpd servers out there, but rather as a simple, dynamic, integrated alternative for bootstrapping new machines and clusters in an elegant way.

TODO: add support for TLS XXX: Add an http:flag resource that lets an http client set a flag somewhere! XXX: Add a http:ui resource that functions can read data from! XXX: The http:ui resource can also take in values from those functions!

func (*HTTPServerRes) AcceptHTTP

func (obj *HTTPServerRes) AcceptHTTP(req *http.Request) error

AcceptHTTP determines whether we will respond to this request. Return nil to accept, or any error to pass. In this particular case, it accepts for the Root directory handler, but it happens to be implemented with this signature in case it gets moved. It doesn't intentionally match the HTTPServerGroupableRes interface.

func (*HTTPServerRes) CheckApply

func (obj *HTTPServerRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply never has anything to do for this resource, so it always succeeds. It does however check that certain runtime requirements (such as the Root dir existing if one was specified) are fulfilled. If there are any autogrouped resources, those will be recursively called so that they can send/recv.

func (*HTTPServerRes) Cleanup

func (obj *HTTPServerRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*HTTPServerRes) Cmp

func (obj *HTTPServerRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*HTTPServerRes) Copy

func (obj *HTTPServerRes) Copy() engine.CopyableRes

Copy copies the resource. Don't call it directly, use engine.ResCopy instead. TODO: should this copy internal state?

func (*HTTPServerRes) Default

func (obj *HTTPServerRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*HTTPServerRes) GroupCmp

func (obj *HTTPServerRes) GroupCmp(r engine.GroupableRes) error

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 (*HTTPServerRes) Init

func (obj *HTTPServerRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*HTTPServerRes) Interrupt

func (obj *HTTPServerRes) Interrupt() error

Interrupt is called to ask the execution of this resource to end early. It will cause the server Shutdown to end abruptly instead of leading open client connections terminate gracefully. It does this by causing the server Close method to run.

func (*HTTPServerRes) ServeHTTP

func (obj *HTTPServerRes) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP is the standard HTTP handler that will be used here. In this particular case, it serves the Root directory handler, but it happens to be implemented with this signature in case it gets moved. It doesn't intentionally match the HTTPServerGroupableRes interface.

func (*HTTPServerRes) UnmarshalYAML

func (obj *HTTPServerRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*HTTPServerRes) Validate

func (obj *HTTPServerRes) Validate() error

Validate checks if the resource data structure was populated correctly.

func (*HTTPServerRes) Watch

func (obj *HTTPServerRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type HetznerVMRes

type HetznerVMRes struct {
	traits.Base

	// APIToken specifies the unique API token corresponding to a Hetzner
	// project. Keep this token private! It provides full access to this
	// project, so a leaked token will be vulnerable to abuse. Read it from
	// a local file or the mgmt deploy, or provide it directly as a string.
	// NOTE: It must be generated manually via https://console.hetzner.cloud/.
	// NOTE: This token is usually a 64 character alphanumeric string.
	APIToken string `lang:"apitoken"`

	// State specifies the desired state of the server instance. The supported
	// options are "" (undefined), "absent", "exists", "off" and "running".
	// HetznerStateUndefined ("") leaves the state undefined by default.
	// HetznerStateExists ("exists") indicates that the server must exist.
	// HetznerStateAbsent ("absent") indicates that the server must not exist.
	// HetznerStateRunning ("running") tells the server it must be powered on.
	// HetznerStateOff ("off") tells the server it must be powered off.
	// NOTE: any other inputs will not pass Validate and result in an error.
	// NOTE: setting the state of a live server to "absent" will delete all data
	// and services that are located on that instance! Use with caution.
	State string `lang:"state"`

	// AllowRebuild provides flexible protection against unexpected server
	// rebuilds. Any changes to the "servertype", "datacenter" or "image" params
	// require a destructive rebuild, which deletes all data on that server.
	// The user must explicitly allow these operations with AllowRebuild.
	// Choose from three options: "ifneeded" allows all rebuilds that are needed
	// by CheckApply to meet the specified params. "ignore" disables these
	// rebuilds, but continues without error. The default option ("") disables
	// always returns an error when CheckApply requests a rebuild.
	// NOTE: Soft updates related to power and rescue mode are always allowed,
	// because they are only required for explicit changes to resource fields.
	// TODO: add AllowReboot if any indirect poweroffs are ever implemented.
	AllowRebuild string `lang:"allowrebuild"`

	// ServerType determines the machine type as defined by Hetzner. A complete
	// and up-to-date list of options must be requested from the Hetzner API,
	// but hcloud-go-getopts (url) provides a static reference. Basic servertype
	// options include "cx11", "cx21", "cx31" etc.
	// NOTE: make sure to check the price of the selected servertype! The listed
	// examples are usually very cheap, but never free. Price and availability
	// can also be dependent on the selected datacenter.
	// https://github.com/JefMasereel/hcloud-go-getopts/
	// TODO: set some kind of cost-based protection policy?
	ServerType string `lang:"servertype"`

	// Datacenter determines where the resource is hosted.  A complete and
	// up-to-date list of options must be requested from the Hetzner API, but
	// hcloud-go-getopts (url) provides a static reference. The datacenter
	// options include "nbg1-dc3", "fsn1-dc14", "hel1-dc2" etc.
	// https://github.com/JefMasereel/hcloud-go-getopts/
	Datacenter string `lang:"datacenter"`

	// Image determines the operating system to be installed. A complete and
	// up-to-date list of options must be requested from the Hetzner API, but
	// hcloud-go-getopts (url) provides a static reference. The image type
	// options include "centos-7", "ubuntu-18.04", "debian-10" etc.
	// https://github.com/JefMasereel/hcloud-go-getopts/
	Image string `lang:"image"`

	// UserData can be used to run commands on the server instance at creation.
	// https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html.
	UserData string `lang:"userdata"`

	// ServerRescueMode specifies the image type used when enabling rescue mode.
	// The supported image types are "linux32", "linux64" and "freebsd64".
	// Alternatively, leave this string empty to disable rescue mode (default).
	// Other input values will not pass Validate and result in an error.
	// NOTE: rescue mode can not be enabled if the server is absent.
	// NOTE: Rescue mode can be used to log into the server over SSH and access
	// the disks when the normal OS has trouble booting on its own.
	ServerRescueMode string `lang:"serverrescuemode"`

	// ServerRescueSSHKeys can be used to select a subset of keys that should be
	// enabled for rescue mode operations over SSH. From all SSH keys known to
	// the project client, choose a subset of keys by name, as an array of
	// strings. New keys must first be added manually via the cloud console.
	// An error is thrown if a given keyname is not recognized by the client.
	// NOTE: live changes to this keylist while rescue mode is already enabled
	// are not (yet) detected or applied by CheckApply.
	// TODO: improve ssh key handling at checkApplyRescueMode and serverRebuild.
	ServerRescueSSHKeys []string `lang:"serverrescuekeys"`

	// WaitInterval is the interval in seconds that is used when waiting for
	// transient states to converge between intermediate operations. A zero
	// value causes the waiter to run without delays (burst requests). Although
	// such burst requests are allowed, it is recommended to use a wait interval
	// that keeps the total request rate under 3600 requests per hour. Take
	// these factors into account: polling rate "Meta:poll", number of active
	// resources under the same Hetzner project, and the expected rate of param
	// updates. This will help to prevent rate limit errors.
	WaitInterval uint32 `lang:"waitinterval"`

	// WaitTimeout will cancel wait loops if they do not exit cleanly before
	// the expected time in seconds, in order to detect defective loops and
	// avoid unnecessary consumption of computational resources.
	WaitTimeout uint32 `lang:"waittimeout"`
	// contains filtered or unexported fields
}

HetznerVMRes is a Hetzner cloud resource (1). It connects with the cloud API using the hcloud-go package provided by Hetzner. The API token for a new project must be generated manually, via the cloud console (2), before this resource can establish a connection with the API. One Hetzner resource represents one server instance, and multiple instances can be registered under the same project. A resource in the "absent" state only exists as a local mcl struct, and does not exist as server instance on Hetzner's side. NOTE: the Hetzner cloud console must be used to create a new project, generate the corresponding API token, and initialize the desired SSH keys. All registered SSH keys are used when creating a server, and a subset of those can be enabled for rescue mode via the "serverrescuekeys" param. NOTE: complete and up-to-date serverconfig options must be requested from the Hetzner API, but hcloud-go-getopts (3) provides a static reference. NOTE: this resources requires polling, via the "Meta:poll" param. The Hetzner API imposes a maximum rate of 3600 requests per hour that must be taken into account for intensive and/or long term operations. When running N hetzner:vm resources under the same Hetzner project, it is recommended to use a polling interval of at least N seconds. High rates of change to other params will require additional API requests at CheckApply. When frequent param updates are expected for long term operations, it is reommended to increase the polling interval again to prevent rate limit errors. NOTE: running multiple concurrent mcl scripts on the same resource might cause unexpected behavior in the API or the resource state. Use with care. TODO: build tests for hetzner:vm? But hcloud-go has no mocking package. 1) https://docs.hetzner.cloud/ 2) https://console.hetzner.cloud/ 3) https://github.com/jefmasereel/hcloud-go-getopts

func (*HetznerVMRes) CheckApply

func (obj *HetznerVMRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply checks the resource state and determines what needs to happen for the HetznerVM resource to converge. It only applies the necessary changes if the bool apply is true. If the resource requires changes, CheckApply returns false regardless of the apply value, true otherwise. Any errors that might occur are wrapped and returned. NOTE: all functions that push changes to the Hetzner instance run a waitUntil call with the appropriate exit condition before returning, such that the requested operation is confirmed before continuing. This ensures that the "server" struct always contains up-to-date info of the live instance. NOTE: this last assumption might still fail in case the same resource instance is managed by multiple running mgmt instances! TODO: possible to ensure safe concurrency?

func (*HetznerVMRes) Cleanup

func (obj *HetznerVMRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done. It deletes the authentication info before closing the resource.

func (*HetznerVMRes) Cmp

func (obj *HetznerVMRes) Cmp(r engine.Res) error

Cmp compares two resource structs. Returns nil if the comparison holds true, otherwise an error is thrown to identify the difference.

func (*HetznerVMRes) Default

func (obj *HetznerVMRes) Default() engine.Res

Default returns some conservative defaults for this resource.

func (*HetznerVMRes) Init

func (obj *HetznerVMRes) Init(init *engine.Init) error

Init runs some startup code for this resource: initialize hcloud-go client, and then build some internal flags from the given public fields.

func (*HetznerVMRes) Validate

func (obj *HetznerVMRes) Validate() error

Validate if the given param values are valid.

func (*HetznerVMRes) Watch

func (obj *HetznerVMRes) Watch(context.Context) error

Watch is not implemented for this resource, since the Hetzner API does not provide any event streams. Instead, always use polling. NOTE: HetznerPollLimit sets an explicit minimum on the polling interval.

type HostData

type HostData struct {
	// NBP is the network boot program URL. See the resources for more docs.
	NBP string
}

HostData is some data that each host will get made available to its handler.

type HostRecord

type HostRecord struct {
	IP netip.Addr

	// Expires represents the number of seconds since the epoch that this
	// lease expires at.
	Expires int
}

HostRecord is some information that we store about each reservation that we allocated. This struct is stored as a value which is mapped to by a mac address key, which is why the mac address is not stored in this record.

type HostnameRes

type HostnameRes struct {
	traits.Base // add the base methods without re-implementation

	// Hostname specifies the hostname we want to set in all of the places
	// that it's possible. This is the fallback value for all the three
	// fields below. If only this Hostname field is specified, this will set
	// all tree fields (PrettyHostname, StaticHostname, TransientHostname)
	// to this value.
	Hostname string `lang:"hostname" yaml:"hostname"`

	// PrettyHostname is a free-form UTF8 host name for presentation to the
	// user.
	PrettyHostname *string `lang:"pretty_hostname" yaml:"pretty_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.
	StaticHostname *string `lang:"static_hostname" yaml:"static_hostname"`

	// 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.
	TransientHostname *string `lang:"transient_hostname" yaml:"transient_hostname"`
	// contains filtered or unexported fields
}

HostnameRes is a resource that allows setting and watching the hostname. If you don't specify any parameters, the Name is used. The Hostname field is used if none of the other parameters are used. If the parameters are set to the empty string, then those variants are not managed by the resource.

func (*HostnameRes) CheckApply

func (obj *HostnameRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for Hostname resource.

func (*HostnameRes) Cleanup

func (obj *HostnameRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*HostnameRes) Cmp

func (obj *HostnameRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*HostnameRes) Default

func (obj *HostnameRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*HostnameRes) Init

func (obj *HostnameRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*HostnameRes) UIDs

func (obj *HostnameRes) UIDs() []engine.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(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type HostnameUID

type HostnameUID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

HostnameUID is the UID struct for HostnameRes.

type KVRes

type KVRes struct {
	traits.Base // add the base methods without re-implementation
	//traits.Groupable // TODO: it could be useful to group our writes and watches!
	traits.Refreshable
	traits.Recvable

	// Key represents the key to set. If it is not specified, the Name value
	// is used instead.
	Key string `lang:"key" yaml:"key"`

	// Value represents the string value to set. If this value is nil or,
	// undefined, then this will delete that key.
	Value *string `lang:"value" yaml:"value"`

	// Mapped specifies that we will store the value in a map with each
	// hostname as part of the key. This is very useful for exchanging
	// values when running this resource on multiple nodes simultaneously.
	// To read/write/watch a single, global key, this value should be false.
	// Note that resources may fight if more than one uses this. The `world`
	// functions like `exchange`, require this to be true, since they're
	// pulling values out of a pool that each node sets. The `world`
	// functions like `getval`, require this to be false, since they're
	// pulling values directly out of the same namespace that is shared by
	// all nodes.
	Mapped bool

	// SkipLessThan causes the value to be updated as long as it is greater.
	SkipLessThan bool `lang:"skiplessthan" yaml:"skiplessthan"`

	// SkipCmpStyle is the type of compare function used when determining if
	// the value is greater when using the SkipLessThan parameter.
	SkipCmpStyle KVResSkipCmpStyle `lang:"skipcmpstyle" yaml:"skipcmpstyle"`
	// contains filtered or unexported fields
}

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

func (obj *KVRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for Password resource. Does nothing, returns happy!

func (*KVRes) Cleanup

func (obj *KVRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*KVRes) Cmp

func (obj *KVRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*KVRes) Default

func (obj *KVRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*KVRes) Init

func (obj *KVRes) Init(init *engine.Init) error

Init initializes the resource.

func (*KVRes) Interrupt

func (obj *KVRes) Interrupt() error

Interrupt is called to ask the execution of this resource to end early.

func (*KVRes) UIDs

func (obj *KVRes) UIDs() []engine.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 (*KVRes) UnmarshalYAML

func (obj *KVRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*KVRes) Validate

func (obj *KVRes) Validate() error

Validate if the params passed in are valid data.

func (*KVRes) Watch

func (obj *KVRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

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 {
	engine.BaseUID
	// contains filtered or unexported fields
}

KVUID is the UID struct for KVRes.

type MountRes

type MountRes struct {
	traits.Base

	// State must be exists or absent. If absent, remaining fields are
	// ignored.
	State string `lang:"state" yaml:"state"`

	// Device is the location of the device or image.
	Device string `lang:"device" yaml:"device"`

	// Type of the filesystem.
	Type string `lang:"type" yaml:"type"`

	// Options are mount options.
	Options map[string]string `lang:"options" yaml:"options"`

	// Freq is the dump frequency.
	Freq int `lang:"freq" yaml:"freq"`

	// PassNo is the verification order.
	PassNo int `lang:"passno" yaml:"passno"`
	// contains filtered or unexported fields
}

MountRes is a systemd mount resource that adds/removes entries from /etc/fstab, and makes sure the defined device is mounted or unmounted accordingly. The mount point is set according to the resource's name.

func (*MountRes) CheckApply

func (obj *MountRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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 (*MountRes) Cleanup

func (obj *MountRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*MountRes) Cmp

func (obj *MountRes) Cmp(r engine.Res) error

Cmp compares two resources and return if they are equivalent.

func (*MountRes) Default

func (obj *MountRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*MountRes) Init

func (obj *MountRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*MountRes) UIDs

func (obj *MountRes) UIDs() []engine.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 (*MountRes) UnmarshalYAML

func (obj *MountRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*MountRes) Validate

func (obj *MountRes) Validate() error

Validate if the params passed in are valid data.

func (*MountRes) Watch

func (obj *MountRes) Watch(ctx context.Context) error

Watch listens for signals from the mount unit associated with the resource. It also watch for changes to /etc/fstab, where mounts are defined.

type MountUID

type MountUID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

MountUID is a unique resource identifier.

func (*MountUID) IFF

func (obj *MountUID) IFF(uid engine.ResUID) bool

IFF aka if and only if they are equivalent, return true. If not, false.

type MsgRes

type MsgRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Refreshable

	// Body is the body of the message to send.
	Body string `lang:"body" yaml:"body"`

	// Priority is the priority of the message. Currently this is one of:
	// Emerg, Alert, Crit, Err, Warning, Notice, Info, Debug.
	Priority string `lang:"priority" yaml:"priority"`

	// Fields are the key/value pairs set in the journal if we are using it.
	Fields map[string]string `lang:"fields" yaml:"fields"`

	// Journal should be true to enable systemd journaled (journald) output.
	Journal bool `lang:"journal" yaml:"journal"`

	// Syslog should be true to enable traditional syslog output. This is
	// probably going to somewhere in `/var/log/` on your filesystem.
	Syslog bool `lang:"syslog" yaml:"syslog"`
	// contains filtered or unexported fields
}

MsgRes is a resource that writes messages to logs.

func (*MsgRes) CheckApply

func (obj *MsgRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for Msg resource. Every check leads to an apply, meaning that the message is flushed to the journal.

func (*MsgRes) Cleanup

func (obj *MsgRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*MsgRes) Cmp

func (obj *MsgRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*MsgRes) Default

func (obj *MsgRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*MsgRes) Init

func (obj *MsgRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*MsgRes) UIDs

func (obj *MsgRes) UIDs() []engine.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 (*MsgRes) UnmarshalYAML

func (obj *MsgRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*MsgRes) Validate

func (obj *MsgRes) Validate() error

Validate the params that are passed to MsgRes.

func (*MsgRes) Watch

func (obj *MsgRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type MsgUID

type MsgUID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

MsgUID is a unique representation for a MsgRes object.

type NetRes

type NetRes struct {
	traits.Base // add the base methods without re-implementation

	traits.Reversible

	// State is the desired state of the interface. It can be "up", "down",
	// or the empty string to leave that unspecified.
	State string `lang:"state" yaml:"state"`

	// Addrs is the list of addresses to set on the interface. They must
	// each be in CIDR notation such as: 192.0.2.42/24 for example.
	Addrs []string `lang:"addrs" yaml:"addrs"`

	// Gateway represents the default route to set for the interface.
	Gateway string `lang:"gateway" yaml:"gateway"`

	// IPForward is a boolean that sets whether we should forward incoming
	// packets onward when this is set. It default to unspecified, which
	// downstream (in the systemd-networkd configuration) defaults to false.
	// XXX: this could also be "ipv4" or "ipv6", add those as a second option?
	IPForward *bool `lang:"ip_forward" yaml:"ip_forward"`
	// contains filtered or unexported fields
}

NetRes is a network interface resource based on netlink. It manages the state of a network link. Configuration is also stored in a networkd configuration file, so the network is available upon reboot. The name of the resource is the string representing the network interface name. This could be "eth0" for example. It supports flipping the state if you ask for it to be reversible.

func (*NetRes) CheckApply

func (obj *NetRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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 (*NetRes) Cleanup

func (obj *NetRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*NetRes) Cmp

func (obj *NetRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*NetRes) Copy

func (obj *NetRes) Copy() engine.CopyableRes

Copy copies the resource. Don't call it directly, use engine.ResCopy instead. TODO: should this copy internal state?

func (*NetRes) Default

func (obj *NetRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*NetRes) Init

func (obj *NetRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*NetRes) Reversed

func (obj *NetRes) Reversed() (engine.ReversibleRes, error)

Reversed returns the "reverse" or "reciprocal" resource. This is used to "clean" up after a previously defined resource has been removed.

func (*NetRes) UIDs

func (obj *NetRes) UIDs() []engine.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 (*NetRes) UnmarshalYAML

func (obj *NetRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*NetRes) Validate

func (obj *NetRes) Validate() error

Validate if the params passed in are valid data.

func (*NetRes) Watch

func (obj *NetRes) Watch(ctx context.Context) error

Watch listens for events from the specified interface via a netlink socket. TODO: currently gets events from ALL interfaces, would be nice to reject events from other interfaces.

type NetUID

type NetUID 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.
	engine.BaseUID
	// contains filtered or unexported fields
}

NetUID is a unique resource identifier.

func (*NetUID) IFF

func (obj *NetUID) IFF(uid engine.ResUID) bool

IFF aka if and only if they are equivalent, return true. If not, false.

type NetworkDevice

type NetworkDevice struct {
	Name string `lang:"name" yaml:"name"`
	MAC  string `lang:"mac" yaml:"mac"`
}

NetworkDevice represents a network card that is attached to the virt machine.

func (*NetworkDevice) Cmp

func (obj *NetworkDevice) Cmp(dev *NetworkDevice) error

Cmp compares two NetworkDevice's and returns an error if they are not equivalent.

func (*NetworkDevice) GetXML

func (obj *NetworkDevice) GetXML(idx int) string

GetXML returns the XML representation of this device.

type NoopRes

type NoopRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Groupable
	traits.Refreshable

	// Comment is a useless comment field that you can use however you like.
	Comment string `lang:"comment" yaml:"comment"`
	// contains filtered or unexported fields
}

NoopRes is a no-op resource that does nothing.

func (*NoopRes) CheckApply

func (obj *NoopRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for Noop resource. Does nothing, returns happy!

func (*NoopRes) Cleanup

func (obj *NoopRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*NoopRes) Cmp

func (obj *NoopRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*NoopRes) Default

func (obj *NoopRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*NoopRes) GroupCmp

func (obj *NoopRes) GroupCmp(r engine.GroupableRes) error

GroupCmp returns whether two resources can be grouped together or not.

func (*NoopRes) Init

func (obj *NoopRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*NoopRes) UIDs

func (obj *NoopRes) UIDs() []engine.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 (*NoopRes) UnmarshalYAML

func (obj *NoopRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*NoopRes) Validate

func (obj *NoopRes) Validate() error

Validate if the params passed in are valid data.

func (*NoopRes) Watch

func (obj *NoopRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type NoopUID

type NoopUID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

NoopUID is the UID struct for NoopRes.

type NspawnRes

type NspawnRes struct {
	traits.Base // add the base methods without re-implementation
	//traits.Groupable // TODO: this would be quite useful for this resource
	traits.Refreshable // needed because we embed a svc res

	// State specifies the desired state for this resource. This must be
	// either `running` or `stopped`.
	State string `lang:"state" yaml:"state"`
	// contains filtered or unexported fields
}

NspawnRes is an nspawn container resource.

func (*NspawnRes) CheckApply

func (obj *NspawnRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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) Cleanup

func (obj *NspawnRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*NspawnRes) Cmp

func (obj *NspawnRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*NspawnRes) Default

func (obj *NspawnRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*NspawnRes) Init

func (obj *NspawnRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*NspawnRes) UIDs

func (obj *NspawnRes) UIDs() []engine.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 (*NspawnRes) UnmarshalYAML

func (obj *NspawnRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*NspawnRes) Validate

func (obj *NspawnRes) Validate() error

Validate if the params passed in are valid data.

func (*NspawnRes) Watch

func (obj *NspawnRes) Watch(ctx context.Context) error

Watch for state changes and sends a message to the bus if there is a change.

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.
	engine.BaseUID
	// contains filtered or unexported fields
}

NspawnUID is a unique resource identifier.

func (*NspawnUID) IFF

func (obj *NspawnUID) IFF(uid engine.ResUID) bool

IFF aka if and only if they are equivalent, return true. If not, false.

type PanicRes

type PanicRes struct {
	traits.Base // add the base methods without re-implementation
	// contains filtered or unexported fields
}

PanicRes is a no-op resource that does nothing as quietly as possible. One of these will be added the graph if you use the panic function. (Even when it is in a non-panic mode.) This is possibly the simplest resource that exists, and in fact, everytime it is used, it will always have the same "name" value. It is only used so that there is a valid destination for the panic function.

func (*PanicRes) CheckApply

func (obj *PanicRes) CheckApply(context.Context, bool) (bool, error)

CheckApply method for Panic resource. Does nothing, returns happy!

func (*PanicRes) Cleanup

func (obj *PanicRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*PanicRes) Cmp

func (obj *PanicRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*PanicRes) Default

func (obj *PanicRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*PanicRes) Init

func (obj *PanicRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*PanicRes) UnmarshalYAML

func (obj *PanicRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*PanicRes) Validate

func (obj *PanicRes) Validate() error

Validate if the params passed in are valid data.

func (*PanicRes) Watch

func (obj *PanicRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type PasswordRes

type PasswordRes struct {
	traits.Base // add the base methods without re-implementation
	// TODO: it could be useful to group our tokens into a single write, and
	// as a result, we save inotify watches too!
	//traits.Groupable // TODO: this is doable, but probably not very useful
	traits.Refreshable
	traits.Sendable

	// Length is the number of characters to return.
	// FIXME: is uint16 too big?
	Length uint16 `lang:"length" yaml:"length"`

	// Saved caches the password in the clear locally.
	Saved bool `lang:"saved" yaml:"saved"`

	// CheckRecovery specifies that we should recover from, regenerate, and
	// carry on casually without erroring the resource if the "check"
	// facility fails. This can happen when loading a saved password from
	// disk which is not of the expected length. In this case, we'd discard
	// the old saved password and create a new one without erroring.
	CheckRecovery bool `lang:"check_recovery" yaml:"check_recovery"`
	// contains filtered or unexported fields
}

PasswordRes is a no-op resource that returns a random password string.

func (*PasswordRes) CheckApply

func (obj *PasswordRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for Password resource. Does nothing, returns happy!

func (*PasswordRes) Cleanup

func (obj *PasswordRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*PasswordRes) Cmp

func (obj *PasswordRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*PasswordRes) Default

func (obj *PasswordRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*PasswordRes) Init

func (obj *PasswordRes) Init(init *engine.Init) error

Init runs some startup code for this resource. It 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) Sends

func (obj *PasswordRes) Sends() interface{}

Sends represents the default struct of values we can send using Send/Recv.

func (*PasswordRes) UIDs

func (obj *PasswordRes) UIDs() []engine.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(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type PasswordSends

type PasswordSends struct {
	// Password is the generated password being sent.
	Password *string `lang:"password"`
	// Hashing is the algorithm used for this password. Empty is plain text.
	Hashing string // TODO: implement me
}

PasswordSends is the struct of data which is sent after a successful Apply.

type PasswordUID

type PasswordUID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

PasswordUID is the UID struct for PasswordRes.

type PippetRes

type PippetRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Refreshable

	// Type is the exact name of the wrapped Puppet resource type, e.g.
	// "file", "mount". This needs not be a core type. It can be a type
	// from a module. The Puppet installation local to the mgmt agent
	// machine must be able recognize it. It has to be a native type though,
	// as opposed to defined types from your Puppet manifest code.
	Type string `lang:"type" yaml:"type" json:"type"`

	// Title is used by Puppet as the resource title. Puppet will often
	// assign special meaning to the title, e.g. use it as the path for a
	// file resource, or the name of a package.
	Title string `lang:"title" yaml:"title" json:"title"`

	// Params is expected to be a hash in YAML format, pairing resource
	// parameter names with their respective values, e.g. { ensure: present
	// }
	Params string `lang:"params" yaml:"params" json:"params"`
	// contains filtered or unexported fields
}

PippetRes is a wrapper resource for puppet. It implements the functional equivalent of an exec resource that calls "puppet resource <type> <title> <params>", but offers superior performance through a long-running Puppet process that receives resources through a pipe (hence the name).

func (*PippetRes) CheckApply

func (obj *PippetRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply synchronizes the resource if required.

func (*PippetRes) Cleanup

func (obj *PippetRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*PippetRes) Cmp

func (obj *PippetRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*PippetRes) Default

func (obj *PippetRes) Default() engine.Res

Default returns an example Pippet resource.

func (*PippetRes) Init

func (obj *PippetRes) Init(init *engine.Init) error

Init makes sure that the PippetReceiver object is initialized.

func (*PippetRes) UIDs

func (obj *PippetRes) UIDs() []engine.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 (*PippetRes) UnmarshalYAML

func (obj *PippetRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*PippetRes) Validate

func (obj *PippetRes) Validate() error

Validate never errors out. We don't know the set of potential types that Puppet supports. Resource names are arbitrary. We cannot really validate the parameter YAML, because we cannot assume that it can be unmarshalled into a map[string]string; Puppet supports complex parameter values.

func (*PippetRes) Watch

func (obj *PippetRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type PippetResult

type PippetResult struct {
	Error     bool
	Failed    bool
	Changed   bool
	Exception string
}

PippetResult is the structured return value type for the PippetReceiver's Apply function.

type PippetRunner

type PippetRunner interface {
	LockApply()
	UnlockApply()
	InputStream() io.WriteCloser
	OutputStream() io.ReadCloser
}

PippetRunner is the interface used to communicate with the PippetReceiver object. Its main purpose is dependency injection.

type PippetUID

type PippetUID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

PippetUID is the UID struct for PippetRes.

type PkgFileUID

type PkgFileUID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

PkgFileUID is the UID struct for PkgRes files.

type PkgRes

type PkgRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Edgeable
	traits.Groupable

	// State determines if we want to install or uninstall the package, and
	// what version we want to pin if any. Valid values include: installed,
	// uninstalled, newest, and `version`, where you just put the raw
	// version string desired.
	State string `lang:"state" yaml:"state"`

	// AllowUntrusted specifies if we want to allow untrusted packages to be
	// installed. Please see the PackageKit documentation for more
	// information.
	AllowUntrusted bool `lang:"allowuntrusted" yaml:"allowuntrusted"`

	// AllowNonFree specifies if we want to allow nonfree packages to be
	// found? Please see the PackageKit documentation for more information.
	AllowNonFree bool `lang:"allownonfree" yaml:"allownonfree"`

	// AllowUnsupported specifies if we want to unsupported packages to be
	// found? Please see the PackageKit documentation for more information.
	AllowUnsupported bool `lang:"allowunsupported" yaml:"allowunsupported"`
	// contains filtered or unexported fields
}

PkgRes is a package resource for packagekit.

func (*PkgRes) Adapts

func (obj *PkgRes) Adapts(r engine.CompatibleRes) error

Adapts compares two resources and returns an error if they are not able to be equivalently output compatible.

func (*PkgRes) AutoEdges

func (obj *PkgRes) AutoEdges() (engine.AutoEdge, error)

AutoEdges produces an object which generates a minimal pkg file optimization sequence of edges.

func (*PkgRes) CheckApply

func (obj *PkgRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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) Cleanup

func (obj *PkgRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*PkgRes) Cmp

func (obj *PkgRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*PkgRes) Copy

func (obj *PkgRes) Copy() engine.CopyableRes

Copy copies the resource. Don't call it directly, use engine.ResCopy instead. TODO: should this copy internal state?

func (*PkgRes) Default

func (obj *PkgRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*PkgRes) GroupCmp

func (obj *PkgRes) GroupCmp(r engine.GroupableRes) error

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) Init

func (obj *PkgRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*PkgRes) Merge

Merge returns the best equivalent of the two resources. They must satisfy the Adapts test for this to work.

func (*PkgRes) UIDs

func (obj *PkgRes) UIDs() []engine.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 (*PkgRes) UnmarshalYAML

func (obj *PkgRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*PkgRes) Validate

func (obj *PkgRes) Validate() error

Validate checks if the resource data structure was populated correctly.

func (*PkgRes) Watch

func (obj *PkgRes) Watch(ctx context.Context) error

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() []engine.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 {
	engine.BaseUID
	// contains filtered or unexported fields
}

PkgUID is the main UID struct for PkgRes.

func (*PkgUID) IFF

func (obj *PkgUID) IFF(uid engine.ResUID) bool

IFF aka if and only if they are equivalent, return true. If not, false.

type PrintRes

type PrintRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Groupable
	traits.Recvable
	traits.Refreshable

	// Msg is the message to display.
	Msg string `lang:"msg" yaml:"msg"`

	// RefreshOnly is an option that causes the message to be printed only
	// when notified by another resource. When set to true, this resource
	// cannot be autogrouped.
	RefreshOnly bool `lang:"refresh_only" yaml:"refresh_only"`
	// contains filtered or unexported fields
}

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

func (obj *PrintRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for Print resource. Does nothing, returns happy!

func (*PrintRes) Cleanup

func (obj *PrintRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*PrintRes) Cmp

func (obj *PrintRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*PrintRes) Default

func (obj *PrintRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*PrintRes) GroupCmp

func (obj *PrintRes) GroupCmp(r engine.GroupableRes) error

GroupCmp returns whether two resources can be grouped together or not.

func (*PrintRes) Init

func (obj *PrintRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*PrintRes) UIDs

func (obj *PrintRes) UIDs() []engine.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 (*PrintRes) UnmarshalYAML

func (obj *PrintRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*PrintRes) Validate

func (obj *PrintRes) Validate() error

Validate if the params passed in are valid data.

func (*PrintRes) Watch

func (obj *PrintRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type PrintUID

type PrintUID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

PrintUID is the UID struct for PrintRes.

type SSHKeyInfo

type SSHKeyInfo struct {
	// User is the user account we want to add this key to.
	User string `lang:"user" yaml:"user"`

	// Type of SSH key. Usually "ssh-rsa" for example.
	Type string `lang:"type" yaml:"type"`

	// Key is the base64 encoded key.
	Key string `lang:"key" yaml:"key"`

	// Comment is a short comment about this entry.
	Comment string `lang:"comment" yaml:"comment"`
}

SSHKeyInfo stores information about user SSH keys. It is used to add entries to the authorized_keys file in the target vm.

func (*SSHKeyInfo) AuthorizedKeyLine

func (obj *SSHKeyInfo) AuthorizedKeyLine() string

AuthorizedKeyLine returns the valid line for the authorized_keys entry. Make sure you've run Validate before using this.

func (*SSHKeyInfo) Cmp

func (obj *SSHKeyInfo) Cmp(x *SSHKeyInfo) error

Cmp compares two of these and returns an error if they are not equivalent.

func (*SSHKeyInfo) SSHInjectLine

func (obj *SSHKeyInfo) SSHInjectLine() string

SSHInjectLine returns the valid arg for the --ssh-inject command. Make sure you've run Validate before using this.

func (*SSHKeyInfo) Validate

func (obj *SSHKeyInfo) Validate() error

Validate reports any problems with the struct definition.

type SvcRes

type SvcRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Edgeable
	traits.Groupable
	traits.Refreshable

	// State is the desired state for this resource. Valid values include:
	// running, stopped, and undefined (empty string).
	State string `lang:"state" yaml:"state"`

	// Startup specifies what should happen on startup. Values can be:
	// enabled, disabled, and undefined (empty string).
	Startup string `lang:"startup" yaml:"startup"`

	// Session specifies if this is for a system service (false) or a user
	// session specific service (true).
	Session bool `lang:"session" yaml:"session"` // user session (true) or system?
	// contains filtered or unexported fields
}

SvcRes is a service resource for systemd units.

func (*SvcRes) AutoEdges

func (obj *SvcRes) AutoEdges() (engine.AutoEdge, error)

AutoEdges returns the AutoEdge interface. In this case, systemd unit file resources and cron (systemd-timer) resources.

func (*SvcRes) CheckApply

func (obj *SvcRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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) Cleanup

func (obj *SvcRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*SvcRes) Cmp

func (obj *SvcRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*SvcRes) Default

func (obj *SvcRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*SvcRes) Init

func (obj *SvcRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*SvcRes) UIDs

func (obj *SvcRes) UIDs() []engine.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 (*SvcRes) UnmarshalYAML

func (obj *SvcRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*SvcRes) Validate

func (obj *SvcRes) Validate() error

Validate checks if the resource data structure was populated correctly.

func (*SvcRes) Watch

func (obj *SvcRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

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() []engine.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 SvcResAutoEdgesCron

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

SvcResAutoEdgesCron holds the state of the svc -> cron auto edge generator.

func (*SvcResAutoEdgesCron) Next

func (obj *SvcResAutoEdgesCron) Next() []engine.ResUID

Next returns the next automatic edge.

func (*SvcResAutoEdgesCron) Test

func (obj *SvcResAutoEdgesCron) Test([]bool) bool

Test takes the output of the last call to Next() and outputs true 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.
	engine.BaseUID
	// contains filtered or unexported fields
}

SvcUID is the UID struct for SvcRes.

func (*SvcUID) IFF

func (obj *SvcUID) IFF(uid engine.ResUID) bool

IFF aka if and only if they are equivalent, return true. If not, false.

type SysctlRes

type SysctlRes struct {
	traits.Base // add the base methods without re-implementation

	// Value is the string value to set. Make sure you specify it in the
	// same format that the kernel parses it as to avoid automation
	// "flapping". You can test this by writing a value to the correct
	// /proc/sys/ path entry with `echo foo >` and then reading it back out
	// and seeing what the "parsed" correct format is. You must not include
	// the trailing newline which is present in the readback for all values.
	Value string `lang:"value" yaml:"value"`

	// Runtime specifies whether this value should be set immediately. It
	// defaults to true. If this is not set, then the value must be set in a
	// file and the machine will have to reboot for the setting to take
	// effect.
	Runtime bool `lang:"runtime" yaml:"runtime"`

	// Persist specifies whether this value should be stored on disk where
	// it will persist across reboots. It defaults to true. Keep in mind,
	// that if this is not used, but `Runtime` is true, then the value will
	// be restored anyways if `mgmt` runs on boot, which may be what you
	// want anyways.
	Persist bool `lang:"persist" yaml:"persist"`

	// Filename is the full path for the persistence file which is usually
	// read on boot. We usually use entries in the /etc/sysctl.d/ directory.
	// By convention, they end in .conf and start with a numeric prefix and
	// a dash. For example: /etc/sysctl.d/10-dmesg.conf for example. If this
	// is omitted, the filename will be chosen automatically.
	Filename string `lang:"path" yaml:"path"`
	// contains filtered or unexported fields
}

SysctlRes is a resource for setting kernel parameters. TODO: Add a sysctl:clean resource that removes any unmanaged files from /etc/sysctl.d/ and optionally blanks out the stock /etc/sysctl.conf file too.

func (*SysctlRes) CheckApply

func (obj *SysctlRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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 (*SysctlRes) Cleanup

func (obj *SysctlRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*SysctlRes) Cmp

func (obj *SysctlRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*SysctlRes) Default

func (obj *SysctlRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*SysctlRes) Init

func (obj *SysctlRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*SysctlRes) UnmarshalYAML

func (obj *SysctlRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*SysctlRes) Validate

func (obj *SysctlRes) Validate() error

Validate reports any problems with the struct definition.

func (*SysctlRes) Watch

func (obj *SysctlRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events. This one watches the on disk filename if it creates one, as well as the runtime value the kernel has stored!

type TFTPFileRes

type TFTPFileRes struct {
	traits.Base      // add the base methods without re-implementation
	traits.Edgeable  // XXX: add autoedge support
	traits.Groupable // can be grouped into TFTPServerRes

	// Server is the name of the tftp server resource to group this into. If
	// it is omitted, and there is only a single tftp resource, then it will
	// be grouped into it automatically. If there is more than one main tftp
	// resource being used, then the grouping behaviour is *undefined* when
	// this is not specified, and it is not recommended to leave this blank!
	Server string `lang:"server" yaml:"server"`

	// Filename is the name of the file this data should appear as on the
	// tftp server.
	Filename string `lang:"filename" yaml:"filename"`

	// Path is the absolute path to a file that should be used as the source
	// for this file resource. It must not be combined with the data field.
	Path string `lang:"path" yaml:"path"`

	// Data is the file content that should be used as the source for this
	// file resource. It must not be combined with the path field.
	// TODO: should this be []byte instead?
	Data string `lang:"data" yaml:"data"`
	// contains filtered or unexported fields
}

TFTPFileRes is a file that exists within a tftp server. The name is used as the public path of the file, unless the filename field is specified, and in that case it is used instead. The way this works is that it autogroups at runtime with an existing tftp resource, and in doing so makes the file associated with this resource available for serving from that tftp server.

func (*TFTPFileRes) CheckApply

func (obj *TFTPFileRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply never has anything to do for this resource, so it always succeeds.

func (*TFTPFileRes) Cleanup

func (obj *TFTPFileRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*TFTPFileRes) Cmp

func (obj *TFTPFileRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*TFTPFileRes) Default

func (obj *TFTPFileRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*TFTPFileRes) Init

func (obj *TFTPFileRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*TFTPFileRes) UnmarshalYAML

func (obj *TFTPFileRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*TFTPFileRes) Validate

func (obj *TFTPFileRes) Validate() error

Validate checks if the resource data structure was populated correctly.

func (*TFTPFileRes) Watch

func (obj *TFTPFileRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events. This particular one does absolutely nothing but block until we've received a done signal.

type TFTPServerRes

type TFTPServerRes struct {
	traits.Base      // add the base methods without re-implementation
	traits.Edgeable  // XXX: add autoedge support
	traits.Groupable // can have TFTPFileRes grouped into it

	// Address is the listen address to use for the tftp server. It is
	// common to use `:69` (the standard) to listen on UDP port 69 on all
	// addresses.
	Address string `lang:"address" yaml:"address"`

	// Timeout is the timeout in seconds to use for server connections.
	Timeout uint64 `lang:"timeout" yaml:"timeout"`

	// Root is the root directory that we should serve files from. If it is
	// not specified, then it is not used. Any tftp file resources will have
	// precedence over anything in here, in case the same path exists twice.
	// TODO: should we have a flag to determine the precedence rules here?
	Root string `lang:"root" yaml:"root"`
	// contains filtered or unexported fields
}

TFTPServerRes is a tftp server resource. It serves files, but does not actually apply any state. The name is used as the address to listen on, unless the Address field is specified, and in that case it is used instead. This resource can offer up files for serving that are specified either inline in this resource by specifying a tftp root, or as tftp:file resources which will get autogrouped into this resource at runtime. The two methods can be combined as well.

func (*TFTPServerRes) CheckApply

func (obj *TFTPServerRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply never has anything to do for this resource, so it always succeeds. It does however check that certain runtime requirements (such as the Root dir existing if one was specified) are fulfilled.

func (*TFTPServerRes) Cleanup

func (obj *TFTPServerRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*TFTPServerRes) Cmp

func (obj *TFTPServerRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*TFTPServerRes) Copy

func (obj *TFTPServerRes) Copy() engine.CopyableRes

Copy copies the resource. Don't call it directly, use engine.ResCopy instead. TODO: should this copy internal state?

func (*TFTPServerRes) Default

func (obj *TFTPServerRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*TFTPServerRes) GroupCmp

func (obj *TFTPServerRes) GroupCmp(r engine.GroupableRes) error

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 (*TFTPServerRes) Init

func (obj *TFTPServerRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*TFTPServerRes) UnmarshalYAML

func (obj *TFTPServerRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*TFTPServerRes) Validate

func (obj *TFTPServerRes) Validate() error

Validate checks if the resource data structure was populated correctly.

func (*TFTPServerRes) Watch

func (obj *TFTPServerRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type TarRes

type TarRes struct {
	traits.Base // add the base methods without re-implementation

	// Path, which defaults to the name if not specified, represents the
	// destination path for the compressed file being created. It must be an
	// absolute path, and as a result must start with a slash. Since it is a
	// file, it must not end with a slash.
	Path string `lang:"path" yaml:"path"`

	// Inputs represents the list of files to be compressed. They must each
	// be absolute paths of either single files or directories, and as a
	// result, each must start with a slash. Directories must end with a
	// slash and files must not.
	Inputs []string `lang:"inputs" yaml:"inputs"`

	// Format is the header format to use. If you change this, then the
	// file will get rearchived. The strange thing is that it seems the
	// header format is stored for each individual file. The available
	// values are: const.res.tar.format.unknown, const.res.tar.format.ustar,
	// const.res.tar.format.pax, and const.res.tar.format.gnu which have
	// values of 0, 2, 4, and 8 respectively.
	Format int `lang:"format" yaml:"format"`
	// contains filtered or unexported fields
}

TarRes is a resource that archives a number of paths using tar, thus combining them into a single file. The name of the resource is the path to the resultant archive file. The input comes from a list of paths which can be either files or directories or both. Directories are added recursively of course. This uses hashes to determine if something was changed, so as a result, this may not be suitable if you can create a sha256 hash collision. TODO: support send/recv to send the output instead of writing to a file?

func (*TarRes) CheckApply

func (obj *TarRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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. This is where we actually do the archiving into a tar file work when needed.

func (*TarRes) Cleanup

func (obj *TarRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*TarRes) Cmp

func (obj *TarRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*TarRes) Default

func (obj *TarRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*TarRes) Init

func (obj *TarRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*TarRes) UnmarshalYAML

func (obj *TarRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*TarRes) Validate

func (obj *TarRes) Validate() error

Validate if the params passed in are valid data.

func (*TarRes) Watch

func (obj *TarRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type TestRes

type TestRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Groupable
	traits.Refreshable
	traits.Sendable
	traits.Recvable

	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"`

	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"`

	// Int8PtrPtrPtr 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 {
		SomeBool  bool    `lang:"somebool" yaml:"somebool"`
		SomeStr   string  `lang:"somestr" yaml:"somestr"`
		SomeInt   int64   `lang:"someint" yaml:"someint"`
		SomeFloat float64 `lang:"somefloat" yaml:"somefloat"`
		// contains filtered or unexported fields
	} `lang:"mixedstruct" yaml:"mixedstruct"`
	Interface interface{} `lang:"interface" yaml:"interface"`

	AnotherStr string `lang:"anotherstr" yaml:"anotherstr"`

	// Func1 passes the value 42 to the input and returns a string.
	Func1 func(int) string `lang:"func1" yaml:"func1"`

	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?
	SendValue     string    `lang:"sendvalue" yaml:"send_value"`         // what value should we send?
	ExpectRecv    *[]string `lang:"expectrecv" yaml:"expect_recv"`       // what keys should we expect from send/recv?
	OnlyShow      []string  `lang:"onlyshow" yaml:"only_show"`           // what values do we show?

	Comment string `lang:"comment" yaml:"comment"`
	// contains filtered or unexported fields
}

TestRes is a resource that is mostly harmless and is used for internal tests.

func (*TestRes) CheckApply

func (obj *TestRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for Test resource. Does nothing, returns happy!

func (*TestRes) Cleanup

func (obj *TestRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*TestRes) Cmp

func (obj *TestRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*TestRes) Default

func (obj *TestRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*TestRes) GroupCmp

func (obj *TestRes) GroupCmp(r engine.GroupableRes) error

GroupCmp returns whether two resources can be grouped together or not.

func (*TestRes) Init

func (obj *TestRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*TestRes) Sends

func (obj *TestRes) Sends() interface{}

Sends represents the default struct of values we can send using Send/Recv.

func (*TestRes) UIDs

func (obj *TestRes) UIDs() []engine.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 (*TestRes) UnmarshalYAML

func (obj *TestRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*TestRes) Validate

func (obj *TestRes) Validate() error

Validate if the params passed in are valid data.

func (*TestRes) Watch

func (obj *TestRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type TestSends

type TestSends struct {
	// Hello is some value being sent.
	Hello  *string `lang:"hello" yaml:"hello"`
	Answer int     `lang:"answer" yaml:"answer"` // some other value being sent
}

TestSends is the struct of data which is sent after a successful Apply.

type TestUID

type TestUID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

TestUID is the UID struct for TestRes.

type TimerRes

type TimerRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Refreshable

	// Interval between runs in seconds.
	Interval uint32 `lang:"interval" yaml:"interval"`
	// contains filtered or unexported fields
}

TimerRes is a timer resource for time based events. It outputs an event every interval seconds.

func (*TimerRes) CheckApply

func (obj *TimerRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for Timer resource. Triggers a timer reset on notify.

func (*TimerRes) Cleanup

func (obj *TimerRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*TimerRes) Cmp

func (obj *TimerRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*TimerRes) Default

func (obj *TimerRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*TimerRes) Init

func (obj *TimerRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*TimerRes) UIDs

func (obj *TimerRes) UIDs() []engine.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 (*TimerRes) UnmarshalYAML

func (obj *TimerRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*TimerRes) Validate

func (obj *TimerRes) Validate() error

Validate the params that are passed to TimerRes.

func (*TimerRes) Watch

func (obj *TimerRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type TimerUID

type TimerUID struct {
	engine.BaseUID
	// contains filtered or unexported fields
}

TimerUID is the UID struct for TimerRes.

type UserRes

type UserRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Edgeable

	// State is either exists or absent.
	State string `lang:"state" yaml:"state"`

	// UID specifies the usually unique user ID. It must be unique unless
	// AllowDuplicateUID is true.
	UID *uint32 `lang:"uid" yaml:"uid"`

	// GID of the user's primary group.
	GID *uint32 `lang:"gid" yaml:"gid"`

	// Group is the name of the user's primary group.
	Group *string `lang:"group" yaml:"group"`

	// Groups are a list of supplemental groups.
	Groups []string `lang:"groups" yaml:"groups"`

	// HomeDir is the path to the user's home directory.
	HomeDir *string `lang:"homedir" yaml:"homedir"`

	// AllowDuplicateUID is needed for a UID to be non-unique. This is rare
	// but happens if you want more than one username to access the
	// resources of the same UID. See the --non-unique flag in `useradd`.
	AllowDuplicateUID bool `lang:"allowduplicateuid" yaml:"allowduplicateuid"`
	// contains filtered or unexported fields
}

UserRes is a user account resource.

func (*UserRes) AutoEdges

func (obj *UserRes) AutoEdges() (engine.AutoEdge, error)

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

func (obj *UserRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for User resource.

func (*UserRes) Cleanup

func (obj *UserRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*UserRes) Cmp

func (obj *UserRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*UserRes) Default

func (obj *UserRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*UserRes) Init

func (obj *UserRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*UserRes) UIDs

func (obj *UserRes) UIDs() []engine.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 (*UserRes) UnmarshalYAML

func (obj *UserRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*UserRes) Validate

func (obj *UserRes) Validate() error

Validate if the params passed in are valid data.

func (*UserRes) Watch

func (obj *UserRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type UserResAutoEdges

type UserResAutoEdges struct {
	UIDs []engine.ResUID
	// contains filtered or unexported fields
}

UserResAutoEdges holds the state of the auto edge generator.

func (*UserResAutoEdges) Next

func (obj *UserResAutoEdges) Next() []engine.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 {
	engine.BaseUID
	// contains filtered or unexported fields
}

UserUID is the UID struct for UserRes.

func (*UserUID) IFF

func (obj *UserUID) IFF(uid engine.ResUID) bool

IFF aka if and only if they are equivalent, return true. If not, false.

type ValueRes

type ValueRes struct {
	traits.Base // add the base methods without re-implementation

	//traits.Groupable // TODO: this is doable, but probably not very useful
	traits.Sendable
	traits.Recvable

	// Any is an arbitrary value to store in this resource. It can also be
	// sent via send/recv and received by the same mechanism as well. The
	// received value overwrites this value for the lifetime of the
	// resource. It is interface{} because it can hold any type. It has
	// pointer because it is only set if an actual value exists.
	Any *interface{} `lang:"any" yaml:"any"`
	// contains filtered or unexported fields
}

ValueRes is a no-op resource that accepts a value normally or via send/recv and it sends it via send/recv as well.

XXX: intermediate chained values being used for send/recv must have a temporary placeholder value set or we'll get an invalid value error. This can be fixed eventually when we expand the resource API. See the Default method of this resource for more information.

func (*ValueRes) CheckApply

func (obj *ValueRes) CheckApply(ctx context.Context, apply bool) (bool, error)

CheckApply method for Value resource. Does nothing, returns happy!

func (*ValueRes) Cleanup

func (obj *ValueRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*ValueRes) Cmp

func (obj *ValueRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*ValueRes) Default

func (obj *ValueRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*ValueRes) Init

func (obj *ValueRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*ValueRes) Sends

func (obj *ValueRes) Sends() interface{}

Sends represents the default struct of values we can send using Send/Recv.

func (*ValueRes) UnmarshalYAML

func (obj *ValueRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*ValueRes) Validate

func (obj *ValueRes) Validate() error

Validate if the params passed in are valid data.

func (*ValueRes) Watch

func (obj *ValueRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type ValueSends

type ValueSends struct {
	// Any is the generated value being sent. It is interface{} because it
	// can hold any type. It has pointer because it is only set if an actual
	// value is actually being sent.
	Any *interface{} `lang:"any"`
}

ValueSends is the struct of data which is sent after a successful Apply.

type VirtAuth

type VirtAuth struct {
	Username string `lang:"username" yaml:"username"`
	Password string `lang:"password" yaml:"password"`
}

VirtAuth is used to pass credentials to libvirt.

func (*VirtAuth) Cmp

func (obj *VirtAuth) Cmp(auth *VirtAuth) error

Cmp compares two VirtAuth structs. It errors if they are not identical.

type VirtBuilderRes

type VirtBuilderRes struct {
	traits.Base // add the base methods without re-implementation

	// Output is the full absolute file path where the image will be
	// created. If this file exists, then no action will be performed.
	// TODO: Consider adding a "overwrite" type mechanism in the future,
	// when we can find a safe way to do so.
	Output string `lang:"output" yaml:"output"`

	// OSVersion specifies which distro and version to use for installation.
	// You will need to pick from the output of `virt-builder --list`.
	OSVersion string `lang:"os_version" yaml:"os_version"`

	// Arch specifies the CPU architecture to use for this machine. You will
	// need to pick from the output of `virt-builder --list`. Note that not
	// all OSVersion+Arch combinations may exist.
	Arch string `lang:"arch" yaml:"arch"`

	// Hostname for the new machine.
	Hostname string `lang:"hostname" yaml:"hostname"`

	// Format is the disk image format. You likely want "raw" or "qcow2".
	Format string `lang:"format" yaml:"format"`

	// Size is the disk size of the new virtual machine in bytes.
	Size int `lang:"size" yaml:"size"`

	// Packages is the list of packages to install. If Bootstrap is true,
	// then it will add additional packages that we install if needed.
	Packages []string `lang:"packages" yaml:"packages"`

	// Update specifies that we should update the installed packages during
	// image build. This defaults to true.
	Update bool `lang:"update" yaml:"update"`

	// SelinuxRelabel specifies that we should do an selinux relabel on the
	// final image. This defaults to true.
	SelinuxRelabel bool `lang:"selinux_relabel" yaml:"selinux_relabel"`

	// NoSetup can be set to true to disable trying to install the package
	// for the virt-builder binary.
	NoSetup bool `lang:"no_setup" yaml:"no_setup"`

	// SSHKeys is a list of additional keys to add to the machine. This is
	// not a map because you may wish to add more than one to that user
	// account.
	SSHKeys []*SSHKeyInfo `lang:"ssh_keys" yaml:"ssh_keys"`

	// RootSSHInject disables installing the root ssh key into the new vm.
	// If one is not present, then nothing is done.	This defaults to true.
	RootSSHInject bool `lang:"root_ssh_inject" yaml:"root_ssh_inject"`

	// Bootstrap can be set to false to disable any automatic bootstrapping
	// of running the mgmt binary on first boot. If this is set, we will
	// attempt to copy the mgmt binary in, and then run it. This also adds
	// additional packages to install which are needed to bootstrap mgmt.
	// This defaults to true.
	// TODO: This does not yet support multi or cross arch.
	// FIXME: This doesn't kick off mgmt runs yet.
	Bootstrap bool `lang:"bootstrap" yaml:"bootstrap"`

	// LogOutput logs the output of running this command to a file in the
	// special $vardir directory. It defaults to true. Keep in mind that if
	// you let virt-builder choose the password randomly, it will be output
	// in these logs in cleartext!
	LogOutput bool `lang:"log_output" yaml:"log_output"`

	// Tweaks adds some random tweaks to work around common bugs. This
	// defaults to true.
	Tweaks bool `lang:"tweaks" yaml:"tweaks"`
	// contains filtered or unexported fields
}

VirtBuilderRes is a resource for building virtual machine images. It is based on the amazing virt-builder tool which is part of the guestfs suite of tools. TODO: Add autoedges with the virt resource disk path!

func (*VirtBuilderRes) CheckApply

func (obj *VirtBuilderRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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 (*VirtBuilderRes) Cleanup

func (obj *VirtBuilderRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*VirtBuilderRes) Cmp

func (obj *VirtBuilderRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*VirtBuilderRes) Default

func (obj *VirtBuilderRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*VirtBuilderRes) Init

func (obj *VirtBuilderRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*VirtBuilderRes) UnmarshalYAML

func (obj *VirtBuilderRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*VirtBuilderRes) Validate

func (obj *VirtBuilderRes) Validate() error

Validate reports any problems with the struct definition.

func (*VirtBuilderRes) Watch

func (obj *VirtBuilderRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events. This one watches the on disk filename if it creates one, as well as the runtime value the kernel has stored!

type VirtRes

type VirtRes struct {
	traits.Base // add the base methods without re-implementation
	traits.Refreshable

	// URI is the libvirt connection URI, eg: `qemu:///session`.
	URI string `lang:"uri" yaml:"uri"`
	// State is the desired vm state. Possible values include: `running`,
	// `paused` and `shutoff`.
	State string `lang:"state" yaml:"state"`
	// Transient is whether the vm is defined (false) or undefined (true).
	Transient bool `lang:"transient" yaml:"transient"`

	// CPUs is the desired cpu count of the machine.
	CPUs uint `lang:"cpus" yaml:"cpus"`
	// MaxCPUs is the maximum number of cpus allowed in the machine. You
	// need to set this so that on boot the `hardware` knows how many cpu
	// `slots` it might need to make room for.
	MaxCPUs uint `lang:"maxcpus" yaml:"maxcpus"`
	// HotCPUs specifies whether we can hot plug and unplug cpus.
	HotCPUs bool `lang:"hotcpus" yaml:"hotcpus"`
	// Memory is the size in KBytes of memory to include in the machine.
	Memory uint64 `lang:"memory" yaml:"memory"`

	// OSInit is the init used by lxc.
	OSInit string `lang:"osinit" yaml:"osinit"`
	// Boot is the boot order. Values are `fd`, `hd`, `cdrom` and `network`.
	Boot []string `lang:"boot" yaml:"boot"`
	// Disk is the list of disk devices to include.
	Disk []*DiskDevice `lang:"disk" yaml:"disk"`
	// CdRom is the list of cdrom devices to include.
	CDRom []*CDRomDevice `lang:"cdrom" yaml:"cdrom"`
	// Network is the list of network devices to include.
	Network []*NetworkDevice `lang:"network" yaml:"network"`
	// Filesystem is the list of file system devices to include.
	Filesystem []*FilesystemDevice `lang:"filesystem" yaml:"filesystem"`

	// Auth points to the libvirt credentials to use if any are necessary.
	Auth *VirtAuth `lang:"auth" yaml:"auth"`

	// RestartOnDiverge is the restart policy, and can be: `ignore`,
	// `ifneeded` or `error`.
	RestartOnDiverge string `lang:"restartondiverge" yaml:"restartondiverge"`
	// RestartOnRefresh specifies if we restart on refresh signal.
	RestartOnRefresh bool `lang:"restartonrefresh" yaml:"restartonrefresh"`
	// 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. TODO: some values inside here should be enum's!

func (*VirtRes) CheckApply

func (obj *VirtRes) CheckApply(ctx context.Context, apply bool) (bool, error)

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) Cleanup

func (obj *VirtRes) Cleanup() error

Cleanup is run by the engine to clean up after the resource is done.

func (*VirtRes) Cmp

func (obj *VirtRes) Cmp(r engine.Res) error

Cmp compares two resources and returns an error if they are not equivalent.

func (*VirtRes) Default

func (obj *VirtRes) Default() engine.Res

Default returns some sensible defaults for this resource.

func (*VirtRes) Init

func (obj *VirtRes) Init(init *engine.Init) error

Init runs some startup code for this resource.

func (*VirtRes) UIDs

func (obj *VirtRes) UIDs() []engine.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 (*VirtRes) UnmarshalYAML

func (obj *VirtRes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is the custom unmarshal handler for this struct. It is primarily useful for setting the defaults.

func (*VirtRes) Validate

func (obj *VirtRes) Validate() error

Validate if the params passed in are valid data.

func (*VirtRes) Watch

func (obj *VirtRes) Watch(ctx context.Context) error

Watch is the primary listener for this resource and it outputs events.

type VirtUID

type VirtUID struct {
	engine.BaseUID
}

VirtUID is the UID struct for FileRes.

Directories

Path Synopsis
Package packagekit provides an interface to interact with packagekit.
Package packagekit provides an interface to interact with packagekit.

Jump to

Keyboard shortcuts

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