common

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2015 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyFilePermissions

func ApplyFilePermissions(fromPath, toPath string) error

ApplyFilePermissions applies permission flags and ownership from the first file to the second file.

func CopyFile

func CopyFile(fromPath, toPath string) error

CopyFile copies a regular file or symlink, including the file metadata.

func EntityDirectory

func EntityDirectory() string

EntityDirectory is derived from the TargetDirectory() as "$target_dir/usr/share/holo".

func Getent

func Getent(databaseFile string, predicate func([]string) bool) ([]string, error)

Getent reads entries from a UNIX user/group database (e.g. /etc/passwd or /etc/group) and returns the first entry matching the given predicate. For example, to locate the user with name "foo":

fields, err := Getent("/etc/passwd", func(fields []string) bool {
    return fields[0] == "foo"
})
func IsFileInfoASymbolicLink(fileInfo os.FileInfo) bool

IsFileInfoASymbolicLink returns whether the given FileInfo describes a symlink.

func IsManageableFile

func IsManageableFile(path string) bool

IsManageableFile returns whether the file can be managed by Holo (i.e. is a regular file or a symlink).

func IsManageableFileInfo added in v0.9.0

func IsManageableFileInfo(info os.FileInfo) bool

IsManageableFileInfo returns whether the given FileInfo refers to a manageable file (i.e. a regular file or a symlink).

func MoveFile

func MoveFile(fromPath, toPath string) error

MoveFile is like CopyFile, but it removes the fromPath after successful copying.

func ProvisionedDirectory

func ProvisionedDirectory() string

ProvisionedDirectory is derived from the TargetDirectory() as "$target_dir/var/lib/holo/provisioned".

func RepoDirectory

func RepoDirectory() string

RepoDirectory is derived from the TargetDirectory() as "$target_dir/usr/share/holo/repo".

func ScanDirectory added in v0.9.0

func ScanDirectory(path string, predicate func(fi os.FileInfo) bool) ([]string, error)

ScanDirectory reads the directory at path and returns the full paths of all files in it that match the given predicate. No recursive walking of subdirectories is performed. The result slice is sorted by file name.

func ScriptDirectory added in v0.9.0

func ScriptDirectory() string

ScriptDirectory is derived from the TargetDirectory() as "$target_dir/usr/share/holo/provision".

func TargetBaseDirectory

func TargetBaseDirectory() string

TargetBaseDirectory is derived from the TargetDirectory() as "$target_dir/var/lib/holo/base".

func TargetDirectory

func TargetDirectory() string

TargetDirectory is usually the root directory "/" and can be set with the environment variable HOLO_CHROOT_DIR (usually only within unit tests).

Types

type Entities

type Entities []Entity

Entities holds a slice of Entity instances, and implements some methods to satisfy the sort.Interface interface.

func (Entities) Len

func (e Entities) Len() int

func (Entities) Less

func (e Entities) Less(i, j int) bool

func (Entities) Swap

func (e Entities) Swap(i, j int)

type Entity

type Entity interface {
	//EntityID returns a string that uniquely identifies the entity, usually in
	//the form "type:name". This is how the entity can be addressed as a target
	//in the argument list for "holo apply", e.g. "holo apply /etc/sudoers
	//group:foo" will apply the target file "/etc/sudoers" and the group "foo".
	//Therefore, entity IDs should not contain whitespaces or characters that
	//have a special meaning on the shell.
	EntityID() string
	//Report generates a Report describing this Entity.
	Report() *shared.Report
	//Apply performs the complete application algorithm for the given Entity.
	Apply(withForce bool)
	//RenderDiff creates a unified diff between the current and last
	//provisioned version of this entity. For files, the output is always a
	//patch that can be applied on the last provisioned version to obtain the
	//current state.
	RenderDiff() ([]byte, error)
}

Entity provides a common interface for configuration entities, such as configuration files, user accounts and user groups.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL