Documentation ¶
Index ¶
- Constants
- Variables
- func CommandFalse(command string) bool
- func CommandOutput(command string) string
- func CommandTrue(command string) bool
- func DirExists(path string) bool
- func ExpandPath(path string) string
- func ExpandPathRoot(path string) string
- func FileContents(path string) string
- func FileExists(path string) bool
- func FileSize(path string) int64
- func IsDirectory(path string) bool
- func IsRoot() bool
- func IsUbuntu() bool
- func LinkExists(path string) bool
- func ListFiles(path string) (files []string, err error)
- func Log(v ...interface{})
- func LoggerOutput(resource, action string, v ...interface{}) string
- func MatchChmod(path string, perms fs.FileMode) bool
- func MatchChown(path string, user, group int) bool
- func PrependSudo(args []string) []string
- func RunCommand(command ...string) error
- func SudoCommand(command ...string) error
- func TmpFile(path string) string
- type Configs
- type Error
- type Logger
- type Manifest
- type PlatformAttributes
- type Resource
- type ResourceAttributes
- type ResourceID
- type ResourceKind
- type ResourceParams
- type Status
- type SystemAttributes
Constants ¶
const LinuxOsReleaseFile = "/etc/os-release"
Variables ¶
var ( Attribute SystemAttributes Config Configs )
Functions ¶
func CommandFalse ¶ added in v0.3.1
CommandFalse is the same as True, but returns the opposite.
func CommandOutput ¶ added in v0.3.1
CommandOutput will run a command and provide the output. Can be useful in if statements for checking arbitary values. Will not error, but will return an empty string.
func CommandTrue ¶ added in v0.3.1
CommandTrue is similar to the "Unless" parameter found in some resources, but instead can be used freeform within configuration. If it exits cleanly, then it returns true.
func ExpandPath ¶ added in v0.1.9
ExpandPath ensures that "~" are expanded.
func ExpandPathRoot ¶ added in v0.1.11
ExpandPathRoot is like ExpandPath, but ignores the user attribute
func FileContents ¶ added in v0.3.0
FileContents simply returns the file contents as a string
func FileExists ¶ added in v0.1.10
FileExists returns true if the file exists
func IsDirectory ¶ added in v0.3.3
IsDirectory is an alias for DirExists
func IsUbuntu ¶ added in v0.1.9
func IsUbuntu() bool
IsUbuntu returns true if the distribution is Ubuntu
func LinkExists ¶ added in v0.3.0
LinkExists returns true if the symlink exists
func LoggerOutput ¶ added in v0.3.0
func MatchChmod ¶ added in v0.1.11
MatchChmod returns true if the permissions of the path match
func MatchChown ¶ added in v0.1.11
MatchChown returns true if the path is owned by the specified user and group
func PrependSudo ¶ added in v0.1.9
PrependSudo takes a slice of args and simply prepends sudo to the front.
func RunCommand ¶ added in v0.1.9
RunCommand is essentially a wrapper around exec.Command. Generally the Execute resource should be used, but sometimes it can be useful to run things directly.
func SudoCommand ¶ added in v0.1.9
SudoCommand is the same as RunCommand but runs with sudo.
Types ¶
type Configs ¶
Configs sets different settings when running something with viaduct
func (*Configs) SetDryRun ¶ added in v0.3.1
func (c *Configs) SetDryRun()
SetDryRun enables dry run mode.
func (*Configs) SetDumpManifest ¶ added in v0.3.1
func (c *Configs) SetDumpManifest()
SetDumpManifest enables dumping the manifest.
type Logger ¶ added in v0.3.0
type Logger struct { // This is the resource type, such as git, file and directory Resource string // This denotes the action taken on the resource, such as create or delete Action string // Quiet disables all output other than errors Quiet bool // Silent disables all output Silent bool }
Logger provides Viaduct log output.
func NewQuietLogger ¶ added in v0.3.0
func NewSilentLogger ¶ added in v0.3.0
func NewSilentLogger() *Logger
func NewStandardLogger ¶ added in v0.3.1
func (*Logger) Critical ¶ added in v0.3.0
func (l *Logger) Critical(v ...interface{})
Critical is like Fatal, but without exiting
func (*Logger) Info ¶ added in v0.3.0
func (l *Logger) Info(v ...interface{})
Info outputs informational messages
type Manifest ¶ added in v0.2.0
type Manifest struct {
// contains filtered or unexported fields
}
Manifest is a map of resources to allow concurrent runs
func (*Manifest) Add ¶ added in v0.3.0
func (m *Manifest) Add(attributes ResourceAttributes, deps ...*Resource) *Resource
func (*Manifest) Run ¶ added in v0.2.0
func (m *Manifest) Run()
Run will run the specified resources concurrently, taking into account any dependencies that have been declared
type PlatformAttributes ¶
type PlatformAttributes struct { Name string `json:"name"` Version string `json:"version"` ID string `json:"id"` IDLike string `json:"idLike"` PrettyName string `json:"prettyName"` VersionID string `json:"versionId"` HomeURL string `json:"homeUrl"` SupportURL string `json:"supportUrl"` BugReportURL string `json:"bugReportUrl"` PrivacyPolicyURL string `json:"privacyPolicyUrl"` VersionCodename string `json:"versionCodename"` UbuntuCodename string `json:"ubuntuCodename"` }
PlatformAttributes has details about the platform (currently Linux only)
type Resource ¶ added in v0.2.0
type Resource struct { // ResourceID is the resources generated ID. ResourceID // ResourceKind is what the resource kind is, such as "File" or "Package". ResourceKind // Status denotes the current status of the resource. Status // Attributes are the resource type attributes. Attributes ResourceAttributes // DependsOn is a list of resource dependencies. DependsOn []ResourceID `json:"DependsOn,omitempty"` // GlobalLock will mean the resource will not run at the same time // as other resources that have this set to true. GlobalLock bool // Error contains any errors raised during a run. Error `json:"Error"` }
Resource holds details about a particular resource during a Viaduct run.
type ResourceAttributes ¶ added in v0.3.0
type ResourceAttributes interface { // OperationName is a simple identifier for the operation type, such as // Create, Delete, Update or Run. OperationName() string // Params are a set of parameters that determine how a resource should // interact with Viaduct. Params() *ResourceParams // PreflightChecks are used to check that the resource parameters have been // correctly set, and to ensure that default parameters are assigned. PreflightChecks(log *Logger) error // Run performs the resource operation. Run(log *Logger) error }
ResourceAttributes implement different resource types, such as File or Directory. As long as this interface is implemented, then custom resources can be directly integrated.
type ResourceKind ¶ added in v0.2.0
type ResourceKind string
ResourceKind is the kind of resource, such as "File" or "Package".
type ResourceParams ¶ added in v0.3.0
type ResourceParams struct { // GlobalLock can be set to ensure that the resource uses a global // lock during operations GlobalLock bool }
ResourceParams are a set of options that each resource can set depending on their logic
func NewResourceParams ¶ added in v0.3.0
func NewResourceParams() *ResourceParams
NewResourceParams creates a new ResourceParams.
func NewResourceParamsWithLock ¶ added in v0.3.0
func NewResourceParamsWithLock() *ResourceParams
NewResourceParamsWithLock creates a new ResourceParams, but with a global lock applied.
type SystemAttributes ¶ added in v0.3.0
type SystemAttributes struct { User user.User `json:"user"` OS string `json:"os"` Arch string `json:"arch"` Hostname string `json:"hostname"` Platform PlatformAttributes `json:"platform"` Custom map[string]string `json:"custom"` TmpDir string `json:"tmp_dir"` // contains filtered or unexported fields }
Attributes represents all possible attributes of a system
func (*SystemAttributes) AddCustom ¶ added in v0.3.0
func (a *SystemAttributes) AddCustom(key, value string)
AddCustom allows us to add custom attributes during a run
func (*SystemAttributes) GetCustom ¶ added in v0.3.0
func (a *SystemAttributes) GetCustom(key string) string
GetCustom returns the value of a custom attribute
func (*SystemAttributes) JSON ¶ added in v0.3.0
func (a *SystemAttributes) JSON() string
JSON returns a string representation of the loaded attributes
func (*SystemAttributes) SetUser ¶ added in v0.3.0
func (a *SystemAttributes) SetUser(username string)
SetUser allows us to assign a default username