Documentation ¶
Index ¶
- func ScanRepo() common.Entities
- type ApplyImpl
- type FileBuffer
- type RepoFile
- type RepoFiles
- type TargetFile
- func (target *TargetFile) AddRepoEntry(entry RepoFile)
- func (target *TargetFile) Apply(withForce bool)
- func (target *TargetFile) EntityID() string
- func (target *TargetFile) PathIn(directory string) string
- func (target *TargetFile) RenderDiff() ([]byte, error)
- func (target *TargetFile) RepoEntries() RepoFiles
- func (target *TargetFile) Report() *shared.Report
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApplyImpl ¶
type ApplyImpl func(*FileBuffer, *shared.Report) (*FileBuffer, error)
ApplyImpl is the return type for GetApplyImpl.
func GetApplyImpl ¶
GetApplyImpl returns a function that applies the given RepoFile to a file buffer, as part of the `holo apply` algorithm.
type FileBuffer ¶
type FileBuffer struct { //set only for regular files Contents []byte //set only for symlinks SymlinkTarget string //used by ResolveSymlink (see doc over there) BasePath string }
FileBuffer represents the contents of a file. It is used in holo.Apply() as an intermediary product of application steps.
func NewFileBuffer ¶
func NewFileBuffer(path string, basePath string) (*FileBuffer, error)
NewFileBuffer creates a FileBuffer object by reading the manageable file at the given path. The basePath is stored in the FileBuffer for use in holo.FileBuffer.ResolveSymlink().
func NewFileBufferFromContents ¶
func NewFileBufferFromContents(fileContents []byte, basePath string) *FileBuffer
NewFileBufferFromContents creates a file buffer containing the given byte array. The basePath is stored in the FileBuffer for use in holo.FileBuffer.ResolveSymlink().
func (*FileBuffer) EqualTo ¶
func (fb *FileBuffer) EqualTo(other *FileBuffer) bool
EqualTo returns whether two file buffers have the same content (or link target).
func (*FileBuffer) ResolveSymlink ¶
func (fb *FileBuffer) ResolveSymlink() (*FileBuffer, error)
ResolveSymlink takes a FileBuffer that contains a symlink, resolves it and returns a new FileBuffer containing the contents of the symlink target. This operation is used by application strategies that require text input. If the given FileBuffer contains file contents, the same buffer is returned unaltered.
It uses the FileBuffer's BasePath to resolve relative symlinks. Since file buffers are usually written to the target path of a `holo apply` operation, the BasePath is most likely the target path.
func (*FileBuffer) Write ¶
func (fb *FileBuffer) Write(path string) error
type RepoFile ¶
type RepoFile string
RepoFile represents a single file in the configuration repository. The string stored in it is the path to the repo file (also accessible as Path()).
func NewRepoFile ¶
NewRepoFile creates a RepoFile instance when its path in the file system is known.
func (RepoFile) ApplicationStrategy ¶
ApplicationStrategy returns the human-readable name for the strategy that will be employed to apply this repo file.
func (RepoFile) TargetPath ¶
TargetPath returns the path to the corresponding target file.
type RepoFiles ¶
type RepoFiles []RepoFile
RepoFiles holds a slice of RepoFile instances, and implements some methods to satisfy the sort.Interface interface.
type TargetFile ¶
type TargetFile struct {
// contains filtered or unexported fields
}
TargetFile represents a configuration file that can be provisioned by Holo.
func NewTargetFileFromPathIn ¶
func NewTargetFileFromPathIn(directory, path string) *TargetFile
NewTargetFileFromPathIn creates a TargetFile instance for which a path relative to a known location is known.
target := NewTargetFileFromPathIn(common.TargetDirectory(), targetPath) target := NewTargetFileFromPathIn(common.ProvisionedDirectory(), provisionedPath)
func (*TargetFile) AddRepoEntry ¶
func (target *TargetFile) AddRepoEntry(entry RepoFile)
AddRepoEntry registers a new repository entry in this TargetFile instance.
func (*TargetFile) Apply ¶
func (target *TargetFile) Apply(withForce bool)
Apply implements the common.Entity interface.
func (*TargetFile) EntityID ¶
func (target *TargetFile) EntityID() string
EntityID implements the common.Entity interface.
func (*TargetFile) PathIn ¶
func (target *TargetFile) PathIn(directory string) string
PathIn returns the path to this target file relative to the given directory.
targetPath := target.pathIn(common.TargetDirectory()) // e.g. "/etc/foo.conf" targetBasePath := target.pathIn(common.TargetBaseDirectory()) // e.g. "/var/lib/holo/base/etc/foo.conf" provisionedPath := target.pathIn(common.ProvisionedDirectory()) // e.g. "/var/lib/holo/provisioned/etc/foo.conf"
func (*TargetFile) RenderDiff ¶
func (target *TargetFile) RenderDiff() ([]byte, error)
RenderDiff creates a unified diff of a target file and its last provisioned version, similar to `diff /var/lib/holo/provisioned/$FILE $FILE`, but it also handles symlinks and missing files gracefully. The output is always a patch that can be applied to last provisioned version into the current version.
func (*TargetFile) RepoEntries ¶
func (target *TargetFile) RepoEntries() RepoFiles
RepoEntries returns an ordered list of all repository entries for this TargetFile.
func (*TargetFile) Report ¶
func (target *TargetFile) Report() *shared.Report
Report implements the common.Entity interface.