chezmoi

package
v1.8.11 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Prefix = ".chezmoi"
)

Special file names.

View Source
const (
	TemplateSuffix = ".tmpl"
)

Suffixes and prefixes.

Variables

View Source
var (
	// DefaultTemplateOptions are the default template options.
	DefaultTemplateOptions = []string{"missingkey=error"}

	// Skip indicates that entry should be skipped.
	Skip = filepath.SkipDir

	// Umask is the process's umask.
	Umask = os.FileMode(0)
)
View Source
var Formats = map[string]Format{
	"json": JSONFormat,
	"toml": TOMLFormat,
	"yaml": YAMLFormat,
}

Formats is a map of all Formats by name.

Functions

func DiffPatch

func DiffPatch(path RelPath, fromData []byte, fromMode os.FileMode, toData []byte, toMode os.FileMode) (diff.Patch, error)

DiffPatch returns a github.com/go-git/go-git/plumbing/format/diff.Patch for path from the given data and mode to the given data and mode.

func FQDNHostname

func FQDNHostname(fs vfs.FS) (string, error)

FQDNHostname returns the FQDN hostname.

func KernelInfo

func KernelInfo(fs vfs.FS) (map[string]string, error)

KernelInfo returns the kernel information parsed from /proc/sys/kernel.

func MkdirAll

func MkdirAll(system System, absPath AbsPath, perm os.FileMode) error

MkdirAll is the equivalent of os.MkdirAll but operates on system.

func OSRelease

func OSRelease(fs vfs.FS) (map[string]string, error)

OSRelease returns the operating system identification data as defined by the os-release specification.

func PersistentStateData

func PersistentStateData(s PersistentState) (interface{}, error)

PersistentStateData returns the structured data in s.

func ShellQuoteArgs

func ShellQuoteArgs(args []string) string

ShellQuoteArgs returs args shell quoted and joined into a single string.

func SuspiciousSourceDirEntry

func SuspiciousSourceDirEntry(base string, info os.FileInfo) bool

SuspiciousSourceDirEntry returns true if base is a suspicous dir entry.

func Walk

func Walk(system System, rootAbsPath AbsPath, walkFn func(absPath AbsPath, info os.FileInfo, err error) error) error

Walk walks rootAbsPath in s.

Types

type AGEEncryption

type AGEEncryption struct {
	Command         string
	Args            []string
	Identity        string
	Identities      []string
	Recipient       string
	Recipients      []string
	RecipientsFile  string
	RecipientsFiles []string
}

An AGEEncryption uses age for encryption and decryption. See https://github.com/FiloSottile/age.

func (*AGEEncryption) Decrypt

func (t *AGEEncryption) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt implements Encyrption.Decrypt.

func (*AGEEncryption) DecryptToFile

func (t *AGEEncryption) DecryptToFile(filename string, ciphertext []byte) error

DecryptToFile implements Encryption.DecryptToFile.

func (*AGEEncryption) Encrypt

func (t *AGEEncryption) Encrypt(plaintext []byte) ([]byte, error)

Encrypt implements Encryption.Encrypt.

func (*AGEEncryption) EncryptFile

func (t *AGEEncryption) EncryptFile(filename string) ([]byte, error)

EncryptFile implements Encryption.EncryptFile.

type AbsPath

type AbsPath string

An AbsPath is an absolute path.

func NewAbsPath

func NewAbsPath(path string) (AbsPath, error)

NewAbsPath returns a new AbsPath.

func NewAbsPathFromExtPath

func NewAbsPathFromExtPath(extPath string, homeDirAbsPath AbsPath) (AbsPath, error)

NewAbsPathFromExtPath returns a new AbsPath by converting extPath to use slashes, performing tilde expansion, and making the path absolute.

func NormalizePath

func NormalizePath(path string) (AbsPath, error)

NormalizePath returns path normalized. On non-Windows systems, normalized paths are absolute paths.

func (AbsPath) Base

func (p AbsPath) Base() string

Base returns p's basename.

func (AbsPath) Dir

func (p AbsPath) Dir() AbsPath

Dir returns p's directory.

func (AbsPath) Join

func (p AbsPath) Join(elems ...RelPath) AbsPath

Join appends elems to p.

func (AbsPath) MustTrimDirPrefix

func (p AbsPath) MustTrimDirPrefix(dirPrefix AbsPath) RelPath

MustTrimDirPrefix is like TrimPrefix but panics on any error.

func (AbsPath) Split

func (p AbsPath) Split() (AbsPath, RelPath)

Split returns p's directory and file.

func (AbsPath) TrimDirPrefix

func (p AbsPath) TrimDirPrefix(dirPrefixAbsPath AbsPath) (RelPath, error)

TrimDirPrefix trims prefix from p.

type AbsPaths

type AbsPaths []AbsPath

AbsPaths is a slice of AbsPaths that implements sort.Interface.

func (AbsPaths) Len

func (ps AbsPaths) Len() int

func (AbsPaths) Less

func (ps AbsPaths) Less(i, j int) bool

func (AbsPaths) Swap

func (ps AbsPaths) Swap(i, j int)

type ActualStateAbsent

type ActualStateAbsent struct {
	// contains filtered or unexported fields
}

A ActualStateAbsent represents the absence of an entry in the filesystem.

func (*ActualStateAbsent) EntryState

func (s *ActualStateAbsent) EntryState() (*EntryState, error)

EntryState returns d's entry state.

func (*ActualStateAbsent) Path

func (s *ActualStateAbsent) Path() AbsPath

Path returns d's path.

func (*ActualStateAbsent) Remove

func (s *ActualStateAbsent) Remove(system System) error

Remove removes d.

type ActualStateDir

type ActualStateDir struct {
	// contains filtered or unexported fields
}

A ActualStateDir represents the state of a directory in the filesystem.

func (*ActualStateDir) EntryState

func (s *ActualStateDir) EntryState() (*EntryState, error)

EntryState returns d's entry state.

func (*ActualStateDir) Path

func (s *ActualStateDir) Path() AbsPath

Path returns d's path.

func (*ActualStateDir) Remove

func (s *ActualStateDir) Remove(system System) error

Remove removes d.

type ActualStateEntry

type ActualStateEntry interface {
	EntryState() (*EntryState, error)
	Path() AbsPath
	Remove(system System) error
}

An ActualStateEntry represents the actual state of an entry in the filesystem.

func NewActualStateEntry

func NewActualStateEntry(system System, absPath AbsPath, info os.FileInfo, err error) (ActualStateEntry, error)

NewActualStateEntry returns a new ActualStateEntry populated with absPath from fs.

type ActualStateFile

type ActualStateFile struct {
	// contains filtered or unexported fields
}

A ActualStateFile represents the state of a file in the filesystem.

func (ActualStateFile) Contents

func (lc ActualStateFile) Contents() ([]byte, error)

Contents returns lc's contents.

func (ActualStateFile) ContentsSHA256

func (lc ActualStateFile) ContentsSHA256() ([]byte, error)

ContentsSHA256 returns the SHA256 sum of lc's contents.

func (*ActualStateFile) EntryState

func (s *ActualStateFile) EntryState() (*EntryState, error)

EntryState returns d's entry state.

func (*ActualStateFile) Path

func (s *ActualStateFile) Path() AbsPath

Path returns d's path.

func (*ActualStateFile) Remove

func (s *ActualStateFile) Remove(system System) error

Remove removes d.

type ActualStateSymlink struct {
	// contains filtered or unexported fields
}

A ActualStateSymlink represents the state of a symlink in the filesystem.

func (*ActualStateSymlink) EntryState

func (s *ActualStateSymlink) EntryState() (*EntryState, error)

EntryState returns d's entry state.

func (ActualStateSymlink) Linkname

func (ll ActualStateSymlink) Linkname() (string, error)

Linkname returns s's linkname.

func (ActualStateSymlink) LinknameSHA256

func (ll ActualStateSymlink) LinknameSHA256() ([]byte, error)

LinknameSHA256 returns the SHA256 sum of ll's linkname.

func (*ActualStateSymlink) Path

func (s *ActualStateSymlink) Path() AbsPath

Path returns d's path.

func (*ActualStateSymlink) Remove

func (s *ActualStateSymlink) Remove(system System) error

Remove removes d.

type AddOptions

type AddOptions struct {
	AutoTemplate bool
	Empty        bool
	Encrypt      bool
	Exact        bool
	Exists       bool
	Include      *IncludeSet
	RemoveDir    RelPath
	Template     bool
}

AddOptions are options to SourceState.Add.

type ApplyOptions

type ApplyOptions struct {
	Include       *IncludeSet
	PreApplyFunc  PreApplyFunc
	SkipEncrypted bool
	Umask         os.FileMode
}

ApplyOptions are options to SourceState.ApplyAll and SourceState.ApplyOne.

type BoltPersistentState

type BoltPersistentState struct {
	// contains filtered or unexported fields
}

A BoltPersistentState is a state persisted with bolt.

func NewBoltPersistentState

func NewBoltPersistentState(system System, path AbsPath, mode BoltPersistentStateMode) (*BoltPersistentState, error)

NewBoltPersistentState returns a new BoltPersistentState.

func (*BoltPersistentState) Close

func (b *BoltPersistentState) Close() error

Close closes b.

func (*BoltPersistentState) CopyTo

CopyTo copies b to p.

func (*BoltPersistentState) Delete

func (b *BoltPersistentState) Delete(bucket, key []byte) error

Delete deletes the value associate with key in bucket. If bucket or key does not exist then Delete does nothing.

func (*BoltPersistentState) ForEach

func (b *BoltPersistentState) ForEach(bucket []byte, fn func(k, v []byte) error) error

ForEach calls fn for each key, value pair in bucket.

func (*BoltPersistentState) Get

func (b *BoltPersistentState) Get(bucket, key []byte) ([]byte, error)

Get returns the value associated with key in bucket.

func (*BoltPersistentState) Set

func (b *BoltPersistentState) Set(bucket, key, value []byte) error

Set sets the value associated with key in bucket. bucket will be created if it does not already exist.

type BoltPersistentStateMode

type BoltPersistentStateMode int

A BoltPersistentStateMode is a mode for opening a PersistentState.

const (
	BoltPersistentStateReadOnly BoltPersistentStateMode = iota
	BoltPersistentStateReadWrite
)

PersistentStateModes.

type DebugEncryption

type DebugEncryption struct {
	// contains filtered or unexported fields
}

A DebugEncryption logs all calls to an Encryption.

func NewDebugEncryption

func NewDebugEncryption(encryption Encryption) *DebugEncryption

NewDebugEncryption returns a new DebugEncryption.

func (*DebugEncryption) Decrypt

func (e *DebugEncryption) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt implements Encryption.Decrypt.

func (*DebugEncryption) DecryptToFile

func (e *DebugEncryption) DecryptToFile(filename string, ciphertext []byte) error

DecryptToFile implements Encryption.DecryptToFile.

func (*DebugEncryption) Encrypt

func (e *DebugEncryption) Encrypt(plaintext []byte) ([]byte, error)

Encrypt implements Encryption.Encrypt.

func (*DebugEncryption) EncryptFile

func (e *DebugEncryption) EncryptFile(filename string) ([]byte, error)

EncryptFile implements Encryption.EncryptFile.

type DebugPersistentState

type DebugPersistentState struct {
	// contains filtered or unexported fields
}

A DebugPersistentState logs calls to a PersistentState.

func NewDebugPersistentState

func NewDebugPersistentState(persistentState PersistentState) *DebugPersistentState

NewDebugPersistentState returns a new debugPersistentState.

func (*DebugPersistentState) Close

func (s *DebugPersistentState) Close() error

Close implements PersistentState.Close.

func (*DebugPersistentState) CopyTo

CopyTo implements PersistentState.CopyTo.

func (*DebugPersistentState) Delete

func (s *DebugPersistentState) Delete(bucket, key []byte) error

Delete implements PersistentState.Delete.

func (*DebugPersistentState) ForEach

func (s *DebugPersistentState) ForEach(bucket []byte, fn func(k, v []byte) error) error

ForEach implements PersistentState.ForEach.

func (*DebugPersistentState) Get

func (s *DebugPersistentState) Get(bucket, key []byte) ([]byte, error)

Get implements PersistentState.Get.

func (*DebugPersistentState) Set

func (s *DebugPersistentState) Set(bucket, key, value []byte) error

Set implements PersistentState.Set.

type DebugSystem

type DebugSystem struct {
	// contains filtered or unexported fields
}

A DebugSystem logs all calls to a System.

func NewDebugSystem

func NewDebugSystem(system System) *DebugSystem

NewDebugSystem returns a new DebugSystem.

func (*DebugSystem) Chmod

func (s *DebugSystem) Chmod(name AbsPath, mode os.FileMode) error

Chmod implements System.Chmod.

func (*DebugSystem) Glob

func (s *DebugSystem) Glob(name string) ([]string, error)

Glob implements System.Glob.

func (*DebugSystem) IdempotentCmdOutput

func (s *DebugSystem) IdempotentCmdOutput(cmd *exec.Cmd) ([]byte, error)

IdempotentCmdOutput implements System.IdempotentCmdOutput.

func (*DebugSystem) Lstat

func (s *DebugSystem) Lstat(name AbsPath) (os.FileInfo, error)

Lstat implements System.Lstat.

func (*DebugSystem) Mkdir

func (s *DebugSystem) Mkdir(name AbsPath, perm os.FileMode) error

Mkdir implements System.Mkdir.

func (*DebugSystem) RawPath

func (s *DebugSystem) RawPath(path AbsPath) (AbsPath, error)

RawPath implements System.RawPath.

func (*DebugSystem) ReadDir

func (s *DebugSystem) ReadDir(name AbsPath) ([]os.FileInfo, error)

ReadDir implements System.ReadDir.

func (*DebugSystem) ReadFile

func (s *DebugSystem) ReadFile(filename AbsPath) ([]byte, error)

ReadFile implements System.ReadFile.

func (s *DebugSystem) Readlink(name AbsPath) (string, error)

Readlink implements System.Readlink.

func (*DebugSystem) RemoveAll

func (s *DebugSystem) RemoveAll(name AbsPath) error

RemoveAll implements System.RemoveAll.

func (*DebugSystem) Rename

func (s *DebugSystem) Rename(oldpath, newpath AbsPath) error

Rename implements System.Rename.

func (*DebugSystem) RunCmd

func (s *DebugSystem) RunCmd(cmd *exec.Cmd) error

RunCmd implements System.RunCmd.

func (*DebugSystem) RunScript

func (s *DebugSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte) error

RunScript implements System.RunScript.

func (*DebugSystem) Stat

func (s *DebugSystem) Stat(name AbsPath) (os.FileInfo, error)

Stat implements System.Stat.

func (*DebugSystem) UnderlyingFS

func (s *DebugSystem) UnderlyingFS() vfs.FS

UnderlyingFS implements System.UnderlyingFS.

func (*DebugSystem) WriteFile

func (s *DebugSystem) WriteFile(name AbsPath, data []byte, perm os.FileMode) error

WriteFile implements System.WriteFile.

func (s *DebugSystem) WriteSymlink(oldname string, newname AbsPath) error

WriteSymlink implements System.WriteSymlink.

type DirAttr

type DirAttr struct {
	TargetName string
	Exact      bool
	Private    bool
}

DirAttr holds attributes parsed from a source directory name.

func (DirAttr) SourceName

func (da DirAttr) SourceName() string

SourceName returns da's source name.

type DryRunSystem

type DryRunSystem struct {
	// contains filtered or unexported fields
}

DryRunSystem is an System that reads from, but does not write to, to a wrapped System.

func NewDryRunSystem

func NewDryRunSystem(system System) *DryRunSystem

NewDryRunSystem returns a new DryRunSystem that wraps fs.

func (*DryRunSystem) Chmod

func (s *DryRunSystem) Chmod(name AbsPath, mode os.FileMode) error

Chmod implements System.Chmod.

func (*DryRunSystem) Glob

func (s *DryRunSystem) Glob(pattern string) ([]string, error)

Glob implements System.Glob.

func (*DryRunSystem) IdempotentCmdOutput

func (s *DryRunSystem) IdempotentCmdOutput(cmd *exec.Cmd) ([]byte, error)

IdempotentCmdOutput implements System.IdempotentCmdOutput.

func (*DryRunSystem) Lstat

func (s *DryRunSystem) Lstat(name AbsPath) (os.FileInfo, error)

Lstat implements System.Lstat.

func (*DryRunSystem) Mkdir

func (s *DryRunSystem) Mkdir(name AbsPath, perm os.FileMode) error

Mkdir implements System.Mkdir.

func (*DryRunSystem) Modified

func (s *DryRunSystem) Modified() bool

Modified returns true if a method that would have modified the wrapped system has been called.

func (*DryRunSystem) RawPath

func (s *DryRunSystem) RawPath(path AbsPath) (AbsPath, error)

RawPath implements System.RawPath.

func (*DryRunSystem) ReadDir

func (s *DryRunSystem) ReadDir(dirname AbsPath) ([]os.FileInfo, error)

ReadDir implements System.ReadDir.

func (*DryRunSystem) ReadFile

func (s *DryRunSystem) ReadFile(filename AbsPath) ([]byte, error)

ReadFile implements System.ReadFile.

func (s *DryRunSystem) Readlink(name AbsPath) (string, error)

Readlink implements System.Readlink.

func (*DryRunSystem) RemoveAll

func (s *DryRunSystem) RemoveAll(AbsPath) error

RemoveAll implements System.RemoveAll.

func (*DryRunSystem) Rename

func (s *DryRunSystem) Rename(oldpath, newpath AbsPath) error

Rename implements System.Rename.

func (*DryRunSystem) RunCmd

func (s *DryRunSystem) RunCmd(cmd *exec.Cmd) error

RunCmd implements System.RunCmd.

func (*DryRunSystem) RunScript

func (s *DryRunSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte) error

RunScript implements System.RunScript.

func (*DryRunSystem) Stat

func (s *DryRunSystem) Stat(name AbsPath) (os.FileInfo, error)

Stat implements System.Stat.

func (*DryRunSystem) UnderlyingFS

func (s *DryRunSystem) UnderlyingFS() vfs.FS

UnderlyingFS implements System.UnderlyingFS.

func (*DryRunSystem) WriteFile

func (s *DryRunSystem) WriteFile(AbsPath, []byte, os.FileMode) error

WriteFile implements System.WriteFile.

func (s *DryRunSystem) WriteSymlink(string, AbsPath) error

WriteSymlink implements System.WriteSymlink.

type DumpSystem

type DumpSystem struct {
	// contains filtered or unexported fields
}

A DumpSystem is a System that writes to a data file.

func NewDumpSystem

func NewDumpSystem() *DumpSystem

NewDumpSystem returns a new DumpSystem that accumulates data.

func (DumpSystem) Chmod

func (DumpSystem) Chmod(name AbsPath, perm os.FileMode) error

func (*DumpSystem) Data

func (s *DumpSystem) Data() interface{}

Data returns s's data.

func (DumpSystem) Glob

func (DumpSystem) Glob(pattern string) ([]string, error)

func (DumpSystem) IdempotentCmdOutput

func (DumpSystem) IdempotentCmdOutput(cmd *exec.Cmd) ([]byte, error)

func (DumpSystem) Lstat

func (DumpSystem) Lstat(name AbsPath) (os.FileInfo, error)

func (*DumpSystem) Mkdir

func (s *DumpSystem) Mkdir(dirname AbsPath, perm os.FileMode) error

Mkdir implements System.Mkdir.

func (DumpSystem) RawPath

func (DumpSystem) RawPath(path AbsPath) (AbsPath, error)

func (DumpSystem) ReadDir

func (DumpSystem) ReadDir(dirname AbsPath) ([]os.FileInfo, error)

func (DumpSystem) ReadFile

func (DumpSystem) ReadFile(filename AbsPath) ([]byte, error)
func (DumpSystem) Readlink(name AbsPath) (string, error)

func (DumpSystem) RemoveAll

func (DumpSystem) RemoveAll(name AbsPath) error

func (DumpSystem) Rename

func (DumpSystem) Rename(oldpath, newpath AbsPath) error

func (DumpSystem) RunCmd

func (DumpSystem) RunCmd(cmd *exec.Cmd) error

func (*DumpSystem) RunScript

func (s *DumpSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte) error

RunScript implements System.RunScript.

func (DumpSystem) Stat

func (DumpSystem) Stat(name AbsPath) (os.FileInfo, error)

func (*DumpSystem) UnderlyingFS

func (s *DumpSystem) UnderlyingFS() vfs.FS

UnderlyingFS implements System.UnderlyingFS.

func (*DumpSystem) WriteFile

func (s *DumpSystem) WriteFile(filename AbsPath, data []byte, perm os.FileMode) error

WriteFile implements System.WriteFile.

func (s *DumpSystem) WriteSymlink(oldname string, newname AbsPath) error

WriteSymlink implements System.WriteSymlink.

type Encryption

type Encryption interface {
	Decrypt(ciphertext []byte) ([]byte, error)
	DecryptToFile(filename string, ciphertext []byte) error
	Encrypt(plaintext []byte) ([]byte, error)
	EncryptFile(filename string) ([]byte, error)
}

An Encryption encrypts and decrypts files and data.

type EntryState

type EntryState struct {
	Type           EntryStateType `json:"type" toml:"type" yaml:"type"`
	Mode           os.FileMode    `json:"mode,omitempty" toml:"mode,omitempty" yaml:"mode,omitempty"`
	ContentsSHA256 hexBytes       `json:"contentsSHA256,omitempty" toml:"contentsSHA256,omitempty" yaml:"contentsSHA256,omitempty"`
	// contains filtered or unexported fields
}

An EntryState represents the state of an entry. A nil EntryState is equivalent to EntryStateTypeAbsent.

func (*EntryState) Contents

func (s *EntryState) Contents() []byte

Contents returns s's contents, if available.

func (*EntryState) Equal

func (s *EntryState) Equal(other *EntryState) bool

Equal returns true if s is equal to other.

func (*EntryState) Equivalent

func (s *EntryState) Equivalent(other *EntryState) bool

Equivalent returns true if s is equivalent to other.

type EntryStateType

type EntryStateType string

An EntryStateType is an entry state type.

const (
	EntryStateTypeAbsent  EntryStateType = "absent"
	EntryStateTypePresent EntryStateType = "present"
	EntryStateTypeDir     EntryStateType = "dir"
	EntryStateTypeFile    EntryStateType = "file"
	EntryStateTypeSymlink EntryStateType = "symlink"
	EntryStateTypeScript  EntryStateType = "script"
)

Entry state types.

type FileAttr

type FileAttr struct {
	TargetName string
	Type       SourceFileTargetType
	Empty      bool
	Encrypted  bool
	Executable bool
	Once       bool
	Order      int
	Private    bool
	Template   bool
}

A FileAttr holds attributes parsed from a source file name.

func (FileAttr) SourceName

func (fa FileAttr) SourceName() string

SourceName returns fa's source name.

type Format

type Format interface {
	Marshal(value interface{}) ([]byte, error)
	Name() string
	Unmarshal(data []byte, value interface{}) error
}

A Format is a serialization format.

var (
	JSONFormat Format = jsonFormat{}
	TOMLFormat Format = tomlFormat{}
	YAMLFormat Format = yamlFormat{}
)

Formats.

type GPGEncryption

type GPGEncryption struct {
	Command   string
	Args      []string
	Recipient string
	Symmetric bool
}

A GPGEncryption uses gpg for encryption and decryption. See https://gnupg.org/.

func (*GPGEncryption) Decrypt

func (t *GPGEncryption) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt implements Encyrption.Decrypt.

func (*GPGEncryption) DecryptToFile

func (t *GPGEncryption) DecryptToFile(filename string, ciphertext []byte) error

DecryptToFile implements Encryption.DecryptToFile.

func (*GPGEncryption) Encrypt

func (t *GPGEncryption) Encrypt(plaintext []byte) ([]byte, error)

Encrypt implements Encryption.Encrypt.

func (*GPGEncryption) EncryptFile

func (t *GPGEncryption) EncryptFile(filename string) (ciphertext []byte, err error)

EncryptFile implements Encryption.EncryptFile.

type GitDiffSystem

type GitDiffSystem struct {
	// contains filtered or unexported fields
}

A GitDiffSystem wraps a System and logs all of the actions executed as a git diff.

func NewGitDiffSystem

func NewGitDiffSystem(system System, w io.Writer, dirAbsPath AbsPath, color bool) *GitDiffSystem

NewGitDiffSystem returns a new GitDiffSystem.

func (*GitDiffSystem) Chmod

func (s *GitDiffSystem) Chmod(name AbsPath, mode os.FileMode) error

Chmod implements System.Chmod.

func (*GitDiffSystem) Glob

func (s *GitDiffSystem) Glob(pattern string) ([]string, error)

Glob implements System.Glob.

func (*GitDiffSystem) IdempotentCmdOutput

func (s *GitDiffSystem) IdempotentCmdOutput(cmd *exec.Cmd) ([]byte, error)

IdempotentCmdOutput implements System.IdempotentCmdOutput.

func (*GitDiffSystem) Lstat

func (s *GitDiffSystem) Lstat(name AbsPath) (os.FileInfo, error)

Lstat implements System.Lstat.

func (*GitDiffSystem) Mkdir

func (s *GitDiffSystem) Mkdir(name AbsPath, perm os.FileMode) error

Mkdir implements System.Mkdir.

func (*GitDiffSystem) RawPath

func (s *GitDiffSystem) RawPath(path AbsPath) (AbsPath, error)

RawPath implements System.RawPath.

func (*GitDiffSystem) ReadDir

func (s *GitDiffSystem) ReadDir(dirname AbsPath) ([]os.FileInfo, error)

ReadDir implements System.ReadDir.

func (*GitDiffSystem) ReadFile

func (s *GitDiffSystem) ReadFile(filename AbsPath) ([]byte, error)

ReadFile implements System.ReadFile.

func (s *GitDiffSystem) Readlink(name AbsPath) (string, error)

Readlink implements System.Readlink.

func (*GitDiffSystem) RemoveAll

func (s *GitDiffSystem) RemoveAll(name AbsPath) error

RemoveAll implements System.RemoveAll.

func (*GitDiffSystem) Rename

func (s *GitDiffSystem) Rename(oldpath, newpath AbsPath) error

Rename implements System.Rename.

func (*GitDiffSystem) RunCmd

func (s *GitDiffSystem) RunCmd(cmd *exec.Cmd) error

RunCmd implements System.RunCmd.

func (*GitDiffSystem) RunScript

func (s *GitDiffSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte) error

RunScript implements System.RunScript.

func (*GitDiffSystem) Stat

func (s *GitDiffSystem) Stat(name AbsPath) (os.FileInfo, error)

Stat implements System.Stat.

func (*GitDiffSystem) UnderlyingFS

func (s *GitDiffSystem) UnderlyingFS() vfs.FS

UnderlyingFS implements System.UnderlyingFS.

func (*GitDiffSystem) WriteFile

func (s *GitDiffSystem) WriteFile(filename AbsPath, data []byte, perm os.FileMode) error

WriteFile implements System.WriteFile.

func (s *GitDiffSystem) WriteSymlink(oldname string, newname AbsPath) error

WriteSymlink implements System.WriteSymlink.

type IncludeBits

type IncludeBits int

An IncludeBits is a bitmask of entries to include.

const (
	IncludeAbsent IncludeBits = 1 << iota
	IncludeDirs
	IncludeFiles
	IncludeScripts
	IncludeSymlinks

	// IncludeAll is all include bits.
	IncludeAll IncludeBits = IncludeAbsent | IncludeDirs | IncludeFiles | IncludeScripts | IncludeSymlinks
)

Include bits.

type IncludeSet

type IncludeSet struct {
	// contains filtered or unexported fields
}

An IncludeSet controls what types of entries to include. It parses and prints as a comma-separated list of strings, but is internally represented as a bitmask. *IncludeSet implements the github.com/spf13/pflag.Value interface.

func NewIncludeSet

func NewIncludeSet(bits IncludeBits) *IncludeSet

NewIncludeSet returns a new IncludeSet.

func (*IncludeSet) IncludeActualStateEntry

func (s *IncludeSet) IncludeActualStateEntry(actualStateEntry ActualStateEntry) bool

IncludeActualStateEntry returns true if actualStateEntry should be included.

func (*IncludeSet) IncludeFileInfo

func (s *IncludeSet) IncludeFileInfo(info os.FileInfo) bool

IncludeFileInfo returns true if info should be included.

func (*IncludeSet) IncludeTargetStateEntry

func (s *IncludeSet) IncludeTargetStateEntry(targetStateEntry TargetStateEntry) bool

IncludeTargetStateEntry returns true if targetStateEntry should be included.

func (*IncludeSet) Set

func (s *IncludeSet) Set(str string) error

Set implements github.com/spf13/pflag.Value.Set.

func (*IncludeSet) String

func (s *IncludeSet) String() string

func (*IncludeSet) Type

func (s *IncludeSet) Type() string

Type implements github.com/spf13/pflag.Value.Type.

type MockPersistentState

type MockPersistentState struct {
	// contains filtered or unexported fields
}

A MockPersistentState is a mock persistent state.

func NewMockPersistentState

func NewMockPersistentState() *MockPersistentState

NewMockPersistentState returns a new PersistentState.

func (*MockPersistentState) Close

func (s *MockPersistentState) Close() error

Close closes s.

func (*MockPersistentState) CopyTo

CopyTo implements PersistentState.CopyTo.

func (*MockPersistentState) Delete

func (s *MockPersistentState) Delete(bucket, key []byte) error

Delete implements PersistentState.Delete.

func (*MockPersistentState) ForEach

func (s *MockPersistentState) ForEach(bucket []byte, fn func(k, v []byte) error) error

ForEach implements PersistentState.ForEach.

func (*MockPersistentState) Get

func (s *MockPersistentState) Get(bucket, key []byte) ([]byte, error)

Get implements PersistentState.Get.

func (*MockPersistentState) Set

func (s *MockPersistentState) Set(bucket, key, value []byte) error

Set implements PersistentState.Set.

type NoEncryption

type NoEncryption struct{}

NoEncryption returns an error when any method is called.

func (NoEncryption) Decrypt

func (NoEncryption) Decrypt([]byte) ([]byte, error)

Decrypt implements Encryption.Decrypt.

func (NoEncryption) DecryptToFile

func (NoEncryption) DecryptToFile(string, []byte) error

DecryptToFile implements Encryption.DecryptToFile.

func (NoEncryption) Encrypt

func (NoEncryption) Encrypt([]byte) ([]byte, error)

Encrypt implements Encryption.Encrypt.

func (NoEncryption) EncryptFile

func (NoEncryption) EncryptFile(string) ([]byte, error)

EncryptFile implements Encryption.EncryptFile.

type NullPersistentState

type NullPersistentState struct{}

A NullPersistentState is an empty PersistentState that returns the zero value for all reads and silently consumes all writes.

func (NullPersistentState) Close

func (NullPersistentState) Close() error

Close does nothing.

func (NullPersistentState) CopyTo

CopyTo does nothing.

func (NullPersistentState) Delete

func (NullPersistentState) Delete(bucket, key []byte) error

Delete does nothing.

func (NullPersistentState) ForEach

func (NullPersistentState) ForEach(bucket []byte, fn func(k, v []byte) error) error

ForEach does nothing.

func (NullPersistentState) Get

func (NullPersistentState) Get(bucket, key []byte) ([]byte, error)

Get does nothing.

func (NullPersistentState) Set

func (NullPersistentState) Set(bucket, key, value []byte) error

Set does nothing.

type PersistentState

type PersistentState interface {
	Close() error
	CopyTo(s PersistentState) error
	Delete(bucket, key []byte) error
	ForEach(bucket []byte, fn func(k, v []byte) error) error
	Get(bucket, key []byte) ([]byte, error)
	Set(bucket, key, value []byte) error
}

A PersistentState is a persistent state.

type PreApplyFunc

type PreApplyFunc func(targetRelPath RelPath, targetEntryState, lastWrittenEntryState, actualEntryState *EntryState) error

A PreApplyFunc is called before a target is applied.

type ReadOnlySystem

type ReadOnlySystem struct {
	// contains filtered or unexported fields
}

A ReadOnlySystem is a system that may only be read from.

func NewReadOnlySystem

func NewReadOnlySystem(system System) *ReadOnlySystem

NewReadOnlySystem returns a new ReadOnlySystem that wraps system.

func (ReadOnlySystem) Chmod

func (ReadOnlySystem) Chmod(name AbsPath, perm os.FileMode) error

func (*ReadOnlySystem) Glob

func (s *ReadOnlySystem) Glob(pattern string) ([]string, error)

Glob implements System.Glob.

func (*ReadOnlySystem) IdempotentCmdOutput

func (s *ReadOnlySystem) IdempotentCmdOutput(cmd *exec.Cmd) ([]byte, error)

IdempotentCmdOutput implements System.IdempotentCmdOutput.

func (*ReadOnlySystem) Lstat

func (s *ReadOnlySystem) Lstat(filename AbsPath) (os.FileInfo, error)

Lstat implements System.Lstat.

func (ReadOnlySystem) Mkdir

func (ReadOnlySystem) Mkdir(name AbsPath, perm os.FileMode) error

func (*ReadOnlySystem) RawPath

func (s *ReadOnlySystem) RawPath(path AbsPath) (AbsPath, error)

RawPath implements System.RawPath.

func (*ReadOnlySystem) ReadDir

func (s *ReadOnlySystem) ReadDir(dirname AbsPath) ([]os.FileInfo, error)

ReadDir implements System.ReadDir.

func (*ReadOnlySystem) ReadFile

func (s *ReadOnlySystem) ReadFile(filename AbsPath) ([]byte, error)

ReadFile implements System.ReadFile.

func (s *ReadOnlySystem) Readlink(name AbsPath) (string, error)

Readlink implements System.Readlink.

func (ReadOnlySystem) RemoveAll

func (ReadOnlySystem) RemoveAll(name AbsPath) error

func (ReadOnlySystem) Rename

func (ReadOnlySystem) Rename(oldpath, newpath AbsPath) error

func (ReadOnlySystem) RunCmd

func (ReadOnlySystem) RunCmd(cmd *exec.Cmd) error

func (ReadOnlySystem) RunScript

func (ReadOnlySystem) RunScript(scriptname RelPath, dir AbsPath, data []byte) error

func (*ReadOnlySystem) Stat

func (s *ReadOnlySystem) Stat(name AbsPath) (os.FileInfo, error)

Stat implements System.Stat.

func (*ReadOnlySystem) UnderlyingFS

func (s *ReadOnlySystem) UnderlyingFS() vfs.FS

UnderlyingFS implements System.UnderlyingFS.

func (ReadOnlySystem) WriteFile

func (ReadOnlySystem) WriteFile(filename AbsPath, data []byte, perm os.FileMode) error
func (ReadOnlySystem) WriteSymlink(oldname string, newname AbsPath) error

type RealSystem

type RealSystem struct {
	// contains filtered or unexported fields
}

An RealSystem is a System that writes to a filesystem and executes scripts.

func NewRealSystem

func NewRealSystem(fs vfs.FS) *RealSystem

NewRealSystem returns a System that acts on fs.

func (*RealSystem) Chmod

func (s *RealSystem) Chmod(name AbsPath, mode os.FileMode) error

Chmod implements System.Chmod.

func (*RealSystem) Glob

func (s *RealSystem) Glob(pattern string) ([]string, error)

Glob implements System.Glob.

func (*RealSystem) IdempotentCmdOutput

func (s *RealSystem) IdempotentCmdOutput(cmd *exec.Cmd) ([]byte, error)

IdempotentCmdOutput implements System.IdempotentCmdOutput.

func (*RealSystem) Lstat

func (s *RealSystem) Lstat(filename AbsPath) (os.FileInfo, error)

Lstat implements System.Lstat.

func (*RealSystem) Mkdir

func (s *RealSystem) Mkdir(name AbsPath, perm os.FileMode) error

Mkdir implements System.Mkdir.

func (*RealSystem) PathSeparator

func (s *RealSystem) PathSeparator() rune

PathSeparator implements doublestar.OS.PathSeparator.

func (*RealSystem) RawPath

func (s *RealSystem) RawPath(absPath AbsPath) (AbsPath, error)

RawPath implements System.RawPath.

func (*RealSystem) ReadDir

func (s *RealSystem) ReadDir(dirname AbsPath) ([]os.FileInfo, error)

ReadDir implements System.ReadDir.

func (*RealSystem) ReadFile

func (s *RealSystem) ReadFile(filename AbsPath) ([]byte, error)

ReadFile implements System.ReadFile.

func (s *RealSystem) Readlink(name AbsPath) (string, error)

Readlink implements System.Readlink.

func (*RealSystem) RemoveAll

func (s *RealSystem) RemoveAll(name AbsPath) error

RemoveAll implements System.RemoveAll.

func (*RealSystem) Rename

func (s *RealSystem) Rename(oldpath, newpath AbsPath) error

Rename implements System.Rename.

func (*RealSystem) RunCmd

func (s *RealSystem) RunCmd(cmd *exec.Cmd) error

RunCmd implements System.RunCmd.

func (*RealSystem) RunScript

func (s *RealSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte) (err error)

RunScript implements System.RunScript.

func (*RealSystem) Stat

func (s *RealSystem) Stat(name AbsPath) (os.FileInfo, error)

Stat implements System.Stat.

func (*RealSystem) UnderlyingFS

func (s *RealSystem) UnderlyingFS() vfs.FS

UnderlyingFS implements System.UnderlyingFS.

func (*RealSystem) WriteFile

func (s *RealSystem) WriteFile(filename AbsPath, data []byte, perm os.FileMode) error

WriteFile implements System.WriteFile.

func (s *RealSystem) WriteSymlink(oldname string, newname AbsPath) error

WriteSymlink implements System.WriteSymlink.

type RelPath

type RelPath string

A RelPath is a relative path.

func (RelPath) Base

func (p RelPath) Base() string

Base returns p's base name.

func (RelPath) Dir

func (p RelPath) Dir() RelPath

Dir returns p's directory.

func (RelPath) HasDirPrefix

func (p RelPath) HasDirPrefix(dirPrefix RelPath) bool

HasDirPrefix returns true if p has dir prefix dirPrefix.

func (RelPath) Join

func (p RelPath) Join(elems ...RelPath) RelPath

Join appends elems to p.

func (RelPath) Split

func (p RelPath) Split() (RelPath, RelPath)

Split returns p's directory and path.

func (RelPath) TrimDirPrefix

func (p RelPath) TrimDirPrefix(dirPrefix RelPath) (RelPath, error)

TrimDirPrefix trims prefix from p.

type RelPaths

type RelPaths []RelPath

RelPaths is a slice of RelPaths that implements sort.Interface.

func (RelPaths) Len

func (ps RelPaths) Len() int

func (RelPaths) Less

func (ps RelPaths) Less(i, j int) bool

func (RelPaths) Swap

func (ps RelPaths) Swap(i, j int)

type SourceFileTargetType

type SourceFileTargetType int

A SourceFileTargetType is a the type of a target represented by a file in the source state. A file in the source state can represent a file, script, or symlink in the target state.

const (
	SourceFileTypeFile SourceFileTargetType = iota
	SourceFileTypePresent
	SourceFileTypeScript
	SourceFileTypeSymlink
)

Source file types.

type SourceRelPath

type SourceRelPath struct {
	// contains filtered or unexported fields
}

A SourceRelPath is a relative path to an entry in the source state.

func NewSourceRelDirPath

func NewSourceRelDirPath(relPath RelPath) SourceRelPath

NewSourceRelDirPath returns a new SourceRelPath for a directory.

func NewSourceRelPath

func NewSourceRelPath(relPath RelPath) SourceRelPath

NewSourceRelPath returns a new SourceRelPath.

func (SourceRelPath) Dir

func (p SourceRelPath) Dir() SourceRelPath

Dir returns p's directory.

func (SourceRelPath) Empty

func (p SourceRelPath) Empty() bool

Empty returns true if p is empty.

func (SourceRelPath) Join

func (p SourceRelPath) Join(elems ...SourceRelPath) SourceRelPath

Join appends elems to p.

func (SourceRelPath) RelPath

func (p SourceRelPath) RelPath() RelPath

RelPath returns p as a relative path.

func (SourceRelPath) Split

Split returns the p's file and directory.

func (SourceRelPath) String

func (p SourceRelPath) String() string

func (SourceRelPath) TargetRelPath

func (p SourceRelPath) TargetRelPath() RelPath

TargetRelPath returns the relative path of p's target.

type SourceRelPaths

type SourceRelPaths []SourceRelPath

SourceRelPaths is a slice of SourceRelPaths that implements sort.Interface.

func (SourceRelPaths) Len

func (ps SourceRelPaths) Len() int

func (SourceRelPaths) Less

func (ps SourceRelPaths) Less(i, j int) bool

func (SourceRelPaths) Swap

func (ps SourceRelPaths) Swap(i, j int)

type SourceState

type SourceState struct {
	// contains filtered or unexported fields
}

A SourceState is a source state.

func NewSourceState

func NewSourceState(options ...SourceStateOption) *SourceState

NewSourceState creates a new source state with the given options.

func (*SourceState) Add

func (s *SourceState) Add(sourceSystem System, persistentState PersistentState, destSystem System, destAbsPathInfos map[AbsPath]os.FileInfo, options *AddOptions) error

Add adds destAbsPathInfos to s.

func (*SourceState) AddDestAbsPathInfos

func (s *SourceState) AddDestAbsPathInfos(destAbsPathInfos map[AbsPath]os.FileInfo, system System, destAbsPath AbsPath, info os.FileInfo) error

AddDestAbsPathInfos adds an os.FileInfo to destAbsPathInfos for destAbsPath and any of its parents which are not already known.

func (*SourceState) Apply

func (s *SourceState) Apply(targetSystem System, persistentState PersistentState, targetDir AbsPath, targetRelPath RelPath, options ApplyOptions) error

Apply updates targetRelPath in targetDir in targetSystem to match s.

func (*SourceState) Entries

func (s *SourceState) Entries() map[RelPath]SourceStateEntry

Entries returns s's source state entries.

func (*SourceState) Entry

func (s *SourceState) Entry(targetRelPath RelPath) (SourceStateEntry, bool)

Entry returns the source state entry for targetRelPath.

func (*SourceState) ExecuteTemplateData

func (s *SourceState) ExecuteTemplateData(name string, data []byte) ([]byte, error)

ExecuteTemplateData returns the result of executing template data.

func (*SourceState) Ignored

func (s *SourceState) Ignored(targetRelPath RelPath) bool

Ignored returns if targetRelPath is ignored.

func (*SourceState) MinVersion

func (s *SourceState) MinVersion() semver.Version

MinVersion returns the minimum version for which s is valid.

func (*SourceState) MustEntry

func (s *SourceState) MustEntry(targetRelPath RelPath) SourceStateEntry

MustEntry returns the source state entry associated with targetRelPath, and panics if it does not exist.

func (*SourceState) Read

func (s *SourceState) Read() error

Read reads the source state from the source directory.

func (*SourceState) TargetRelPaths

func (s *SourceState) TargetRelPaths() RelPaths

TargetRelPaths returns all of s's target relative paths in order.

func (*SourceState) TemplateData

func (s *SourceState) TemplateData() map[string]interface{}

TemplateData returns s's template data.

type SourceStateDir

type SourceStateDir struct {
	Attr DirAttr
	// contains filtered or unexported fields
}

A SourceStateDir represents the state of a directory in the source state.

func (*SourceStateDir) Evaluate

func (s *SourceStateDir) Evaluate() error

Evaluate evaluates s and returns any error.

func (*SourceStateDir) Order

func (s *SourceStateDir) Order() int

Order returns s's order.

func (*SourceStateDir) SourceRelPath

func (s *SourceStateDir) SourceRelPath() SourceRelPath

SourceRelPath returns s's source relative path.

func (*SourceStateDir) TargetStateEntry

func (s *SourceStateDir) TargetStateEntry() (TargetStateEntry, error)

TargetStateEntry returns s's target state entry.

type SourceStateEntry

type SourceStateEntry interface {
	Evaluate() error
	Order() int
	SourceRelPath() SourceRelPath
	TargetStateEntry() (TargetStateEntry, error)
}

A SourceStateEntry represents the state of an entry in the source state.

type SourceStateFile

type SourceStateFile struct {
	Attr FileAttr
	// contains filtered or unexported fields
}

A SourceStateFile represents the state of a file in the source state.

func (SourceStateFile) Contents

func (lc SourceStateFile) Contents() ([]byte, error)

Contents returns lc's contents.

func (SourceStateFile) ContentsSHA256

func (lc SourceStateFile) ContentsSHA256() ([]byte, error)

ContentsSHA256 returns the SHA256 sum of lc's contents.

func (*SourceStateFile) Evaluate

func (s *SourceStateFile) Evaluate() error

Evaluate evaluates s and returns any error.

func (*SourceStateFile) Order

func (s *SourceStateFile) Order() int

Order returns s's order.

func (*SourceStateFile) SourceRelPath

func (s *SourceStateFile) SourceRelPath() SourceRelPath

SourceRelPath returns s's source relative path.

func (*SourceStateFile) TargetStateEntry

func (s *SourceStateFile) TargetStateEntry() (TargetStateEntry, error)

TargetStateEntry returns s's target state entry.

type SourceStateOption

type SourceStateOption func(*SourceState)

A SourceStateOption sets an option on a source state.

func WithDefaultTemplateDataFunc

func WithDefaultTemplateDataFunc(defaultTemplateDataFunc func() map[string]interface{}) SourceStateOption

WithDefaultTemplateDataFunc sets the default template data function.

func WithDestDir

func WithDestDir(destDirAbsPath AbsPath) SourceStateOption

WithDestDir sets the destination directory.

func WithEncryption

func WithEncryption(encryption Encryption) SourceStateOption

WithEncryption sets the encryption.

func WithPriorityTemplateData

func WithPriorityTemplateData(priorityTemplateData map[string]interface{}) SourceStateOption

WithPriorityTemplateData adds priority template data.

func WithSourceDir

func WithSourceDir(sourceDirAbsPath AbsPath) SourceStateOption

WithSourceDir sets the source directory.

func WithSystem

func WithSystem(system System) SourceStateOption

WithSystem sets the system.

func WithTemplateFuncs

func WithTemplateFuncs(templateFuncs template.FuncMap) SourceStateOption

WithTemplateFuncs sets the template functions.

func WithTemplateOptions

func WithTemplateOptions(templateOptions []string) SourceStateOption

WithTemplateOptions sets the template options.

type SourceStateRemove

type SourceStateRemove struct {
	// contains filtered or unexported fields
}

A SourceStateRemove represents that an entry should be removed.

func (*SourceStateRemove) Evaluate

func (s *SourceStateRemove) Evaluate() error

Evaluate evaluates s and returns any error.

func (*SourceStateRemove) Order

func (s *SourceStateRemove) Order() int

Order returns s's order.

func (*SourceStateRemove) SourceRelPath

func (s *SourceStateRemove) SourceRelPath() SourceRelPath

SourceRelPath returns s's source relative path.

func (*SourceStateRemove) TargetStateEntry

func (s *SourceStateRemove) TargetStateEntry() (TargetStateEntry, error)

TargetStateEntry returns s's target state entry.

type SourceStateRenameDir

type SourceStateRenameDir struct {
	// contains filtered or unexported fields
}

A SourceStateRenameDir represents the renaming of a directory in the source state.

func (*SourceStateRenameDir) Evaluate

func (s *SourceStateRenameDir) Evaluate() error

Evaluate evaluates s and returns any error.

func (*SourceStateRenameDir) Order

func (s *SourceStateRenameDir) Order() int

Order returns s's order.

func (*SourceStateRenameDir) SourceRelPath

func (s *SourceStateRenameDir) SourceRelPath() SourceRelPath

SourceRelPath returns s's source relative path.

func (*SourceStateRenameDir) TargetStateEntry

func (s *SourceStateRenameDir) TargetStateEntry() (TargetStateEntry, error)

TargetStateEntry returns s's target state entry.

type System

type System interface {
	Chmod(name AbsPath, mode os.FileMode) error
	Glob(pattern string) ([]string, error)
	IdempotentCmdOutput(cmd *exec.Cmd) ([]byte, error)
	Lstat(filename AbsPath) (os.FileInfo, error)
	Mkdir(name AbsPath, perm os.FileMode) error
	RawPath(absPath AbsPath) (AbsPath, error)
	ReadDir(dirname AbsPath) ([]os.FileInfo, error)
	ReadFile(filename AbsPath) ([]byte, error)
	Readlink(name AbsPath) (string, error)
	RemoveAll(name AbsPath) error
	Rename(oldpath, newpath AbsPath) error
	RunCmd(cmd *exec.Cmd) error
	RunScript(scriptname RelPath, dir AbsPath, data []byte) error
	Stat(name AbsPath) (os.FileInfo, error)
	UnderlyingFS() vfs.FS
	WriteFile(filename AbsPath, data []byte, perm os.FileMode) error
	WriteSymlink(oldname string, newname AbsPath) error
}

A System reads from and writes to a filesystem, executes idempotent commands, runs scripts, and persists state.

type TARReaderSystem

type TARReaderSystem struct {
	// contains filtered or unexported fields
}

A TARReaderSystem a system constructed from reading a TAR archive.

func NewTARReaderSystem

func NewTARReaderSystem(tarReader *tar.Reader, options TARReaderSystemOptions) (*TARReaderSystem, error)

NewTARReaderSystem returns a new TARReaderSystem from tarReader.

func (TARReaderSystem) Chmod

func (TARReaderSystem) Chmod(name AbsPath, perm os.FileMode) error

func (*TARReaderSystem) FileInfos

func (s *TARReaderSystem) FileInfos() map[AbsPath]os.FileInfo

FileInfos retunrs s's os.FileInfos.

func (TARReaderSystem) Glob

func (TARReaderSystem) Glob(pattern string) ([]string, error)

func (TARReaderSystem) IdempotentCmdOutput

func (TARReaderSystem) IdempotentCmdOutput(cmd *exec.Cmd) ([]byte, error)

func (*TARReaderSystem) Lstat

func (s *TARReaderSystem) Lstat(filename AbsPath) (os.FileInfo, error)

Lstat implements System.Lstat.

func (TARReaderSystem) Mkdir

func (TARReaderSystem) Mkdir(name AbsPath, perm os.FileMode) error

func (TARReaderSystem) RawPath

func (TARReaderSystem) RawPath(path AbsPath) (AbsPath, error)

func (TARReaderSystem) ReadDir

func (TARReaderSystem) ReadDir(dirname AbsPath) ([]os.FileInfo, error)

func (*TARReaderSystem) ReadFile

func (s *TARReaderSystem) ReadFile(filename AbsPath) ([]byte, error)

ReadFile implements System.ReadFile.

func (s *TARReaderSystem) Readlink(name AbsPath) (string, error)

Readlink implements System.Readlink.

func (TARReaderSystem) RemoveAll

func (TARReaderSystem) RemoveAll(name AbsPath) error

func (TARReaderSystem) Rename

func (TARReaderSystem) Rename(oldpath, newpath AbsPath) error

func (TARReaderSystem) RunCmd

func (TARReaderSystem) RunCmd(cmd *exec.Cmd) error

func (TARReaderSystem) RunScript

func (TARReaderSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte) error

func (TARReaderSystem) Stat

func (TARReaderSystem) Stat(name AbsPath) (os.FileInfo, error)

func (TARReaderSystem) UnderlyingFS

func (TARReaderSystem) UnderlyingFS() vfs.FS

func (TARReaderSystem) WriteFile

func (TARReaderSystem) WriteFile(filename AbsPath, data []byte, perm os.FileMode) error
func (TARReaderSystem) WriteSymlink(oldname string, newname AbsPath) error

type TARReaderSystemOptions

type TARReaderSystemOptions struct {
	RootAbsPath     AbsPath
	StripComponents int
}

TARReaderSystemOptions are options to NewTARReaderSystem.

type TARWriterSystem

type TARWriterSystem struct {
	// contains filtered or unexported fields
}

A TARWriterSystem is a System that writes to a TAR archive.

func NewTARWriterSystem

func NewTARWriterSystem(w io.Writer, headerTemplate tar.Header) *TARWriterSystem

NewTARWriterSystem returns a new TARWriterSystem that writes a TAR file to w.

func (TARWriterSystem) Chmod

func (TARWriterSystem) Chmod(name AbsPath, perm os.FileMode) error

func (*TARWriterSystem) Close

func (s *TARWriterSystem) Close() error

Close closes m.

func (TARWriterSystem) Glob

func (TARWriterSystem) Glob(pattern string) ([]string, error)

func (TARWriterSystem) IdempotentCmdOutput

func (TARWriterSystem) IdempotentCmdOutput(cmd *exec.Cmd) ([]byte, error)

func (TARWriterSystem) Lstat

func (TARWriterSystem) Lstat(name AbsPath) (os.FileInfo, error)

func (*TARWriterSystem) Mkdir

func (s *TARWriterSystem) Mkdir(name AbsPath, perm os.FileMode) error

Mkdir implements System.Mkdir.

func (TARWriterSystem) RawPath

func (TARWriterSystem) RawPath(path AbsPath) (AbsPath, error)

func (TARWriterSystem) ReadDir

func (TARWriterSystem) ReadDir(dirname AbsPath) ([]os.FileInfo, error)

func (TARWriterSystem) ReadFile

func (TARWriterSystem) ReadFile(filename AbsPath) ([]byte, error)
func (TARWriterSystem) Readlink(name AbsPath) (string, error)

func (TARWriterSystem) RemoveAll

func (TARWriterSystem) RemoveAll(name AbsPath) error

func (TARWriterSystem) Rename

func (TARWriterSystem) Rename(oldpath, newpath AbsPath) error

func (TARWriterSystem) RunCmd

func (TARWriterSystem) RunCmd(cmd *exec.Cmd) error

func (*TARWriterSystem) RunScript

func (s *TARWriterSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte) error

RunScript implements System.RunScript.

func (TARWriterSystem) Stat

func (TARWriterSystem) Stat(name AbsPath) (os.FileInfo, error)

func (TARWriterSystem) UnderlyingFS

func (TARWriterSystem) UnderlyingFS() vfs.FS

func (*TARWriterSystem) WriteFile

func (s *TARWriterSystem) WriteFile(filename AbsPath, data []byte, perm os.FileMode) error

WriteFile implements System.WriteFile.

func (s *TARWriterSystem) WriteSymlink(oldname string, newname AbsPath) error

WriteSymlink implements System.WriteSymlink.

type TargetStateAbsent

type TargetStateAbsent struct{}

A TargetStateAbsent represents the absence of an entry in the target state.

func (*TargetStateAbsent) Apply

func (t *TargetStateAbsent) Apply(system System, persistentState PersistentState, actualStateEntry ActualStateEntry, umask os.FileMode) error

Apply updates actualStateEntry to match t.

func (*TargetStateAbsent) EntryState

func (t *TargetStateAbsent) EntryState(umask os.FileMode) (*EntryState, error)

EntryState returns t's entry state.

func (*TargetStateAbsent) Evaluate

func (t *TargetStateAbsent) Evaluate() error

Evaluate evaluates t.

func (*TargetStateAbsent) SkipApply

func (t *TargetStateAbsent) SkipApply(persistentState PersistentState) (bool, error)

SkipApply implements TargetState.SkipApply.

type TargetStateDir

type TargetStateDir struct {
	// contains filtered or unexported fields
}

A TargetStateDir represents the state of a directory in the target state.

func (*TargetStateDir) Apply

func (t *TargetStateDir) Apply(system System, persistentState PersistentState, actualStateEntry ActualStateEntry, umask os.FileMode) error

Apply updates actualStateEntry to match t. It does not recurse.

func (*TargetStateDir) EntryState

func (t *TargetStateDir) EntryState(umask os.FileMode) (*EntryState, error)

EntryState returns t's entry state.

func (*TargetStateDir) Evaluate

func (t *TargetStateDir) Evaluate() error

Evaluate evaluates t.

func (*TargetStateDir) SkipApply

func (t *TargetStateDir) SkipApply(persistentState PersistentState) (bool, error)

SkipApply implements TargetState.SkipApply.

type TargetStateEntry

type TargetStateEntry interface {
	Apply(system System, persistentState PersistentState, actualStateEntry ActualStateEntry, umask os.FileMode) error
	EntryState(umask os.FileMode) (*EntryState, error)
	Evaluate() error
	SkipApply(persistentState PersistentState) (bool, error)
}

A TargetStateEntry represents the state of an entry in the target state.

type TargetStateFile

type TargetStateFile struct {
	// contains filtered or unexported fields
}

A TargetStateFile represents the state of a file in the target state.

func (*TargetStateFile) Apply

func (t *TargetStateFile) Apply(system System, persistentState PersistentState, actualStateEntry ActualStateEntry, umask os.FileMode) error

Apply updates actualStateEntry to match t.

func (TargetStateFile) Contents

func (lc TargetStateFile) Contents() ([]byte, error)

Contents returns lc's contents.

func (TargetStateFile) ContentsSHA256

func (lc TargetStateFile) ContentsSHA256() ([]byte, error)

ContentsSHA256 returns the SHA256 sum of lc's contents.

func (*TargetStateFile) EntryState

func (t *TargetStateFile) EntryState(umask os.FileMode) (*EntryState, error)

EntryState returns t's entry state.

func (*TargetStateFile) Evaluate

func (t *TargetStateFile) Evaluate() error

Evaluate evaluates t.

func (*TargetStateFile) SkipApply

func (t *TargetStateFile) SkipApply(persistentState PersistentState) (bool, error)

SkipApply implements TargetState.SkipApply.

type TargetStatePresent

type TargetStatePresent struct {
	// contains filtered or unexported fields
}

A TargetStatePresent represents the presence of an entry in the target state.

func (*TargetStatePresent) Apply

func (t *TargetStatePresent) Apply(system System, persistentState PersistentState, actualStateEntry ActualStateEntry, umask os.FileMode) error

Apply updates actualStateEntry to match t.

func (TargetStatePresent) Contents

func (lc TargetStatePresent) Contents() ([]byte, error)

Contents returns lc's contents.

func (TargetStatePresent) ContentsSHA256

func (lc TargetStatePresent) ContentsSHA256() ([]byte, error)

ContentsSHA256 returns the SHA256 sum of lc's contents.

func (*TargetStatePresent) EntryState

func (t *TargetStatePresent) EntryState(umask os.FileMode) (*EntryState, error)

EntryState returns t's entry state.

func (*TargetStatePresent) Evaluate

func (t *TargetStatePresent) Evaluate() error

Evaluate evaluates t.

func (*TargetStatePresent) SkipApply

func (t *TargetStatePresent) SkipApply(persistentState PersistentState) (bool, error)

SkipApply implements TargetState.SkipApply.

type TargetStateRenameDir

type TargetStateRenameDir struct {
	// contains filtered or unexported fields
}

A TargetStateRenameDir represents the renaming of a directory in the target state.

func (*TargetStateRenameDir) Apply

func (t *TargetStateRenameDir) Apply(system System, persistentState PersistentState, actualStateEntry ActualStateEntry, umask os.FileMode) error

Apply renames actualStateEntry.

func (*TargetStateRenameDir) EntryState

func (t *TargetStateRenameDir) EntryState(umask os.FileMode) (*EntryState, error)

EntryState returns t's entry state.

func (*TargetStateRenameDir) Evaluate

func (t *TargetStateRenameDir) Evaluate() error

Evaluate does nothing.

func (*TargetStateRenameDir) SkipApply

func (t *TargetStateRenameDir) SkipApply(persistentState PersistentState) (bool, error)

SkipApply implements TargetState.SkipApply.

type TargetStateScript

type TargetStateScript struct {
	// contains filtered or unexported fields
}

A TargetStateScript represents the state of a script.

func (*TargetStateScript) Apply

func (t *TargetStateScript) Apply(system System, persistentState PersistentState, actualStateEntry ActualStateEntry, umask os.FileMode) error

Apply runs t.

func (TargetStateScript) Contents

func (lc TargetStateScript) Contents() ([]byte, error)

Contents returns lc's contents.

func (TargetStateScript) ContentsSHA256

func (lc TargetStateScript) ContentsSHA256() ([]byte, error)

ContentsSHA256 returns the SHA256 sum of lc's contents.

func (*TargetStateScript) EntryState

func (t *TargetStateScript) EntryState(umask os.FileMode) (*EntryState, error)

EntryState returns t's entry state.

func (*TargetStateScript) Evaluate

func (t *TargetStateScript) Evaluate() error

Evaluate evaluates t.

func (*TargetStateScript) SkipApply

func (t *TargetStateScript) SkipApply(persistentState PersistentState) (bool, error)

SkipApply implements TargetState.SkipApply.

type TargetStateSymlink struct {
	// contains filtered or unexported fields
}

A TargetStateSymlink represents the state of a symlink in the target state.

func (*TargetStateSymlink) Apply

func (t *TargetStateSymlink) Apply(system System, persistentState PersistentState, actualStateEntry ActualStateEntry, umask os.FileMode) error

Apply updates actualStateEntry to match t.

func (*TargetStateSymlink) EntryState

func (t *TargetStateSymlink) EntryState(umask os.FileMode) (*EntryState, error)

EntryState returns t's entry state.

func (*TargetStateSymlink) Evaluate

func (t *TargetStateSymlink) Evaluate() error

Evaluate evaluates t.

func (TargetStateSymlink) Linkname

func (ll TargetStateSymlink) Linkname() (string, error)

Linkname returns s's linkname.

func (TargetStateSymlink) LinknameSHA256

func (ll TargetStateSymlink) LinknameSHA256() ([]byte, error)

LinknameSHA256 returns the SHA256 sum of ll's linkname.

func (*TargetStateSymlink) SkipApply

func (t *TargetStateSymlink) SkipApply(persistentState PersistentState) (bool, error)

SkipApply implements TargetState.SkipApply.

type ZIPWriterSystem

type ZIPWriterSystem struct {
	// contains filtered or unexported fields
}

A ZIPWriterSystem is a System that writes to a ZIP archive.

func NewZIPWriterSystem

func NewZIPWriterSystem(w io.Writer, modified time.Time) *ZIPWriterSystem

NewZIPWriterSystem returns a new ZIPWriterSystem that writes a ZIP archive to w.

func (ZIPWriterSystem) Chmod

func (ZIPWriterSystem) Chmod(name AbsPath, perm os.FileMode) error

func (*ZIPWriterSystem) Close

func (s *ZIPWriterSystem) Close() error

Close closes m.

func (ZIPWriterSystem) Glob

func (ZIPWriterSystem) Glob(pattern string) ([]string, error)

func (ZIPWriterSystem) IdempotentCmdOutput

func (ZIPWriterSystem) IdempotentCmdOutput(cmd *exec.Cmd) ([]byte, error)

func (ZIPWriterSystem) Lstat

func (ZIPWriterSystem) Lstat(name AbsPath) (os.FileInfo, error)

func (*ZIPWriterSystem) Mkdir

func (s *ZIPWriterSystem) Mkdir(name AbsPath, perm os.FileMode) error

Mkdir implements System.Mkdir.

func (ZIPWriterSystem) RawPath

func (ZIPWriterSystem) RawPath(path AbsPath) (AbsPath, error)

func (ZIPWriterSystem) ReadDir

func (ZIPWriterSystem) ReadDir(dirname AbsPath) ([]os.FileInfo, error)

func (ZIPWriterSystem) ReadFile

func (ZIPWriterSystem) ReadFile(filename AbsPath) ([]byte, error)
func (ZIPWriterSystem) Readlink(name AbsPath) (string, error)

func (ZIPWriterSystem) RemoveAll

func (ZIPWriterSystem) RemoveAll(name AbsPath) error

func (ZIPWriterSystem) Rename

func (ZIPWriterSystem) Rename(oldpath, newpath AbsPath) error

func (ZIPWriterSystem) RunCmd

func (ZIPWriterSystem) RunCmd(cmd *exec.Cmd) error

func (*ZIPWriterSystem) RunScript

func (s *ZIPWriterSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte) error

RunScript implements System.RunScript.

func (ZIPWriterSystem) Stat

func (ZIPWriterSystem) Stat(name AbsPath) (os.FileInfo, error)

func (ZIPWriterSystem) UnderlyingFS

func (ZIPWriterSystem) UnderlyingFS() vfs.FS

func (*ZIPWriterSystem) WriteFile

func (s *ZIPWriterSystem) WriteFile(filename AbsPath, data []byte, perm os.FileMode) error

WriteFile implements System.WriteFile.

func (s *ZIPWriterSystem) WriteSymlink(oldname string, newname AbsPath) error

WriteSymlink implements System.WriteSymlink.

Jump to

Keyboard shortcuts

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