Documentation ¶
Index ¶
Constants ¶
const ( // VarDatadir is the variable name that // idenfies a Service's data directory path. VarDatadir = "datadir" // VarOpenTag is the string opening a variable name // to be replaced with its real value. VarOpenTag = "{{" // VarParentSep separates parent service's name with // parent service's variable name, when addressing a parent's variable. VarParentSep = "." // TemplateOpenTag is the string closing a variable name // to be replaced with its real value. VarCloseTag = "}}" )
Variables ¶
var ( // DefaultPkgManager is the default package manager command to install OS packages. DefaultPkgManager = []string{"pkcon", "install", "-y"} )
Functions ¶
This section is empty.
Types ¶
type DepSet ¶
type DepSet struct { *set.Set[string] }
DepSet is an unordered set of Service names.
func NewDepSetFrom ¶
NewDepSetFrom creates a DepSet from a list of Service names.
func (*DepSet) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface.
type FilePath ¶
FilePath is a filesystem file path with its file mode.
func (*FilePath) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface.
type Service ¶
type Service struct { // Name uniquely identifies a Service. Name string `yaml:"-"` // Depends is a set of Service names upon which this Service depends. Depends *DepSet `yaml:"depends"` // Setup is a script (UNIX Shell or Powershell, depending on the operating system) // to run before reinstalling and/or restoring any resources. Setup *string `yaml:"setup"` // PkgManager is combination of command name // and arguments to reinstall operating system packages. // It must accept a list of package names appended to it. PkgManager []string `yaml:"pkgmanager"` // Packages is a list of operating system packages to reinstall. // It will be appended as-is to PkgManager. Packages []string `yaml:"packages"` // Links is a collection of symlinks to restore. Their source path // is relative to Service's linkdir. Links map[string]FilePath `yaml:"links"` // Variables is a collection of local variables associated to this Service. // A template engine may use them to edit files in place before copying them, // or to customize Setup and Finalize scripts. // Variables will always contain at least VarDatadir of Datadir kind. Variables map[string]VarValue `yaml:"variables"` // Copies is a collection of files to copy. Their source path // is relative to Service's datadir. A template engine may use Variables // to customize the content. Copies map[string]FilePath `yaml:"copies"` // Setup is a script (UNIX Shell or Powershell, depending on the operating system) // to run after reinstalling and/or restoring any resources. Finalize *string `yaml:"finalize"` }
Service is a collection of resources to reinstall/restore on an operating system. All fields except Name are optional.
func New ¶
New creates a Service with a given name. Variables will contain VarDatadir and PkgManager will be DefaultPkgManager.
func NewFromYAML ¶
NewFromYAML creates a Service with a given name whose fields are defined by a buffered YAML document.
func NewFromYAMLReader ¶
NewFromYAML creates a Service with a given name whose fields are defined by a streaming YAML document.
type VarKind ¶
type VarKind string
VarKind is a kind of variable. Any non-ClearText kind will require a solver to extract the value.
type VarValue ¶
type VarValue struct { // Kind is the variable kind. Unless it's ClearText, a solver is required // to get the real value. Kind VarKind `yaml:"kind"` // Value is either the final value, if Kind is ClearText, or an intermediate value. Value string `yaml:"value"` }
VarValue is a variable's value.
func (*VarValue) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface.