Documentation
¶
Overview ¶
Package chezmoi contains chezmoi's core logic.
Index ¶
- Constants
- Variables
- func DiffPatch(path RelPath, fromData []byte, fromMode fs.FileMode, toData []byte, ...) (diff.Patch, error)
- func EntryTypeSetFlagCompletionFunc(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)
- func FQDNHostname(fileSystem vfs.FS) (string, error)
- func FlagCompletionFunc(allCompletions []string) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)
- func Glob(fileSystem vfs.FS, prefix string) ([]string, error)
- func Kernel(fileSystem vfs.FS) (map[string]any, error)
- func LookPath(file string) (string, error)
- func MkdirAll(system System, absPath AbsPath, perm fs.FileMode) error
- func NewGitHubClient(ctx context.Context, httpClient *http.Client) *github.Client
- func OSRelease(fileSystem vfs.FS) (map[string]any, error)
- func ParseBool(str string) (bool, error)
- func PersistentStateBucketData(s PersistentState, bucket []byte) (map[string]any, error)
- func PersistentStateData(s PersistentState, buckets map[string][]byte) (map[string]any, error)
- func PersistentStateGet(s PersistentState, bucket, key []byte, value any) (bool, error)
- func PersistentStateSet(s PersistentState, bucket, key []byte, value any) error
- func RecursiveMerge(dest, source map[string]any)
- func SHA256Sum(data []byte) []byte
- func StringSliceToEntryTypeSetHookFunc() mapstructure.DecodeHookFunc
- func StringToAbsPathHookFunc() mapstructure.DecodeHookFunc
- func SuspiciousSourceDirEntry(base string, fileInfo fs.FileInfo, encryptedSuffixes []string) bool
- func UniqueAbbreviations(values []string) map[string]string
- func Walk(system System, rootAbsPath AbsPath, walkFunc WalkFunc) error
- func WalkArchive(data []byte, format ArchiveFormat, f WalkArchiveFunc) error
- func WalkSourceDir(system System, sourceDirAbsPath AbsPath, walkFunc WalkFunc) error
- type AbsPath
- func (p AbsPath) Append(s string) AbsPath
- func (p AbsPath) Base() string
- func (p AbsPath) Bytes() []byte
- func (p AbsPath) Dir() AbsPath
- func (p AbsPath) Empty() bool
- func (p AbsPath) Ext() string
- func (p AbsPath) Join(relPaths ...RelPath) AbsPath
- func (p AbsPath) JoinString(ss ...string) AbsPath
- func (p AbsPath) Len() int
- func (p AbsPath) Less(other AbsPath) bool
- func (p AbsPath) MarshalText() ([]byte, error)
- func (p AbsPath) MustTrimDirPrefix(dirPrefix AbsPath) RelPath
- func (p *AbsPath) Set(s string) error
- func (p AbsPath) Split() (AbsPath, RelPath)
- func (p AbsPath) String() string
- func (p AbsPath) ToSlash() AbsPath
- func (p AbsPath) TrimDirPrefix(dirPrefixAbsPath AbsPath) (RelPath, error)
- func (p AbsPath) TrimSuffix(suffix string) AbsPath
- func (p AbsPath) Type() string
- func (p *AbsPath) UnmarshalText(text []byte) error
- type AbsPaths
- type ActualStateAbsent
- type ActualStateDir
- type ActualStateEntry
- type ActualStateFile
- func (lc ActualStateFile) Contents() ([]byte, error)
- func (lc ActualStateFile) ContentsSHA256() ([]byte, error)
- func (s *ActualStateFile) EntryState() (*EntryState, error)
- func (s *ActualStateFile) OriginString() string
- func (s *ActualStateFile) Path() AbsPath
- func (s *ActualStateFile) Perm() fs.FileMode
- func (s *ActualStateFile) Remove(system System) error
- type ActualStateSymlink
- func (s *ActualStateSymlink) EntryState() (*EntryState, error)
- func (ll ActualStateSymlink) Linkname() (string, error)
- func (ll ActualStateSymlink) LinknameSHA256() ([]byte, error)
- func (s *ActualStateSymlink) OriginString() string
- func (s *ActualStateSymlink) Path() AbsPath
- func (s *ActualStateSymlink) Remove(system System) error
- type AddOptions
- type AgeEncryption
- func (e *AgeEncryption) Decrypt(ciphertext []byte) ([]byte, error)
- func (e *AgeEncryption) DecryptToFile(plaintextAbsPath AbsPath, ciphertext []byte) error
- func (e *AgeEncryption) Encrypt(plaintext []byte) ([]byte, error)
- func (e *AgeEncryption) EncryptFile(plaintextAbsPath AbsPath) ([]byte, error)
- func (e *AgeEncryption) EncryptedSuffix() string
- type ApplyOptions
- type ArchiveFormat
- type ArchiveReaderSystem
- func (ArchiveReaderSystem) Chmod(name AbsPath, perm fs.FileMode) error
- func (ArchiveReaderSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
- func (s *ArchiveReaderSystem) FileInfos() map[AbsPath]fs.FileInfo
- func (ArchiveReaderSystem) Glob(pattern string) ([]string, error)
- func (ArchiveReaderSystem) Link(oldname, newname AbsPath) error
- func (s *ArchiveReaderSystem) Lstat(filename AbsPath) (fs.FileInfo, error)
- func (ArchiveReaderSystem) Mkdir(name AbsPath, perm fs.FileMode) error
- func (ArchiveReaderSystem) RawPath(path AbsPath) (AbsPath, error)
- func (ArchiveReaderSystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
- func (s *ArchiveReaderSystem) ReadFile(name AbsPath) ([]byte, error)
- func (s *ArchiveReaderSystem) Readlink(name AbsPath) (string, error)
- func (ArchiveReaderSystem) Remove(name AbsPath) error
- func (ArchiveReaderSystem) RemoveAll(name AbsPath) error
- func (ArchiveReaderSystem) Rename(oldpath, newpath AbsPath) error
- func (ArchiveReaderSystem) RunCmd(cmd *exec.Cmd) error
- func (ArchiveReaderSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions) error
- func (ArchiveReaderSystem) Stat(name AbsPath) (fs.FileInfo, error)
- func (ArchiveReaderSystem) UnderlyingFS() vfs.FS
- func (s *ArchiveReaderSystem) UnderlyingSystem() System
- func (ArchiveReaderSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error
- func (ArchiveReaderSystem) WriteSymlink(oldname string, newname AbsPath) error
- type ArchiveReaderSystemOptions
- type BoltPersistentState
- func (b *BoltPersistentState) Close() error
- func (b *BoltPersistentState) CopyTo(p PersistentState) error
- func (b *BoltPersistentState) Data() (any, error)
- func (b *BoltPersistentState) Delete(bucket, key []byte) error
- func (b *BoltPersistentState) DeleteBucket(bucket []byte) error
- func (b *BoltPersistentState) ForEach(bucket []byte, fn func(k, v []byte) error) error
- func (b *BoltPersistentState) Get(bucket, key []byte) ([]byte, error)
- func (b *BoltPersistentState) Set(bucket, key, value []byte) error
- type BoltPersistentStateMode
- type DebugEncryption
- func (e *DebugEncryption) Decrypt(ciphertext []byte) ([]byte, error)
- func (e *DebugEncryption) DecryptToFile(plaintextAbsPath AbsPath, ciphertext []byte) error
- func (e *DebugEncryption) Encrypt(plaintext []byte) ([]byte, error)
- func (e *DebugEncryption) EncryptFile(plaintextAbsPath AbsPath) ([]byte, error)
- func (e *DebugEncryption) EncryptedSuffix() string
- type DebugPersistentState
- func (s *DebugPersistentState) Close() error
- func (s *DebugPersistentState) CopyTo(p PersistentState) error
- func (s *DebugPersistentState) Data() (any, error)
- func (s *DebugPersistentState) Delete(bucket, key []byte) error
- func (s *DebugPersistentState) DeleteBucket(bucket []byte) error
- func (s *DebugPersistentState) ForEach(bucket []byte, fn func(k, v []byte) error) error
- func (s *DebugPersistentState) Get(bucket, key []byte) ([]byte, error)
- func (s *DebugPersistentState) Set(bucket, key, value []byte) error
- type DebugSystem
- func (s *DebugSystem) Chmod(name AbsPath, mode fs.FileMode) error
- func (s *DebugSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
- func (s *DebugSystem) Glob(name string) ([]string, error)
- func (s *DebugSystem) Link(oldpath, newpath AbsPath) error
- func (s *DebugSystem) Lstat(name AbsPath) (fs.FileInfo, error)
- func (s *DebugSystem) Mkdir(name AbsPath, perm fs.FileMode) error
- func (s *DebugSystem) RawPath(path AbsPath) (AbsPath, error)
- func (s *DebugSystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
- func (s *DebugSystem) ReadFile(name AbsPath) ([]byte, error)
- func (s *DebugSystem) Readlink(name AbsPath) (string, error)
- func (s *DebugSystem) Remove(name AbsPath) error
- func (s *DebugSystem) RemoveAll(name AbsPath) error
- func (s *DebugSystem) Rename(oldpath, newpath AbsPath) error
- func (s *DebugSystem) RunCmd(cmd *exec.Cmd) error
- func (s *DebugSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions) error
- func (s *DebugSystem) Stat(name AbsPath) (fs.FileInfo, error)
- func (s *DebugSystem) UnderlyingFS() vfs.FS
- func (s *DebugSystem) UnderlyingSystem() System
- func (s *DebugSystem) WriteFile(name AbsPath, data []byte, perm fs.FileMode) error
- func (s *DebugSystem) WriteSymlink(oldname string, newname AbsPath) error
- type DirAttr
- type DryRunSystem
- func (s *DryRunSystem) Chmod(name AbsPath, mode fs.FileMode) error
- func (s *DryRunSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
- func (s *DryRunSystem) Glob(pattern string) ([]string, error)
- func (s *DryRunSystem) Link(oldname, newname AbsPath) error
- func (s *DryRunSystem) Lstat(name AbsPath) (fs.FileInfo, error)
- func (s *DryRunSystem) Mkdir(name AbsPath, perm fs.FileMode) error
- func (s *DryRunSystem) Modified() bool
- func (s *DryRunSystem) RawPath(path AbsPath) (AbsPath, error)
- func (s *DryRunSystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
- func (s *DryRunSystem) ReadFile(name AbsPath) ([]byte, error)
- func (s *DryRunSystem) Readlink(name AbsPath) (string, error)
- func (s *DryRunSystem) Remove(AbsPath) error
- func (s *DryRunSystem) RemoveAll(AbsPath) error
- func (s *DryRunSystem) Rename(oldpath, newpath AbsPath) error
- func (s *DryRunSystem) RunCmd(cmd *exec.Cmd) error
- func (s *DryRunSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions) error
- func (s *DryRunSystem) Stat(name AbsPath) (fs.FileInfo, error)
- func (s *DryRunSystem) UnderlyingFS() vfs.FS
- func (s *DryRunSystem) UnderlyingSystem() System
- func (s *DryRunSystem) WriteFile(AbsPath, []byte, fs.FileMode) error
- func (s *DryRunSystem) WriteSymlink(string, AbsPath) error
- type DumpSystem
- func (DumpSystem) Chmod(name AbsPath, perm fs.FileMode) error
- func (DumpSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
- func (s *DumpSystem) Data() any
- func (DumpSystem) Glob(pattern string) ([]string, error)
- func (DumpSystem) Link(oldname, newname AbsPath) error
- func (DumpSystem) Lstat(name AbsPath) (fs.FileInfo, error)
- func (s *DumpSystem) Mkdir(dirname AbsPath, perm fs.FileMode) error
- func (DumpSystem) RawPath(path AbsPath) (AbsPath, error)
- func (DumpSystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
- func (DumpSystem) ReadFile(name AbsPath) ([]byte, error)
- func (DumpSystem) Readlink(name AbsPath) (string, error)
- func (DumpSystem) Remove(name AbsPath) error
- func (DumpSystem) RemoveAll(name AbsPath) error
- func (DumpSystem) Rename(oldpath, newpath AbsPath) error
- func (s *DumpSystem) RunCmd(cmd *exec.Cmd) error
- func (s *DumpSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions) error
- func (DumpSystem) Stat(name AbsPath) (fs.FileInfo, error)
- func (s *DumpSystem) UnderlyingFS() vfs.FS
- func (s *DumpSystem) UnderlyingSystem() System
- func (s *DumpSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error
- func (s *DumpSystem) WriteSymlink(oldname string, newname AbsPath) error
- type Duration
- type Encryption
- type EntryState
- type EntryStateType
- type EntryTypeBits
- type EntryTypeFilter
- func (f *EntryTypeFilter) IncludeEntryTypeBits(entryTypeBits EntryTypeBits) bool
- func (f *EntryTypeFilter) IncludeFileInfo(fileInfo fs.FileInfo) bool
- func (f *EntryTypeFilter) IncludeSourceStateEntry(sourceStateEntry SourceStateEntry) bool
- func (f *EntryTypeFilter) IncludeTargetStateEntry(targetStateEntry TargetStateEntry) bool
- type EntryTypeSet
- func (s *EntryTypeSet) Bits() EntryTypeBits
- func (s *EntryTypeSet) ContainsEntryTypeBits(b EntryTypeBits) bool
- func (s *EntryTypeSet) ContainsFileInfo(fileInfo fs.FileInfo) bool
- func (s *EntryTypeSet) ContainsSourceStateEntry(sourceStateEntry SourceStateEntry) bool
- func (s *EntryTypeSet) ContainsTargetStateEntry(targetStateEntry TargetStateEntry) bool
- func (s *EntryTypeSet) MarshalJSON() ([]byte, error)
- func (s *EntryTypeSet) MarshalYAML() (any, error)
- func (s *EntryTypeSet) Set(str string) error
- func (s *EntryTypeSet) SetSlice(ss []string) error
- func (s *EntryTypeSet) String() string
- func (s *EntryTypeSet) Type() string
- type ErrorOnWriteSystem
- func (s *ErrorOnWriteSystem) Chmod(name AbsPath, mode fs.FileMode) error
- func (s *ErrorOnWriteSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
- func (s *ErrorOnWriteSystem) Glob(pattern string) ([]string, error)
- func (s *ErrorOnWriteSystem) Link(oldname, newname AbsPath) error
- func (s *ErrorOnWriteSystem) Lstat(name AbsPath) (fs.FileInfo, error)
- func (s *ErrorOnWriteSystem) Mkdir(name AbsPath, perm fs.FileMode) error
- func (s *ErrorOnWriteSystem) RawPath(path AbsPath) (AbsPath, error)
- func (s *ErrorOnWriteSystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
- func (s *ErrorOnWriteSystem) ReadFile(name AbsPath) ([]byte, error)
- func (s *ErrorOnWriteSystem) Readlink(name AbsPath) (string, error)
- func (s *ErrorOnWriteSystem) Remove(AbsPath) error
- func (s *ErrorOnWriteSystem) RemoveAll(AbsPath) error
- func (s *ErrorOnWriteSystem) Rename(oldpath, newpath AbsPath) error
- func (s *ErrorOnWriteSystem) RunCmd(cmd *exec.Cmd) error
- func (s *ErrorOnWriteSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions) error
- func (s *ErrorOnWriteSystem) Stat(name AbsPath) (fs.FileInfo, error)
- func (s *ErrorOnWriteSystem) UnderlyingFS() vfs.FS
- func (s *ErrorOnWriteSystem) UnderlyingSystem() System
- func (s *ErrorOnWriteSystem) WriteFile(AbsPath, []byte, fs.FileMode) error
- func (s *ErrorOnWriteSystem) WriteSymlink(string, AbsPath) error
- type ExecuteTemplateDataOptions
- type ExitCodeError
- type External
- type ExternalDiffSystem
- func (s *ExternalDiffSystem) Chmod(name AbsPath, mode fs.FileMode) error
- func (s *ExternalDiffSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
- func (s *ExternalDiffSystem) Close() error
- func (s *ExternalDiffSystem) Glob(pattern string) ([]string, error)
- func (s *ExternalDiffSystem) Link(oldname, newname AbsPath) error
- func (s *ExternalDiffSystem) Lstat(name AbsPath) (fs.FileInfo, error)
- func (s *ExternalDiffSystem) Mkdir(name AbsPath, perm fs.FileMode) error
- func (s *ExternalDiffSystem) RawPath(path AbsPath) (AbsPath, error)
- func (s *ExternalDiffSystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
- func (s *ExternalDiffSystem) ReadFile(name AbsPath) ([]byte, error)
- func (s *ExternalDiffSystem) Readlink(name AbsPath) (string, error)
- func (s *ExternalDiffSystem) Remove(name AbsPath) error
- func (s *ExternalDiffSystem) RemoveAll(name AbsPath) error
- func (s *ExternalDiffSystem) Rename(oldpath, newpath AbsPath) error
- func (s *ExternalDiffSystem) RunCmd(cmd *exec.Cmd) error
- func (s *ExternalDiffSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions) error
- func (s *ExternalDiffSystem) Stat(name AbsPath) (fs.FileInfo, error)
- func (s *ExternalDiffSystem) UnderlyingFS() vfs.FS
- func (s *ExternalDiffSystem) UnderlyingSystem() System
- func (s *ExternalDiffSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error
- func (s *ExternalDiffSystem) WriteSymlink(oldname string, newname AbsPath) error
- type ExternalDiffSystemOptions
- type ExternalType
- type FileAttr
- type Format
- type GPGEncryption
- func (e *GPGEncryption) Decrypt(ciphertext []byte) ([]byte, error)
- func (e *GPGEncryption) DecryptToFile(plaintextFilename AbsPath, ciphertext []byte) error
- func (e *GPGEncryption) Encrypt(plaintext []byte) ([]byte, error)
- func (e *GPGEncryption) EncryptFile(plaintextFilename AbsPath) ([]byte, error)
- func (e *GPGEncryption) EncryptedSuffix() string
- type GitDiffSystem
- func (s *GitDiffSystem) Chmod(name AbsPath, mode fs.FileMode) error
- func (s *GitDiffSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
- func (s *GitDiffSystem) Glob(pattern string) ([]string, error)
- func (s *GitDiffSystem) Link(oldname, newname AbsPath) error
- func (s *GitDiffSystem) Lstat(name AbsPath) (fs.FileInfo, error)
- func (s *GitDiffSystem) Mkdir(name AbsPath, perm fs.FileMode) error
- func (s *GitDiffSystem) RawPath(path AbsPath) (AbsPath, error)
- func (s *GitDiffSystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
- func (s *GitDiffSystem) ReadFile(name AbsPath) ([]byte, error)
- func (s *GitDiffSystem) Readlink(name AbsPath) (string, error)
- func (s *GitDiffSystem) Remove(name AbsPath) error
- func (s *GitDiffSystem) RemoveAll(name AbsPath) error
- func (s *GitDiffSystem) Rename(oldpath, newpath AbsPath) error
- func (s *GitDiffSystem) RunCmd(cmd *exec.Cmd) error
- func (s *GitDiffSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions) error
- func (s *GitDiffSystem) Stat(name AbsPath) (fs.FileInfo, error)
- func (s *GitDiffSystem) UnderlyingFS() vfs.FS
- func (s *GitDiffSystem) UnderlyingSystem() System
- func (s *GitDiffSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error
- func (s *GitDiffSystem) WriteSymlink(oldname string, newname AbsPath) error
- type GitDiffSystemOptions
- type HexBytes
- type Interpreter
- type MockPersistentState
- func (s *MockPersistentState) Close() error
- func (s *MockPersistentState) CopyTo(p PersistentState) error
- func (s *MockPersistentState) Data() (any, error)
- func (s *MockPersistentState) Delete(bucket, key []byte) error
- func (s *MockPersistentState) DeleteBucket(bucket []byte) error
- func (s *MockPersistentState) ForEach(bucket []byte, fn func(k, v []byte) error) error
- func (s *MockPersistentState) Get(bucket, key []byte) ([]byte, error)
- func (s *MockPersistentState) Set(bucket, key, value []byte) error
- type Mode
- type NoEncryption
- type NotInAbsDirError
- type NullPersistentState
- func (NullPersistentState) Close() error
- func (NullPersistentState) CopyTo(s PersistentState) error
- func (NullPersistentState) Data() (any, error)
- func (NullPersistentState) Delete(bucket, key []byte) error
- func (NullPersistentState) DeleteBucket(bucket []byte) error
- func (NullPersistentState) ForEach(bucket []byte, fn func(k, v []byte) error) error
- func (NullPersistentState) Get(bucket, key []byte) ([]byte, error)
- func (NullPersistentState) Set(bucket, key, value []byte) error
- type NullSystem
- func (NullSystem) Chmod(name AbsPath, perm fs.FileMode) error
- func (NullSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
- func (NullSystem) Glob(pattern string) ([]string, error)
- func (NullSystem) Link(oldname, newname AbsPath) error
- func (NullSystem) Lstat(name AbsPath) (fs.FileInfo, error)
- func (NullSystem) Mkdir(name AbsPath, perm fs.FileMode) error
- func (NullSystem) RawPath(path AbsPath) (AbsPath, error)
- func (NullSystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
- func (NullSystem) ReadFile(name AbsPath) ([]byte, error)
- func (NullSystem) Readlink(name AbsPath) (string, error)
- func (NullSystem) Remove(name AbsPath) error
- func (NullSystem) RemoveAll(name AbsPath) error
- func (NullSystem) Rename(oldpath, newpath AbsPath) error
- func (NullSystem) RunCmd(cmd *exec.Cmd) error
- func (NullSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions) error
- func (NullSystem) Stat(name AbsPath) (fs.FileInfo, error)
- func (NullSystem) UnderlyingFS() vfs.FS
- func (s *NullSystem) UnderlyingSystem() System
- func (NullSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error
- func (NullSystem) WriteSymlink(oldname string, newname AbsPath) error
- type PersistentState
- type PreAddFunc
- type PreApplyFunc
- type ReadOnlySystem
- func (ReadOnlySystem) Chmod(name AbsPath, perm fs.FileMode) error
- func (ReadOnlySystem) Chtimes(name AbsPath, atime, mtime time.Time) error
- func (s *ReadOnlySystem) Glob(pattern string) ([]string, error)
- func (ReadOnlySystem) Link(oldname, newname AbsPath) error
- func (s *ReadOnlySystem) Lstat(filename AbsPath) (fs.FileInfo, error)
- func (ReadOnlySystem) Mkdir(name AbsPath, perm fs.FileMode) error
- func (s *ReadOnlySystem) RawPath(path AbsPath) (AbsPath, error)
- func (s *ReadOnlySystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
- func (s *ReadOnlySystem) ReadFile(name AbsPath) ([]byte, error)
- func (s *ReadOnlySystem) Readlink(name AbsPath) (string, error)
- func (ReadOnlySystem) Remove(name AbsPath) error
- func (ReadOnlySystem) RemoveAll(name AbsPath) error
- func (ReadOnlySystem) Rename(oldpath, newpath AbsPath) error
- func (ReadOnlySystem) RunCmd(cmd *exec.Cmd) error
- func (ReadOnlySystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions) error
- func (s *ReadOnlySystem) Stat(name AbsPath) (fs.FileInfo, error)
- func (s *ReadOnlySystem) UnderlyingFS() vfs.FS
- func (s *ReadOnlySystem) UnderlyingSystem() System
- func (ReadOnlySystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error
- func (ReadOnlySystem) WriteSymlink(oldname string, newname AbsPath) error
- type ReadOptions
- type RealSystem
- func (s *RealSystem) Chmod(name AbsPath, mode fs.FileMode) error
- func (s *RealSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
- func (s *RealSystem) Glob(pattern string) ([]string, error)
- func (s *RealSystem) Link(oldname, newname AbsPath) error
- func (s *RealSystem) Lstat(filename AbsPath) (fs.FileInfo, error)
- func (s *RealSystem) Mkdir(name AbsPath, perm fs.FileMode) error
- func (s *RealSystem) RawPath(absPath AbsPath) (AbsPath, error)
- func (s *RealSystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
- func (s *RealSystem) ReadFile(name AbsPath) ([]byte, error)
- func (s *RealSystem) Readlink(name AbsPath) (string, error)
- func (s *RealSystem) Remove(name AbsPath) error
- func (s *RealSystem) RemoveAll(name AbsPath) error
- func (s *RealSystem) Rename(oldpath, newpath AbsPath) error
- func (s *RealSystem) RunCmd(cmd *exec.Cmd) error
- func (s *RealSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions) (err error)
- func (s *RealSystem) SetScriptEnv(scriptEnv []string)
- func (s *RealSystem) Stat(name AbsPath) (fs.FileInfo, error)
- func (s *RealSystem) UnderlyingFS() vfs.FS
- func (s *RealSystem) UnderlyingSystem() System
- func (s *RealSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) (err error)
- func (s *RealSystem) WriteSymlink(oldname string, newname AbsPath) error
- type RealSystemOption
- type RefreshExternals
- type RelPath
- func (p RelPath) AppendString(s string) RelPath
- func (p RelPath) Base() string
- func (p RelPath) Dir() RelPath
- func (p RelPath) Empty() bool
- func (p RelPath) Ext() string
- func (p RelPath) HasDirPrefix(dirPrefix RelPath) bool
- func (p RelPath) Join(relPaths ...RelPath) RelPath
- func (p RelPath) JoinString(ss ...string) RelPath
- func (p RelPath) Len() int
- func (p RelPath) Less(other RelPath) bool
- func (p RelPath) MarshalJSON() ([]byte, error)
- func (p RelPath) Slice(begin, end int) RelPath
- func (p RelPath) SourceRelDirPath() SourceRelPath
- func (p RelPath) SourceRelPath() SourceRelPath
- func (p RelPath) Split() (RelPath, RelPath)
- func (p RelPath) SplitAll() []RelPath
- func (p RelPath) String() string
- func (p RelPath) TrimDirPrefix(dirPrefix RelPath) (RelPath, error)
- type RelPaths
- type ReplaceFunc
- type RunScriptOptions
- type ScriptCondition
- type ScriptOrder
- type SourceAttr
- type SourceDirTargetType
- type SourceFileTargetType
- type SourceRelPath
- func (p SourceRelPath) Dir() SourceRelPath
- func (p SourceRelPath) Empty() bool
- func (p SourceRelPath) Join(sourceRelPaths ...SourceRelPath) SourceRelPath
- func (p SourceRelPath) Less(other SourceRelPath) bool
- func (p SourceRelPath) RelPath() RelPath
- func (p SourceRelPath) Split() (SourceRelPath, SourceRelPath)
- func (p SourceRelPath) String() string
- func (p SourceRelPath) TargetRelPath(encryptedSuffix string) RelPath
- type SourceState
- func (s *SourceState) Add(sourceSystem System, persistentState PersistentState, destSystem System, ...) error
- func (s *SourceState) AddDestAbsPathInfos(destAbsPathInfos map[AbsPath]fs.FileInfo, system System, destAbsPath AbsPath, ...) error
- func (s *SourceState) Apply(targetSystem, destSystem System, persistentState PersistentState, ...) error
- func (s *SourceState) Encryption() Encryption
- func (s *SourceState) ExecuteTemplateData(options ExecuteTemplateDataOptions) ([]byte, error)
- func (s *SourceState) ForEach(f func(RelPath, SourceStateEntry) error) error
- func (s *SourceState) Get(targetRelPath RelPath) SourceStateEntry
- func (s *SourceState) Ignore(targetRelPath RelPath) bool
- func (s *SourceState) Ignored() RelPaths
- func (s *SourceState) MustEntry(targetRelPath RelPath) SourceStateEntry
- func (s *SourceState) PostApply(targetSystem System, targetDirAbsPath AbsPath, targetRelPaths RelPaths) error
- func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error
- func (s *SourceState) TargetRelPaths() []RelPath
- func (s *SourceState) TemplateData() map[string]any
- type SourceStateCommand
- func (s *SourceStateCommand) Evaluate() error
- func (s *SourceStateCommand) MarshalZerologObject(e *zerolog.Event)
- func (s *SourceStateCommand) Order() ScriptOrder
- func (s *SourceStateCommand) Origin() SourceStateOrigin
- func (s *SourceStateCommand) SourceRelPath() SourceRelPath
- func (s *SourceStateCommand) TargetStateEntry(destSystem System, destDirAbsPath AbsPath) (TargetStateEntry, error)
- type SourceStateDir
- func (s *SourceStateDir) Evaluate() error
- func (s *SourceStateDir) MarshalZerologObject(e *zerolog.Event)
- func (s *SourceStateDir) Order() ScriptOrder
- func (s *SourceStateDir) Origin() SourceStateOrigin
- func (s *SourceStateDir) SourceRelPath() SourceRelPath
- func (s *SourceStateDir) TargetStateEntry(destSystem System, destDirAbsPath AbsPath) (TargetStateEntry, error)
- type SourceStateEntry
- type SourceStateFile
- func (lc SourceStateFile) Contents() ([]byte, error)
- func (lc SourceStateFile) ContentsSHA256() ([]byte, error)
- func (s *SourceStateFile) Evaluate() error
- func (s *SourceStateFile) MarshalZerologObject(e *zerolog.Event)
- func (s *SourceStateFile) Order() ScriptOrder
- func (s *SourceStateFile) Origin() SourceStateOrigin
- func (s *SourceStateFile) SourceRelPath() SourceRelPath
- func (s *SourceStateFile) TargetStateEntry(destSystem System, destDirAbsPath AbsPath) (TargetStateEntry, error)
- type SourceStateOption
- func WithBaseSystem(baseSystem System) SourceStateOption
- func WithCacheDir(cacheDirAbsPath AbsPath) SourceStateOption
- func WithDefaultTemplateDataFunc(defaultTemplateDataFunc func() map[string]any) SourceStateOption
- func WithDestDir(destDirAbsPath AbsPath) SourceStateOption
- func WithEncryption(encryption Encryption) SourceStateOption
- func WithHTTPClient(httpClient *http.Client) SourceStateOption
- func WithInterpreters(interpreters map[string]*Interpreter) SourceStateOption
- func WithLogger(logger *zerolog.Logger) SourceStateOption
- func WithMode(mode Mode) SourceStateOption
- func WithPriorityTemplateData(priorityTemplateData map[string]any) SourceStateOption
- func WithReadTemplateData(readTemplateData bool) SourceStateOption
- func WithScriptEnv(scriptEnv []string) SourceStateOption
- func WithSourceDir(sourceDirAbsPath AbsPath) SourceStateOption
- func WithSystem(system System) SourceStateOption
- func WithTemplateDataOnly(templateDataOnly bool) SourceStateOption
- func WithTemplateFuncs(templateFuncs template.FuncMap) SourceStateOption
- func WithTemplateOptions(templateOptions []string) SourceStateOption
- func WithUmask(umask fs.FileMode) SourceStateOption
- func WithVersion(version semver.Version) SourceStateOption
- type SourceStateOrigin
- type SourceStateOriginAbsPath
- type SourceStateOriginRemove
- type SourceStateRemove
- func (s *SourceStateRemove) Evaluate() error
- func (s *SourceStateRemove) MarshalZerologObject(e *zerolog.Event)
- func (s *SourceStateRemove) Order() ScriptOrder
- func (s *SourceStateRemove) Origin() SourceStateOrigin
- func (s *SourceStateRemove) SourceRelPath() SourceRelPath
- func (s *SourceStateRemove) TargetStateEntry(destSystem System, destDirAbsPath AbsPath) (TargetStateEntry, error)
- type System
- type TarWriterSystem
- func (TarWriterSystem) Chmod(name AbsPath, perm fs.FileMode) error
- func (TarWriterSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
- func (s *TarWriterSystem) Close() error
- func (TarWriterSystem) Glob(pattern string) ([]string, error)
- func (TarWriterSystem) Link(oldname, newname AbsPath) error
- func (TarWriterSystem) Lstat(name AbsPath) (fs.FileInfo, error)
- func (s *TarWriterSystem) Mkdir(name AbsPath, perm fs.FileMode) error
- func (TarWriterSystem) RawPath(path AbsPath) (AbsPath, error)
- func (TarWriterSystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
- func (TarWriterSystem) ReadFile(name AbsPath) ([]byte, error)
- func (TarWriterSystem) Readlink(name AbsPath) (string, error)
- func (TarWriterSystem) Remove(name AbsPath) error
- func (TarWriterSystem) RemoveAll(name AbsPath) error
- func (TarWriterSystem) Rename(oldpath, newpath AbsPath) error
- func (s *TarWriterSystem) RunCmd(cmd *exec.Cmd) error
- func (s *TarWriterSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions) error
- func (TarWriterSystem) Stat(name AbsPath) (fs.FileInfo, error)
- func (TarWriterSystem) UnderlyingFS() vfs.FS
- func (s *TarWriterSystem) UnderlyingSystem() System
- func (s *TarWriterSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error
- func (s *TarWriterSystem) WriteSymlink(oldname string, newname AbsPath) error
- type TargetStateDir
- func (t *TargetStateDir) Apply(system System, persistentState PersistentState, ...) (bool, error)
- func (t *TargetStateDir) EntryState(umask fs.FileMode) (*EntryState, error)
- func (t *TargetStateDir) Evaluate() error
- func (t *TargetStateDir) SkipApply(persistentState PersistentState, targetAbsPath AbsPath) (bool, error)
- func (t *TargetStateDir) SourceAttr() SourceAttr
- type TargetStateEntry
- type TargetStateFile
- func (t *TargetStateFile) Apply(system System, persistentState PersistentState, ...) (bool, error)
- func (lc TargetStateFile) Contents() ([]byte, error)
- func (lc TargetStateFile) ContentsSHA256() ([]byte, error)
- func (t *TargetStateFile) EntryState(umask fs.FileMode) (*EntryState, error)
- func (t *TargetStateFile) Evaluate() error
- func (t *TargetStateFile) Perm(umask fs.FileMode) fs.FileMode
- func (t *TargetStateFile) SkipApply(persistentState PersistentState, targetAbsPath AbsPath) (bool, error)
- func (t *TargetStateFile) SourceAttr() SourceAttr
- type TargetStateModifyDirWithCmd
- func (t *TargetStateModifyDirWithCmd) Apply(system System, persistentState PersistentState, ...) (bool, error)
- func (t *TargetStateModifyDirWithCmd) EntryState(umask fs.FileMode) (*EntryState, error)
- func (t *TargetStateModifyDirWithCmd) Evaluate() error
- func (t *TargetStateModifyDirWithCmd) SkipApply(persistentState PersistentState, targetAbsPath AbsPath) (bool, error)
- func (t *TargetStateModifyDirWithCmd) SourceAttr() SourceAttr
- type TargetStateRemove
- func (t *TargetStateRemove) Apply(system System, persistentState PersistentState, ...) (bool, error)
- func (t *TargetStateRemove) EntryState(umask fs.FileMode) (*EntryState, error)
- func (t *TargetStateRemove) Evaluate() error
- func (t *TargetStateRemove) SkipApply(persistentState PersistentState, targetAbsPath AbsPath) (bool, error)
- func (t *TargetStateRemove) SourceAttr() SourceAttr
- type TargetStateScript
- func (t *TargetStateScript) Apply(system System, persistentState PersistentState, ...) (bool, error)
- func (lc TargetStateScript) Contents() ([]byte, error)
- func (lc TargetStateScript) ContentsSHA256() ([]byte, error)
- func (t *TargetStateScript) EntryState(umask fs.FileMode) (*EntryState, error)
- func (t *TargetStateScript) Evaluate() error
- func (t *TargetStateScript) SkipApply(persistentState PersistentState, targetAbsPath AbsPath) (bool, error)
- func (t *TargetStateScript) SourceAttr() SourceAttr
- type TargetStateSymlink
- func (t *TargetStateSymlink) Apply(system System, persistentState PersistentState, ...) (bool, error)
- func (t *TargetStateSymlink) EntryState(umask fs.FileMode) (*EntryState, error)
- func (t *TargetStateSymlink) Evaluate() error
- func (ll TargetStateSymlink) Linkname() (string, error)
- func (ll TargetStateSymlink) LinknameSHA256() ([]byte, error)
- func (t *TargetStateSymlink) SkipApply(persistentState PersistentState, targetAbsPath AbsPath) (bool, error)
- func (t *TargetStateSymlink) SourceAttr() SourceAttr
- type Template
- type TemplateOptions
- type TextConvFunc
- type TooOldError
- type UnknownArchiveFormatError
- type WalkArchiveFunc
- type WalkFunc
- type ZIPWriterSystem
- func (ZIPWriterSystem) Chmod(name AbsPath, perm fs.FileMode) error
- func (ZIPWriterSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
- func (s *ZIPWriterSystem) Close() error
- func (ZIPWriterSystem) Glob(pattern string) ([]string, error)
- func (ZIPWriterSystem) Link(oldname, newname AbsPath) error
- func (ZIPWriterSystem) Lstat(name AbsPath) (fs.FileInfo, error)
- func (s *ZIPWriterSystem) Mkdir(name AbsPath, perm fs.FileMode) error
- func (ZIPWriterSystem) RawPath(path AbsPath) (AbsPath, error)
- func (ZIPWriterSystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
- func (ZIPWriterSystem) ReadFile(name AbsPath) ([]byte, error)
- func (ZIPWriterSystem) Readlink(name AbsPath) (string, error)
- func (ZIPWriterSystem) Remove(name AbsPath) error
- func (ZIPWriterSystem) RemoveAll(name AbsPath) error
- func (ZIPWriterSystem) Rename(oldpath, newpath AbsPath) error
- func (s *ZIPWriterSystem) RunCmd(cmd *exec.Cmd) error
- func (s *ZIPWriterSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions) error
- func (ZIPWriterSystem) Stat(name AbsPath) (fs.FileInfo, error)
- func (ZIPWriterSystem) UnderlyingFS() vfs.FS
- func (s *ZIPWriterSystem) UnderlyingSystem() System
- func (s *ZIPWriterSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error
- func (s *ZIPWriterSystem) WriteSymlink(oldname string, newname AbsPath) error
Constants ¶
const ( Prefix = ".chezmoi" RootName = Prefix + "root" TemplatesDirName = Prefix + "templates" VersionName = Prefix + "version" )
Special file names.
const (
TemplateSuffix = ".tmpl"
)
Prefixes and suffixes.
Variables ¶
var ( DotAbsPath = NewAbsPath(".") EmptyAbsPath = NewAbsPath("") RootAbsPath = NewAbsPath("/") )
var ( // DefaultTemplateOptions are the default template options. DefaultTemplateOptions = []string{"missingkey=error"} // Break indicates that a walk should be stopped. Break = io.EOF // Skip indicates that entry should be skipped. Skip = filepath.SkipDir // Umask is the process's umask. Umask = fs.FileMode(0) )
var ( CutPrefix = strings.CutPrefix CutSuffix = strings.CutSuffix )
var ( // FormatsByName is a map of all FormatsByName by name. FormatsByName = map[string]Format{ "jsonc": FormatJSONC, "json": FormatJSON, "toml": FormatTOML, "yaml": FormatYAML, } // FormatsByExtension is a map of all Formats by extension. FormatsByExtension = map[string]Format{ "jsonc": FormatJSONC, "json": FormatJSON, "toml": FormatTOML, "yaml": FormatYAML, "yml": FormatYAML, } FormatExtensions = sortedKeys(FormatsByExtension) )
var ( // ConfigStateBucket is the bucket for recording the config state. ConfigStateBucket = []byte("configState") // EntryStateBucket is the bucket for recording the entry states. EntryStateBucket = []byte("entryState") // GitRepoExternalStateBucket is the bucket for recording the state of commands // that modify directories. GitRepoExternalStateBucket = []byte("gitRepoExternalState") // ScriptStateBucket is the bucket for recording the state of run once // scripts. ScriptStateBucket = []byte("scriptState") )
var ( DotRelPath = NewRelPath(".") EmptyRelPath = NewRelPath("") )
var FileModeTypeNames = map[fs.FileMode]string{ 0: "file", fs.ModeDir: "dir", fs.ModeSymlink: "symlink", fs.ModeNamedPipe: "named pipe", fs.ModeSocket: "socket", fs.ModeDevice: "device", fs.ModeCharDevice: "char device", }
var ModeFlagCompletionFunc = FlagCompletionFunc([]string{ string(ModeFile), string(ModeSymlink), })
ModeFlagCompletionFunc is a function that completes the value of mode flags.
var ( RefreshExternalsFlagCompletionFunc = FlagCompletionFunc( maps.Keys(refreshExternalsWellKnownStrings), ) )
Functions ¶
func DiffPatch ¶
func DiffPatch( path RelPath, fromData []byte, fromMode fs.FileMode, toData []byte, toMode fs.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 EntryTypeSetFlagCompletionFunc ¶ added in v2.36.1
func EntryTypeSetFlagCompletionFunc( cmd *cobra.Command, args []string, toComplete string, ) ([]string, cobra.ShellCompDirective)
EntryTypeSetFlagCompletionFunc completes EntryTypeSet flags.
func FQDNHostname ¶
FQDNHostname returns the FQDN hostname.
func FlagCompletionFunc ¶ added in v2.36.1
func FlagCompletionFunc(allCompletions []string) func(*cobra.Command, []string, string) ( []string, cobra.ShellCompDirective, )
FlagCompletionFunc returns a flag completion function.
func Glob ¶ added in v2.36.1
Glob is like github.com/bmatcuk/doublestar/v4.Glob except that it does not follow symlinks.
func LookPath ¶ added in v2.36.1
LookPath is like os/exec.LookPath except that the first positive result is cached.
func NewGitHubClient ¶ added in v2.36.1
NewGitHubClient returns a new github.Client configured with an access token and a http client, if available.
func OSRelease ¶
OSRelease returns the operating system identification data as defined by the os-release specification.
func ParseBool ¶ added in v2.36.1
ParseBool is like strconv.ParseBool but also accepts on, ON, y, Y, yes, YES, n, N, no, NO, off, and OFF.
func PersistentStateBucketData ¶ added in v2.9.0
func PersistentStateBucketData(s PersistentState, bucket []byte) (map[string]any, error)
PersistentStateBucketData returns the state data in bucket in s.
func PersistentStateData ¶
PersistentStateData returns the structured data in s.
func PersistentStateGet ¶ added in v2.36.1
func PersistentStateGet(s PersistentState, bucket, key []byte, value any) (bool, error)
PersistentStateGet gets the value associated with key in bucket in s, if it exists.
func PersistentStateSet ¶ added in v2.36.1
func PersistentStateSet(s PersistentState, bucket, key []byte, value any) error
PersistentStateSet sets the value associated with key in bucket in s.
func RecursiveMerge ¶
RecursiveMerge recursively merges maps in source into dest.
func StringSliceToEntryTypeSetHookFunc ¶
func StringSliceToEntryTypeSetHookFunc() mapstructure.DecodeHookFunc
StringSliceToEntryTypeSetHookFunc is a github.com/mitchellh/mapstructure.DecodeHookFunc that parses an EntryTypeSet from a []string.
func StringToAbsPathHookFunc ¶ added in v2.0.11
func StringToAbsPathHookFunc() mapstructure.DecodeHookFunc
StringToAbsPathHookFunc is a github.com/mitchellh/mapstructure.DecodeHookFunc that parses an AbsPath from a string.
func SuspiciousSourceDirEntry ¶
SuspiciousSourceDirEntry returns true if base is a suspicious dir entry.
func UniqueAbbreviations ¶ added in v2.36.1
UniqueAbbreviations returns a map of unique abbreviations of values to values. Values always map to themselves.
func Walk ¶
Walk walks rootAbsPath in system, calling walkFunc for each file or directory in the tree, including rootAbsPath.
Walk does not follow symlinks.
func WalkArchive ¶ added in v2.9.1
func WalkArchive(data []byte, format ArchiveFormat, f WalkArchiveFunc) error
WalkArchive walks over all the entries in an archive.
func WalkSourceDir ¶ added in v2.8.0
WalkSourceDir walks the source directory rooted at sourceDirAbsPath in system, calling walkFunc for each file or directory in the tree, including sourceDirAbsPath.
WalkSourceDir does not follow symbolic links found in directories, but if sourceDirAbsPath itself is a symbolic link, its target will be walked.
Directory entries .chezmoidata.<format> and .chezmoitemplates are visited before all other entries. All other entries are visited in alphabetical order.
Types ¶
type AbsPath ¶
type AbsPath struct {
// contains filtered or unexported fields
}
An AbsPath is an absolute path.
func HomeDirAbsPath ¶ added in v2.7.4
HomeDirAbsPath returns the user's home directory as an AbsPath.
func NewAbsPathFromExtPath ¶
NewAbsPathFromExtPath returns a new AbsPath by converting extPath to use slashes, performing tilde expansion, and making the path absolute.
func NormalizePath ¶
NormalizePath returns path normalized. On non-Windows systems, normalized paths are absolute paths.
func (AbsPath) JoinString ¶ added in v2.7.4
JoinString returns a new AbsPath with ss appended.
func (AbsPath) MarshalText ¶ added in v2.5.1
MarshalText implements encoding.TextMarshaler.MarshalText.
func (AbsPath) MustTrimDirPrefix ¶
MustTrimDirPrefix is like TrimPrefix but panics on any error.
func (AbsPath) TrimDirPrefix ¶
TrimDirPrefix trims prefix from p.
func (AbsPath) TrimSuffix ¶ added in v2.36.1
TrimSuffix returns p with the optional suffix removed.
func (*AbsPath) UnmarshalText ¶ added in v2.5.1
UnmarshalText implements encoding.TextUnmarshaler.UnmarshalText.
type AbsPaths ¶
type AbsPaths []AbsPath
AbsPaths is a slice of RelPaths that implements sort.Interface.
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 s's entry state.
func (*ActualStateAbsent) OriginString ¶ added in v2.36.1
func (s *ActualStateAbsent) OriginString() string
OriginString returns s's origin.
func (*ActualStateAbsent) Remove ¶
func (s *ActualStateAbsent) Remove(system System) error
Remove removes s.
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 s's entry state.
func (*ActualStateDir) OriginString ¶ added in v2.36.1
func (s *ActualStateDir) OriginString() string
OriginString returns s's origin.
func (*ActualStateDir) Remove ¶
func (s *ActualStateDir) Remove(system System) error
Remove removes s.
type ActualStateEntry ¶
type ActualStateEntry interface { EntryState() (*EntryState, error) Path() AbsPath Remove(system System) error OriginString() string }
An ActualStateEntry represents the actual state of an entry in the filesystem.
func NewActualStateEntry ¶
func NewActualStateEntry( system System, absPath AbsPath, fileInfo fs.FileInfo, err error, ) (ActualStateEntry, error)
NewActualStateEntry returns a new ActualStateEntry populated with absPath from system.
type ActualStateFile ¶
type ActualStateFile struct {
// contains filtered or unexported fields
}
A ActualStateFile represents the state of a file in the filesystem.
func (ActualStateFile) ContentsSHA256 ¶
ContentsSHA256 returns the SHA256 sum of lc's contents.
func (*ActualStateFile) EntryState ¶
func (s *ActualStateFile) EntryState() (*EntryState, error)
EntryState returns s's entry state.
func (*ActualStateFile) OriginString ¶ added in v2.36.1
func (s *ActualStateFile) OriginString() string
OriginString returns s's origin.
func (*ActualStateFile) Perm ¶ added in v2.0.13
func (s *ActualStateFile) Perm() fs.FileMode
Perm returns s's perm.
func (*ActualStateFile) Remove ¶
func (s *ActualStateFile) Remove(system System) error
Remove removes s.
type ActualStateSymlink ¶
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 s's entry state.
func (ActualStateSymlink) LinknameSHA256 ¶
LinknameSHA256 returns the SHA256 sum of ll's linkname.
func (*ActualStateSymlink) OriginString ¶ added in v2.36.1
func (s *ActualStateSymlink) OriginString() string
OriginString returns s's origin.
func (*ActualStateSymlink) Path ¶
func (s *ActualStateSymlink) Path() AbsPath
Path returns s's path.
func (*ActualStateSymlink) Remove ¶
func (s *ActualStateSymlink) Remove(system System) error
Remove removes s.
type AddOptions ¶
type AddOptions struct { Create bool // Add create_ entries instead of normal entries. Encrypt bool // Encrypt files. EncryptedSuffix string // Suffix for encrypted files. Exact bool // Add the exact_ attribute to added directories. Filter *EntryTypeFilter // Entry type filter. OnIgnoreFunc func(RelPath) // Function to call when a target is ignored. PreAddFunc PreAddFunc // Function to be called before a source entry is added. ProtectedAbsPaths []AbsPath // Paths that must not be added. RemoveDir RelPath // Directory to remove before adding. ReplaceFunc ReplaceFunc // Function to be called before a source entry is replaced. Template bool // Add the .tmpl attribute to added files. TemplateSymlinks bool // Add symlinks with targets in the source or home directories as templates. }
AddOptions are options to SourceState.Add.
type AgeEncryption ¶ added in v2.4.0
type AgeEncryption struct { UseBuiltin bool `json:"useBuiltin" mapstructure:"useBuiltin" yaml:"useBuiltin"` Command string `json:"command" mapstructure:"command" yaml:"command"` Args []string `json:"args" mapstructure:"args" yaml:"args"` Identity AbsPath `json:"identity" mapstructure:"identity" yaml:"identity"` Identities []AbsPath `json:"identities" mapstructure:"identities" yaml:"identities"` Passphrase bool `json:"passphrase" mapstructure:"passphrase" yaml:"passphrase"` Recipient string `json:"recipient" mapstructure:"recipient" yaml:"recipient"` Recipients []string `json:"recipients" mapstructure:"recipients" yaml:"recipients"` RecipientsFile AbsPath `json:"recipientsFile" mapstructure:"recipientsFile" yaml:"recipientsFile"` RecipientsFiles []AbsPath `json:"recipientsFiles" mapstructure:"recipientsFiles" yaml:"recipientsFiles"` Suffix string `json:"suffix" mapstructure:"suffix" yaml:"suffix"` Symmetric bool `json:"symmetric" mapstructure:"symmetric" yaml:"symmetric"` }
An AgeEncryption uses age for encryption and decryption. See https://age-encryption.org.
func (*AgeEncryption) Decrypt ¶ added in v2.4.0
func (e *AgeEncryption) Decrypt(ciphertext []byte) ([]byte, error)
Decrypt implements Encryption.Decrypt.
func (*AgeEncryption) DecryptToFile ¶ added in v2.4.0
func (e *AgeEncryption) DecryptToFile(plaintextAbsPath AbsPath, ciphertext []byte) error
DecryptToFile implements Encryption.DecryptToFile.
func (*AgeEncryption) Encrypt ¶ added in v2.4.0
func (e *AgeEncryption) Encrypt(plaintext []byte) ([]byte, error)
Encrypt implements Encryption.Encrypt.
func (*AgeEncryption) EncryptFile ¶ added in v2.4.0
func (e *AgeEncryption) EncryptFile(plaintextAbsPath AbsPath) ([]byte, error)
EncryptFile implements Encryption.EncryptFile.
func (*AgeEncryption) EncryptedSuffix ¶ added in v2.4.0
func (e *AgeEncryption) EncryptedSuffix() string
EncryptedSuffix implements Encryption.EncryptedSuffix.
type ApplyOptions ¶
type ApplyOptions struct { Filter *EntryTypeFilter PreApplyFunc PreApplyFunc Umask fs.FileMode }
ApplyOptions are options to SourceState.ApplyAll and SourceState.ApplyOne.
type ArchiveFormat ¶ added in v2.5.0
type ArchiveFormat string
An ArchiveFormat is an archive format and implements the github.com/spf13/pflag.Value interface.
const ( ArchiveFormatUnknown ArchiveFormat = "" ArchiveFormatTar ArchiveFormat = "tar" ArchiveFormatTarBz2 ArchiveFormat = "tar.bz2" ArchiveFormatTarGz ArchiveFormat = "tar.gz" ArchiveFormatTarXz ArchiveFormat = "tar.xz" ArchiveFormatTarZst ArchiveFormat = "tar.zst" ArchiveFormatTbz2 ArchiveFormat = "tbz2" ArchiveFormatTgz ArchiveFormat = "tgz" ArchiveFormatTxz ArchiveFormat = "txz" ArchiveFormatZip ArchiveFormat = "zip" )
Archive formats.
func GuessArchiveFormat ¶ added in v2.5.0
func GuessArchiveFormat(path string, data []byte) ArchiveFormat
GuessArchiveFormat guesses the archive format from the path and data.
func (*ArchiveFormat) Set ¶ added in v2.5.0
func (f *ArchiveFormat) Set(s string) error
Set implements github.com/spf13/pflag.Value.Set.
func (ArchiveFormat) String ¶ added in v2.5.0
func (f ArchiveFormat) String() string
String implements github.com/spf13/pflag.Value.String.
func (ArchiveFormat) Type ¶ added in v2.5.0
func (f ArchiveFormat) Type() string
Type implements github.com/spf13/pflag.Value.Type.
type ArchiveReaderSystem ¶ added in v2.3.0
type ArchiveReaderSystem struct {
// contains filtered or unexported fields
}
A ArchiveReaderSystem a system constructed from reading an archive.
func NewArchiveReaderSystem ¶ added in v2.3.0
func NewArchiveReaderSystem( archivePath string, data []byte, format ArchiveFormat, options ArchiveReaderSystemOptions, ) (*ArchiveReaderSystem, error)
NewArchiveReaderSystem returns a new ArchiveReaderSystem reading from data and using archivePath as a hint for the archive format.
func (*ArchiveReaderSystem) FileInfos ¶ added in v2.3.0
func (s *ArchiveReaderSystem) FileInfos() map[AbsPath]fs.FileInfo
FileInfos returns s's fs.FileInfos.
func (*ArchiveReaderSystem) Lstat ¶ added in v2.3.0
func (s *ArchiveReaderSystem) Lstat(filename AbsPath) (fs.FileInfo, error)
Lstat implements System.Lstat.
func (*ArchiveReaderSystem) ReadFile ¶ added in v2.3.0
func (s *ArchiveReaderSystem) ReadFile(name AbsPath) ([]byte, error)
ReadFile implements System.ReadFile.
func (*ArchiveReaderSystem) Readlink ¶ added in v2.3.0
func (s *ArchiveReaderSystem) Readlink(name AbsPath) (string, error)
Readlink implements System.Readlink.
func (ArchiveReaderSystem) RunScript ¶ added in v2.3.0
func (ArchiveReaderSystem) RunScript( scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions, ) error
func (ArchiveReaderSystem) UnderlyingFS ¶ added in v2.3.0
func (*ArchiveReaderSystem) UnderlyingSystem ¶ added in v2.36.1
func (s *ArchiveReaderSystem) UnderlyingSystem() System
UnderlyingSystem implements System.UnderlyingSystem.
func (ArchiveReaderSystem) WriteSymlink ¶ added in v2.3.0
type ArchiveReaderSystemOptions ¶ added in v2.3.0
ArchiveReaderSystemOptions are options to NewArchiveReaderSystem.
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) CopyTo ¶
func (b *BoltPersistentState) CopyTo(p PersistentState) error
CopyTo copies b to p.
func (*BoltPersistentState) Data ¶
func (b *BoltPersistentState) Data() (any, error)
Data returns all the data in b.
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) DeleteBucket ¶ added in v2.9.0
func (b *BoltPersistentState) DeleteBucket(bucket []byte) error
DeleteBucket deletes the bucket.
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 )
Persistent state modes.
type DebugEncryption ¶
type DebugEncryption struct {
// contains filtered or unexported fields
}
A DebugEncryption logs all calls to an Encryption.
func NewDebugEncryption ¶
func NewDebugEncryption(encryption Encryption, logger *zerolog.Logger) *DebugEncryption
NewDebugEncryption returns a new DebugEncryption that logs methods on encryption to logger.
func (*DebugEncryption) Decrypt ¶
func (e *DebugEncryption) Decrypt(ciphertext []byte) ([]byte, error)
Decrypt implements Encryption.Decrypt.
func (*DebugEncryption) DecryptToFile ¶
func (e *DebugEncryption) DecryptToFile(plaintextAbsPath AbsPath, 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(plaintextAbsPath AbsPath) ([]byte, error)
EncryptFile implements Encryption.EncryptFile.
func (*DebugEncryption) EncryptedSuffix ¶
func (e *DebugEncryption) EncryptedSuffix() string
EncryptedSuffix implements Encryption.EncryptedSuffix.
type DebugPersistentState ¶
type DebugPersistentState struct {
// contains filtered or unexported fields
}
A DebugPersistentState logs calls to a PersistentState.
func NewDebugPersistentState ¶
func NewDebugPersistentState( persistentState PersistentState, logger *zerolog.Logger, ) *DebugPersistentState
NewDebugPersistentState returns a new debugPersistentState that logs methods on persistentState to logger.
func (*DebugPersistentState) Close ¶
func (s *DebugPersistentState) Close() error
Close implements PersistentState.Close.
func (*DebugPersistentState) CopyTo ¶
func (s *DebugPersistentState) CopyTo(p PersistentState) error
CopyTo implements PersistentState.CopyTo.
func (*DebugPersistentState) Data ¶
func (s *DebugPersistentState) Data() (any, error)
Data implements PersistentState.Data.
func (*DebugPersistentState) Delete ¶
func (s *DebugPersistentState) Delete(bucket, key []byte) error
Delete implements PersistentState.Delete.
func (*DebugPersistentState) DeleteBucket ¶ added in v2.9.0
func (s *DebugPersistentState) DeleteBucket(bucket []byte) error
DeleteBucket implements PersistentState.DeleteBucket.
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, logger *zerolog.Logger) *DebugSystem
NewDebugSystem returns a new DebugSystem that logs methods on system to logger.
func (*DebugSystem) Chmod ¶
func (s *DebugSystem) Chmod(name AbsPath, mode fs.FileMode) error
Chmod implements System.Chmod.
func (*DebugSystem) Chtimes ¶ added in v2.36.1
func (s *DebugSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
Chtimes implements System.Chtimes.
func (*DebugSystem) Glob ¶
func (s *DebugSystem) Glob(name string) ([]string, error)
Glob implements System.Glob.
func (*DebugSystem) Link ¶ added in v2.6.0
func (s *DebugSystem) Link(oldpath, newpath AbsPath) error
Link implements System.Link.
func (*DebugSystem) Lstat ¶
func (s *DebugSystem) Lstat(name AbsPath) (fs.FileInfo, error)
Lstat implements System.Lstat.
func (*DebugSystem) Mkdir ¶
func (s *DebugSystem) Mkdir(name AbsPath, perm fs.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) ([]fs.DirEntry, error)
ReadDir implements System.ReadDir.
func (*DebugSystem) ReadFile ¶
func (s *DebugSystem) ReadFile(name AbsPath) ([]byte, error)
ReadFile implements System.ReadFile.
func (*DebugSystem) Readlink ¶
func (s *DebugSystem) Readlink(name AbsPath) (string, error)
Readlink implements System.Readlink.
func (*DebugSystem) Remove ¶ added in v2.36.1
func (s *DebugSystem) Remove(name AbsPath) error
Remove implements System.Remove.
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, options RunScriptOptions, ) error
RunScript implements System.RunScript.
func (*DebugSystem) Stat ¶
func (s *DebugSystem) Stat(name AbsPath) (fs.FileInfo, error)
Stat implements System.Stat.
func (*DebugSystem) UnderlyingFS ¶
func (s *DebugSystem) UnderlyingFS() vfs.FS
UnderlyingFS implements System.UnderlyingFS.
func (*DebugSystem) UnderlyingSystem ¶ added in v2.36.1
func (s *DebugSystem) UnderlyingSystem() System
UnderlyingSystem implements System.UnderlyingSystem.
func (*DebugSystem) WriteSymlink ¶
func (s *DebugSystem) WriteSymlink(oldname string, newname AbsPath) error
WriteSymlink implements System.WriteSymlink.
type DirAttr ¶
type DirAttr struct { TargetName string Type SourceDirTargetType Exact bool External bool Private bool ReadOnly bool }
DirAttr holds attributes parsed from a source directory name.
func (DirAttr) MarshalZerologObject ¶ added in v2.5.0
MarshalZerologObject implements github.com/rs/zerolog.ObjectMarshaler.MarshalZerologObject.
func (DirAttr) SourceName ¶
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 fs.FileMode) error
Chmod implements System.Chmod.
func (*DryRunSystem) Chtimes ¶ added in v2.36.1
func (s *DryRunSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
Chtimes implements System.Chtimes.
func (*DryRunSystem) Glob ¶
func (s *DryRunSystem) Glob(pattern string) ([]string, error)
Glob implements System.Glob.
func (*DryRunSystem) Link ¶ added in v2.6.0
func (s *DryRunSystem) Link(oldname, newname AbsPath) error
Link implements System.Link.
func (*DryRunSystem) Lstat ¶
func (s *DryRunSystem) Lstat(name AbsPath) (fs.FileInfo, error)
Lstat implements System.Lstat.
func (*DryRunSystem) Mkdir ¶
func (s *DryRunSystem) Mkdir(name AbsPath, perm fs.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(name AbsPath) ([]fs.DirEntry, error)
ReadDir implements System.ReadDir.
func (*DryRunSystem) ReadFile ¶
func (s *DryRunSystem) ReadFile(name AbsPath) ([]byte, error)
ReadFile implements System.ReadFile.
func (*DryRunSystem) Readlink ¶
func (s *DryRunSystem) Readlink(name AbsPath) (string, error)
Readlink implements System.Readlink.
func (*DryRunSystem) Remove ¶ added in v2.36.1
func (s *DryRunSystem) Remove(AbsPath) error
Remove implements System.Remove.
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, options RunScriptOptions, ) error
RunScript implements System.RunScript.
func (*DryRunSystem) Stat ¶
func (s *DryRunSystem) Stat(name AbsPath) (fs.FileInfo, error)
Stat implements System.Stat.
func (*DryRunSystem) UnderlyingFS ¶
func (s *DryRunSystem) UnderlyingFS() vfs.FS
UnderlyingFS implements System.UnderlyingFS.
func (*DryRunSystem) UnderlyingSystem ¶ added in v2.36.1
func (s *DryRunSystem) UnderlyingSystem() System
UnderlyingSystem implements System.UnderlyingSystem.
func (*DryRunSystem) WriteSymlink ¶
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) Mkdir ¶
func (s *DumpSystem) Mkdir(dirname AbsPath, perm fs.FileMode) error
Mkdir implements System.Mkdir.
func (*DumpSystem) RunCmd ¶
func (s *DumpSystem) RunCmd(cmd *exec.Cmd) error
RunCmd implements System.RunCmd.
func (*DumpSystem) RunScript ¶
func (s *DumpSystem) RunScript( scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions, ) error
RunScript implements System.RunScript.
func (*DumpSystem) UnderlyingFS ¶
func (s *DumpSystem) UnderlyingFS() vfs.FS
UnderlyingFS implements System.UnderlyingFS.
func (*DumpSystem) UnderlyingSystem ¶ added in v2.36.1
func (s *DumpSystem) UnderlyingSystem() System
UnderlyingSystem implements System.UnderlyingSystem.
func (*DumpSystem) WriteSymlink ¶
func (s *DumpSystem) WriteSymlink(oldname string, newname AbsPath) error
WriteSymlink implements System.WriteSymlink.
type Duration ¶ added in v2.36.1
A Duration is a time.Duration that implements encoding.TextUnmarshaler.
func (*Duration) UnmarshalText ¶ added in v2.36.1
type Encryption ¶
type Encryption interface { Decrypt(ciphertext []byte) ([]byte, error) DecryptToFile(plaintextFilename AbsPath, ciphertext []byte) error Encrypt(plaintext []byte) ([]byte, error) EncryptFile(plaintextFilename AbsPath) ([]byte, error) EncryptedSuffix() string }
An Encryption encrypts and decrypts files and data.
type EntryState ¶
type EntryState struct { Type EntryStateType `json:"type" yaml:"type"` Mode fs.FileMode `json:"mode,omitempty" yaml:"mode,omitempty"` ContentsSHA256 HexBytes `json:"contentsSHA256,omitempty" yaml:"contentsSHA256,omitempty"` //nolint:tagliatelle // 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.
func (*EntryState) MarshalZerologObject ¶ added in v2.3.0
func (s *EntryState) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements github.com/rs/zerolog.LogObjectMarshaler.MarshalZerologObject.
func (*EntryState) Overwrite ¶ added in v2.1.2
func (s *EntryState) Overwrite() bool
Overwrite returns true if s should be overwritten by default.
type EntryStateType ¶
type EntryStateType string
An EntryStateType is an entry state type.
const ( EntryStateTypeDir EntryStateType = "dir" EntryStateTypeFile EntryStateType = "file" EntryStateTypeSymlink EntryStateType = "symlink" EntryStateTypeRemove EntryStateType = "remove" EntryStateTypeScript EntryStateType = "script" )
Entry state types.
type EntryTypeBits ¶
type EntryTypeBits int
An EntryTypeBits is a bitmask of entry types.
const ( EntryTypeDirs EntryTypeBits = 1 << iota EntryTypeFiles EntryTypeRemove EntryTypeScripts EntryTypeSymlinks EntryTypeEncrypted EntryTypeExternals EntryTypeTemplates EntryTypeAlways // EntryTypesAll is all entry types. EntryTypesAll EntryTypeBits = EntryTypeDirs | EntryTypeFiles | EntryTypeRemove | EntryTypeScripts | EntryTypeSymlinks | EntryTypeEncrypted | EntryTypeExternals | EntryTypeTemplates | EntryTypeAlways // EntryTypesNone is no entry types. EntryTypesNone EntryTypeBits = 0 )
Entry type bits.
type EntryTypeFilter ¶ added in v2.36.1
type EntryTypeFilter struct { Include *EntryTypeSet Exclude *EntryTypeSet }
An EntryTypeFilter filters entries by type and source attributes. Any entry in the include set is included, otherwise if the entry is in the exclude set then it is excluded, otherwise it is included.
func NewEntryTypeFilter ¶ added in v2.36.1
func NewEntryTypeFilter(includeEntryTypeBits, excludeEntryTypeBits EntryTypeBits) *EntryTypeFilter
NewEntryTypeFilter returns a new EntryTypeFilter with the given entry type bits.
func (*EntryTypeFilter) IncludeEntryTypeBits ¶ added in v2.36.1
func (f *EntryTypeFilter) IncludeEntryTypeBits(entryTypeBits EntryTypeBits) bool
IncludeEntryTypeBits returns if entryTypeBits is included.
func (*EntryTypeFilter) IncludeFileInfo ¶ added in v2.36.1
func (f *EntryTypeFilter) IncludeFileInfo(fileInfo fs.FileInfo) bool
IncludeFileInfo returns if fileInfo is included.
func (*EntryTypeFilter) IncludeSourceStateEntry ¶ added in v2.36.1
func (f *EntryTypeFilter) IncludeSourceStateEntry(sourceStateEntry SourceStateEntry) bool
IncludeSourceStateEntry returns if sourceStateEntry is included.
func (*EntryTypeFilter) IncludeTargetStateEntry ¶ added in v2.36.1
func (f *EntryTypeFilter) IncludeTargetStateEntry(targetStateEntry TargetStateEntry) bool
IncludeTargetStateEntry returns if targetStateEntry is included.
type EntryTypeSet ¶
type EntryTypeSet struct {
// contains filtered or unexported fields
}
An EntryTypeSet is a set of entry types. It parses and prints as a comma-separated list of strings, but is internally represented as a bitmask. *EntryTypeSet implements the github.com/spf13/pflag.Value interface.
func NewEntryTypeSet ¶
func NewEntryTypeSet(bits EntryTypeBits) *EntryTypeSet
NewEntryTypeSet returns a new IncludeSet.
func (*EntryTypeSet) Bits ¶ added in v2.36.1
func (s *EntryTypeSet) Bits() EntryTypeBits
Bits returns s's bits.
func (*EntryTypeSet) ContainsEntryTypeBits ¶ added in v2.36.1
func (s *EntryTypeSet) ContainsEntryTypeBits(b EntryTypeBits) bool
ContainsEntryTypeBits returns if s includes b.
func (*EntryTypeSet) ContainsFileInfo ¶ added in v2.36.1
func (s *EntryTypeSet) ContainsFileInfo(fileInfo fs.FileInfo) bool
ContainsFileInfo returns true if fileInfo is a member.
func (*EntryTypeSet) ContainsSourceStateEntry ¶ added in v2.36.1
func (s *EntryTypeSet) ContainsSourceStateEntry(sourceStateEntry SourceStateEntry) bool
ContainsSourceStateEntry returns true if sourceStateEntry is a member.
func (*EntryTypeSet) ContainsTargetStateEntry ¶ added in v2.36.1
func (s *EntryTypeSet) ContainsTargetStateEntry(targetStateEntry TargetStateEntry) bool
ContainsTargetStateEntry returns true if targetStateEntry is a member.
func (*EntryTypeSet) MarshalJSON ¶ added in v2.36.1
func (s *EntryTypeSet) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.MarshalJSON.
func (*EntryTypeSet) MarshalYAML ¶ added in v2.36.1
func (s *EntryTypeSet) MarshalYAML() (any, error)
MarshalYAML implements gopkg.in/yaml.v3.Marshaler.
func (*EntryTypeSet) Set ¶
func (s *EntryTypeSet) Set(str string) error
Set implements github.com/spf13/pflag.Value.Set.
func (*EntryTypeSet) SetSlice ¶
func (s *EntryTypeSet) SetSlice(ss []string) error
SetSlice sets s from a []string.
func (*EntryTypeSet) String ¶
func (s *EntryTypeSet) String() string
String implements github.com/spf13/pflag.Value.String.
func (*EntryTypeSet) Type ¶
func (s *EntryTypeSet) Type() string
Type implements github.com/spf13/pflag.Value.Type.
type ErrorOnWriteSystem ¶ added in v2.9.5
type ErrorOnWriteSystem struct {
// contains filtered or unexported fields
}
An ErrorOnWriteSystem is an System that passes reads to the wrapped System and returns an error if it is written to.
func NewErrorOnWriteSystem ¶ added in v2.9.5
func NewErrorOnWriteSystem(system System, err error) *ErrorOnWriteSystem
NewErrorOnWriteSystem returns a new ErrorOnWriteSystem that wraps fs and returns err on any write operation.
func (*ErrorOnWriteSystem) Chmod ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) Chmod(name AbsPath, mode fs.FileMode) error
Chmod implements System.Chmod.
func (*ErrorOnWriteSystem) Chtimes ¶ added in v2.36.1
func (s *ErrorOnWriteSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
Chtimes implements System.Chtimes.
func (*ErrorOnWriteSystem) Glob ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) Glob(pattern string) ([]string, error)
Glob implements System.Glob.
func (*ErrorOnWriteSystem) Link ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) Link(oldname, newname AbsPath) error
Link implements System.Link.
func (*ErrorOnWriteSystem) Lstat ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) Lstat(name AbsPath) (fs.FileInfo, error)
Lstat implements System.Lstat.
func (*ErrorOnWriteSystem) Mkdir ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) Mkdir(name AbsPath, perm fs.FileMode) error
Mkdir implements System.Mkdir.
func (*ErrorOnWriteSystem) RawPath ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) RawPath(path AbsPath) (AbsPath, error)
RawPath implements System.RawPath.
func (*ErrorOnWriteSystem) ReadDir ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
ReadDir implements System.ReadDir.
func (*ErrorOnWriteSystem) ReadFile ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) ReadFile(name AbsPath) ([]byte, error)
ReadFile implements System.ReadFile.
func (*ErrorOnWriteSystem) Readlink ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) Readlink(name AbsPath) (string, error)
Readlink implements System.Readlink.
func (*ErrorOnWriteSystem) Remove ¶ added in v2.36.1
func (s *ErrorOnWriteSystem) Remove(AbsPath) error
Remove implements System.Remove.
func (*ErrorOnWriteSystem) RemoveAll ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) RemoveAll(AbsPath) error
RemoveAll implements System.RemoveAll.
func (*ErrorOnWriteSystem) Rename ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) Rename(oldpath, newpath AbsPath) error
Rename implements System.Rename.
func (*ErrorOnWriteSystem) RunCmd ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) RunCmd(cmd *exec.Cmd) error
RunCmd implements System.RunCmd.
func (*ErrorOnWriteSystem) RunScript ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) RunScript( scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions, ) error
RunScript implements System.RunScript.
func (*ErrorOnWriteSystem) Stat ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) Stat(name AbsPath) (fs.FileInfo, error)
Stat implements System.Stat.
func (*ErrorOnWriteSystem) UnderlyingFS ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) UnderlyingFS() vfs.FS
UnderlyingFS implements System.UnderlyingFS.
func (*ErrorOnWriteSystem) UnderlyingSystem ¶ added in v2.36.1
func (s *ErrorOnWriteSystem) UnderlyingSystem() System
UnderlyingSystem implements System.UnderlyingSystem.
func (*ErrorOnWriteSystem) WriteSymlink ¶ added in v2.9.5
func (s *ErrorOnWriteSystem) WriteSymlink(string, AbsPath) error
WriteSymlink implements System.WriteSymlink.
type ExecuteTemplateDataOptions ¶ added in v2.36.1
type ExecuteTemplateDataOptions struct { Name string Data []byte TemplateOptions TemplateOptions }
ExecuteTemplateDataOptions are options to SourceState.ExecuteTemplateData.
type ExitCodeError ¶ added in v2.9.4
type ExitCodeError int
An ExitCodeError indicates the main program should exit with the given code.
func (ExitCodeError) Error ¶ added in v2.9.4
func (e ExitCodeError) Error() string
type External ¶ added in v2.2.0
type External struct { Type ExternalType `json:"type" toml:"type" yaml:"type"` Encrypted bool `json:"encrypted" toml:"encrypted" yaml:"encrypted"` Exact bool `json:"exact" toml:"exact" yaml:"exact"` Executable bool `json:"executable" toml:"executable" yaml:"executable"` Checksum struct { MD5 HexBytes `json:"md5" toml:"md5" yaml:"md5"` RIPEMD160 HexBytes `json:"ripemd160" toml:"ripemd160" yaml:"ripemd160"` SHA1 HexBytes `json:"sha1" toml:"sha1" yaml:"sha1"` SHA256 HexBytes `json:"sha256" toml:"sha256" yaml:"sha256"` SHA384 HexBytes `json:"sha384" toml:"sha384" yaml:"sha384"` SHA512 HexBytes `json:"sha512" toml:"sha512" yaml:"sha512"` Size int `json:"size" toml:"size" yaml:"size"` } `json:"checksum" toml:"checksum" yaml:"checksum"` Clone struct { Args []string `json:"args" toml:"args" yaml:"args"` } `json:"clone" toml:"clone" yaml:"clone"` Exclude []string `json:"exclude" toml:"exclude" yaml:"exclude"` Filter struct { Command string `json:"command" toml:"command" yaml:"command"` Args []string `json:"args" toml:"args" yaml:"args"` } `json:"filter" toml:"filter" yaml:"filter"` Format ArchiveFormat `json:"format" toml:"format" yaml:"format"` Include []string `json:"include" toml:"include" yaml:"include"` ArchivePath string `json:"path" toml:"path" yaml:"path"` Pull struct { Args []string `json:"args" toml:"args" yaml:"args"` } `json:"pull" toml:"pull" yaml:"pull"` RefreshPeriod Duration `json:"refreshPeriod" toml:"refreshPeriod" yaml:"refreshPeriod"` StripComponents int `json:"stripComponents" toml:"stripComponents" yaml:"stripComponents"` URL string `json:"url" toml:"url" yaml:"url"` // contains filtered or unexported fields }
An External is an external source.
func (*External) OriginString ¶ added in v2.36.1
type ExternalDiffSystem ¶ added in v2.1.5
type ExternalDiffSystem struct {
// contains filtered or unexported fields
}
An ExternalDiffSystem is a DiffSystem that uses an external diff tool.
func NewExternalDiffSystem ¶ added in v2.1.5
func NewExternalDiffSystem( system System, command string, args []string, destDirAbsPath AbsPath, options *ExternalDiffSystemOptions, ) *ExternalDiffSystem
NewExternalDiffSystem creates a new ExternalDiffSystem.
func (*ExternalDiffSystem) Chmod ¶ added in v2.1.5
func (s *ExternalDiffSystem) Chmod(name AbsPath, mode fs.FileMode) error
Chmod implements System.Chmod.
func (*ExternalDiffSystem) Chtimes ¶ added in v2.36.1
func (s *ExternalDiffSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
Chtimes implements System.Chtimes.
func (*ExternalDiffSystem) Close ¶ added in v2.1.5
func (s *ExternalDiffSystem) Close() error
Close frees all resources held by s.
func (*ExternalDiffSystem) Glob ¶ added in v2.1.5
func (s *ExternalDiffSystem) Glob(pattern string) ([]string, error)
Glob implements System.Glob.
func (*ExternalDiffSystem) Link ¶ added in v2.6.0
func (s *ExternalDiffSystem) Link(oldname, newname AbsPath) error
Link implements System.Link.
func (*ExternalDiffSystem) Lstat ¶ added in v2.1.5
func (s *ExternalDiffSystem) Lstat(name AbsPath) (fs.FileInfo, error)
Lstat implements System.Lstat.
func (*ExternalDiffSystem) Mkdir ¶ added in v2.1.5
func (s *ExternalDiffSystem) Mkdir(name AbsPath, perm fs.FileMode) error
Mkdir implements System.Mkdir.
func (*ExternalDiffSystem) RawPath ¶ added in v2.1.5
func (s *ExternalDiffSystem) RawPath(path AbsPath) (AbsPath, error)
RawPath implements System.RawPath.
func (*ExternalDiffSystem) ReadDir ¶ added in v2.1.5
func (s *ExternalDiffSystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
ReadDir implements System.ReadDir.
func (*ExternalDiffSystem) ReadFile ¶ added in v2.1.5
func (s *ExternalDiffSystem) ReadFile(name AbsPath) ([]byte, error)
ReadFile implements System.ReadFile.
func (*ExternalDiffSystem) Readlink ¶ added in v2.1.5
func (s *ExternalDiffSystem) Readlink(name AbsPath) (string, error)
Readlink implements System.Readlink.
func (*ExternalDiffSystem) Remove ¶ added in v2.36.1
func (s *ExternalDiffSystem) Remove(name AbsPath) error
Remove implements System.Remove.
func (*ExternalDiffSystem) RemoveAll ¶ added in v2.1.5
func (s *ExternalDiffSystem) RemoveAll(name AbsPath) error
RemoveAll implements System.RemoveAll.
func (*ExternalDiffSystem) Rename ¶ added in v2.1.5
func (s *ExternalDiffSystem) Rename(oldpath, newpath AbsPath) error
Rename implements System.Rename.
func (*ExternalDiffSystem) RunCmd ¶ added in v2.1.5
func (s *ExternalDiffSystem) RunCmd(cmd *exec.Cmd) error
RunCmd implements System.RunCmd.
func (*ExternalDiffSystem) RunScript ¶ added in v2.1.5
func (s *ExternalDiffSystem) RunScript( scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions, ) error
RunScript implements System.RunScript.
func (*ExternalDiffSystem) Stat ¶ added in v2.1.5
func (s *ExternalDiffSystem) Stat(name AbsPath) (fs.FileInfo, error)
Stat implements System.Stat.
func (*ExternalDiffSystem) UnderlyingFS ¶ added in v2.1.5
func (s *ExternalDiffSystem) UnderlyingFS() vfs.FS
UnderlyingFS implements System.UnderlyingFS.
func (*ExternalDiffSystem) UnderlyingSystem ¶ added in v2.36.1
func (s *ExternalDiffSystem) UnderlyingSystem() System
UnderlyingSystem implements System.UnderlyingSystem.
func (*ExternalDiffSystem) WriteSymlink ¶ added in v2.1.5
func (s *ExternalDiffSystem) WriteSymlink(oldname string, newname AbsPath) error
WriteSymlink implements System.WriteSymlink.
type ExternalDiffSystemOptions ¶ added in v2.8.0
type ExternalDiffSystemOptions struct { Filter *EntryTypeFilter Reverse bool ScriptContents bool }
ExternalDiffSystemOptions are options for NewExternalDiffSystem.
type ExternalType ¶ added in v2.2.0
type ExternalType string
An ExternalType is a type of external source.
const ( ExternalTypeArchive ExternalType = "archive" ExternalTypeArchiveFile ExternalType = "archive-file" ExternalTypeFile ExternalType = "file" ExternalTypeGitRepo ExternalType = "git-repo" )
ExternalTypes.
type FileAttr ¶
type FileAttr struct { TargetName string Type SourceFileTargetType Condition ScriptCondition Empty bool Encrypted bool Executable bool Order ScriptOrder Private bool ReadOnly bool Template bool }
A FileAttr holds attributes parsed from a source file name.
func (FileAttr) MarshalZerologObject ¶ added in v2.5.0
MarshalZerologObject implements github.com/rs/zerolog.LogObjectMarshaler.MarshalZerologObject.
func (FileAttr) SourceName ¶
SourceName returns fa's source name.
type Format ¶
type Format interface { Marshal(value any) ([]byte, error) Name() string Unmarshal(data []byte, value any) error }
A Format is a serialization format.
var ( FormatJSON Format = formatJSON{} FormatJSONC Format = formatJSONC{} FormatTOML Format = formatTOML{} FormatYAML Format = formatYAML{} )
Formats.
func FormatFromAbsPath ¶ added in v2.36.1
FormatFromAbsPath returns the expected format of absPath.
type GPGEncryption ¶
type GPGEncryption struct { Command string `json:"command" mapstructure:"command" yaml:"command"` Args []string `json:"args" mapstructure:"args" yaml:"args"` Recipient string `json:"recipient" mapstructure:"recipient" yaml:"recipient"` Recipients []string `json:"recipients" mapstructure:"recipients" yaml:"recipients"` Symmetric bool `json:"symmetric" mapstructure:"symmetric" yaml:"symmetric"` Suffix string `json:"suffix" mapstructure:"suffix" yaml:"suffix"` }
A GPGEncryption uses gpg for encryption and decryption. See https://gnupg.org/.
func (*GPGEncryption) Decrypt ¶
func (e *GPGEncryption) Decrypt(ciphertext []byte) ([]byte, error)
Decrypt implements Encryption.Decrypt.
func (*GPGEncryption) DecryptToFile ¶
func (e *GPGEncryption) DecryptToFile(plaintextFilename AbsPath, ciphertext []byte) error
DecryptToFile implements Encryption.DecryptToFile.
func (*GPGEncryption) Encrypt ¶
func (e *GPGEncryption) Encrypt(plaintext []byte) ([]byte, error)
Encrypt implements Encryption.Encrypt.
func (*GPGEncryption) EncryptFile ¶
func (e *GPGEncryption) EncryptFile(plaintextFilename AbsPath) ([]byte, error)
EncryptFile implements Encryption.EncryptFile.
func (*GPGEncryption) EncryptedSuffix ¶
func (e *GPGEncryption) EncryptedSuffix() string
EncryptedSuffix implements Encryption.EncryptedSuffix.
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, options *GitDiffSystemOptions, ) *GitDiffSystem
NewGitDiffSystem returns a new GitDiffSystem. Output is written to w, the dirAbsPath is stripped from paths, and color controls whether the output contains ANSI color escape sequences.
func (*GitDiffSystem) Chmod ¶
func (s *GitDiffSystem) Chmod(name AbsPath, mode fs.FileMode) error
Chmod implements System.Chmod.
func (*GitDiffSystem) Chtimes ¶ added in v2.36.1
func (s *GitDiffSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
Chtimes implements system.Chtimes.
func (*GitDiffSystem) Glob ¶
func (s *GitDiffSystem) Glob(pattern string) ([]string, error)
Glob implements System.Glob.
func (*GitDiffSystem) Link ¶ added in v2.6.0
func (s *GitDiffSystem) Link(oldname, newname AbsPath) error
Link implements System.Link.
func (*GitDiffSystem) Lstat ¶
func (s *GitDiffSystem) Lstat(name AbsPath) (fs.FileInfo, error)
Lstat implements System.Lstat.
func (*GitDiffSystem) Mkdir ¶
func (s *GitDiffSystem) Mkdir(name AbsPath, perm fs.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(name AbsPath) ([]fs.DirEntry, error)
ReadDir implements System.ReadDir.
func (*GitDiffSystem) ReadFile ¶
func (s *GitDiffSystem) ReadFile(name AbsPath) ([]byte, error)
ReadFile implements System.ReadFile.
func (*GitDiffSystem) Readlink ¶
func (s *GitDiffSystem) Readlink(name AbsPath) (string, error)
Readlink implements System.Readlink.
func (*GitDiffSystem) Remove ¶ added in v2.36.1
func (s *GitDiffSystem) Remove(name AbsPath) error
Remove implements System.Remove.
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, options RunScriptOptions, ) error
RunScript implements System.RunScript.
func (*GitDiffSystem) Stat ¶
func (s *GitDiffSystem) Stat(name AbsPath) (fs.FileInfo, error)
Stat implements System.Stat.
func (*GitDiffSystem) UnderlyingFS ¶
func (s *GitDiffSystem) UnderlyingFS() vfs.FS
UnderlyingFS implements System.UnderlyingFS.
func (*GitDiffSystem) UnderlyingSystem ¶ added in v2.36.1
func (s *GitDiffSystem) UnderlyingSystem() System
UnderlyingSystem implements System.UnderlyingSystem.
func (*GitDiffSystem) WriteSymlink ¶
func (s *GitDiffSystem) WriteSymlink(oldname string, newname AbsPath) error
WriteSymlink implements System.WriteSymlink.
type GitDiffSystemOptions ¶ added in v2.8.0
type GitDiffSystemOptions struct { Color bool Filter *EntryTypeFilter Reverse bool ScriptContents bool TextConvFunc TextConvFunc }
GitDiffSystemOptions are options for NewGitDiffSystem.
type HexBytes ¶
type HexBytes []byte
A HexBytes is a []byte which is marshaled as a hex string.
func (HexBytes) MarshalText ¶
MarshalText implements encoding.TextMarshaler.MarshalText.
func (*HexBytes) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.UnmarshalText.
type Interpreter ¶ added in v2.0.14
type Interpreter struct { Command string `mapstructure:"command"` Args []string `mapstructure:"args"` }
An Interpreter interprets scripts.
func (*Interpreter) ExecCommand ¶ added in v2.0.14
func (i *Interpreter) ExecCommand(name string) *exec.Cmd
ExecCommand returns the *exec.Cmd to interpret name.
func (*Interpreter) MarshalZerologObject ¶ added in v2.0.14
func (i *Interpreter) MarshalZerologObject(event *zerolog.Event)
MarshalZerologObject implements github.com/rs/zerolog.LogObjectMarshaler.MarshalZerologObject.
func (*Interpreter) None ¶ added in v2.0.14
func (i *Interpreter) None() bool
None returns if i represents no interpreter.
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) CopyTo ¶
func (s *MockPersistentState) CopyTo(p PersistentState) error
CopyTo implements PersistentState.CopyTo.
func (*MockPersistentState) Data ¶
func (s *MockPersistentState) Data() (any, error)
Data implements PersistentState.Data.
func (*MockPersistentState) Delete ¶
func (s *MockPersistentState) Delete(bucket, key []byte) error
Delete implements PersistentState.Delete.
func (*MockPersistentState) DeleteBucket ¶ added in v2.9.0
func (s *MockPersistentState) DeleteBucket(bucket []byte) error
DeleteBucket implements PersistentState.DeleteBucket.
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 Mode ¶ added in v2.1.5
type Mode string
A Mode is a mode of operation. It implements the github.com/spf13/flag.Value interface.
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(AbsPath, []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(AbsPath) ([]byte, error)
EncryptFile implements Encryption.EncryptFile.
func (NoEncryption) EncryptedSuffix ¶
func (NoEncryption) EncryptedSuffix() string
EncryptedSuffix implements Encryption.EncryptedSuffix.
type NotInAbsDirError ¶ added in v2.36.1
type NotInAbsDirError struct {
// contains filtered or unexported fields
}
func (*NotInAbsDirError) Error ¶ added in v2.36.1
func (e *NotInAbsDirError) Error() string
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) CopyTo ¶
func (NullPersistentState) CopyTo(s PersistentState) error
CopyTo does nothing.
func (NullPersistentState) Delete ¶
func (NullPersistentState) Delete(bucket, key []byte) error
Delete does nothing.
func (NullPersistentState) DeleteBucket ¶ added in v2.9.0
func (NullPersistentState) DeleteBucket(bucket []byte) error
DeleteBucket 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 NullSystem ¶ added in v2.36.1
type NullSystem struct {
// contains filtered or unexported fields
}
func (NullSystem) RunScript ¶ added in v2.36.1
func (NullSystem) RunScript( scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions, ) error
func (NullSystem) UnderlyingFS ¶ added in v2.36.1
func (*NullSystem) UnderlyingSystem ¶ added in v2.36.1
func (s *NullSystem) UnderlyingSystem() System
UnderlyingSystem implements System.UnderlyingSystem.
func (NullSystem) WriteSymlink ¶ added in v2.36.1
type PersistentState ¶
type PersistentState interface { Close() error CopyTo(s PersistentState) error Data() (any, error) Delete(bucket, key []byte) error DeleteBucket(bucket []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 PreAddFunc ¶ added in v2.0.11
A PreAddFunc is called before a new source state entry is added.
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) Glob ¶
func (s *ReadOnlySystem) Glob(pattern string) ([]string, error)
Glob implements System.Glob.
func (*ReadOnlySystem) Lstat ¶
func (s *ReadOnlySystem) Lstat(filename AbsPath) (fs.FileInfo, error)
Lstat implements System.Lstat.
func (*ReadOnlySystem) RawPath ¶
func (s *ReadOnlySystem) RawPath(path AbsPath) (AbsPath, error)
RawPath implements System.RawPath.
func (*ReadOnlySystem) ReadDir ¶
func (s *ReadOnlySystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
ReadDir implements System.ReadDir.
func (*ReadOnlySystem) ReadFile ¶
func (s *ReadOnlySystem) ReadFile(name AbsPath) ([]byte, error)
ReadFile implements System.ReadFile.
func (*ReadOnlySystem) Readlink ¶
func (s *ReadOnlySystem) Readlink(name AbsPath) (string, error)
Readlink implements System.Readlink.
func (ReadOnlySystem) RunScript ¶
func (ReadOnlySystem) RunScript( scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions, ) error
func (*ReadOnlySystem) Stat ¶
func (s *ReadOnlySystem) Stat(name AbsPath) (fs.FileInfo, error)
Stat implements System.Stat.
func (*ReadOnlySystem) UnderlyingFS ¶
func (s *ReadOnlySystem) UnderlyingFS() vfs.FS
UnderlyingFS implements System.UnderlyingFS.
func (*ReadOnlySystem) UnderlyingSystem ¶ added in v2.36.1
func (s *ReadOnlySystem) UnderlyingSystem() System
UnderlyingSystem implements System.UnderlyingSystem.
func (ReadOnlySystem) WriteSymlink ¶
type ReadOptions ¶ added in v2.2.0
type ReadOptions struct { ReadHTTPResponse func(*http.Response) ([]byte, error) RefreshExternals RefreshExternals TimeNow func() time.Time }
ReadOptions are options to SourceState.Read.
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(fileSystem vfs.FS, options ...RealSystemOption) *RealSystem
NewRealSystem returns a System that acts on fileSystem.
func (*RealSystem) Chmod ¶
func (s *RealSystem) Chmod(name AbsPath, mode fs.FileMode) error
Chmod implements System.Chmod.
func (*RealSystem) Chtimes ¶ added in v2.36.1
func (s *RealSystem) Chtimes(name AbsPath, atime, mtime time.Time) error
Chtimes implements System.Chtimes.
func (*RealSystem) Glob ¶
func (s *RealSystem) Glob(pattern string) ([]string, error)
Glob implements System.Glob.
func (*RealSystem) Link ¶ added in v2.6.0
func (s *RealSystem) Link(oldname, newname AbsPath) error
Link implements System.Link.
func (*RealSystem) Lstat ¶
func (s *RealSystem) Lstat(filename AbsPath) (fs.FileInfo, error)
Lstat implements System.Lstat.
func (*RealSystem) Mkdir ¶
func (s *RealSystem) Mkdir(name AbsPath, perm fs.FileMode) error
Mkdir implements System.Mkdir.
func (*RealSystem) RawPath ¶
func (s *RealSystem) RawPath(absPath AbsPath) (AbsPath, error)
RawPath implements System.RawPath.
func (*RealSystem) ReadDir ¶
func (s *RealSystem) ReadDir(name AbsPath) ([]fs.DirEntry, error)
ReadDir implements System.ReadDir.
func (*RealSystem) ReadFile ¶
func (s *RealSystem) ReadFile(name AbsPath) ([]byte, error)
ReadFile implements System.ReadFile.
func (*RealSystem) Readlink ¶
func (s *RealSystem) Readlink(name AbsPath) (string, error)
Readlink implements System.Readlink.
func (*RealSystem) Remove ¶ added in v2.36.1
func (s *RealSystem) Remove(name AbsPath) error
Remove implements System.Remove.
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, options RunScriptOptions, ) (err error)
RunScript implements System.RunScript.
func (*RealSystem) SetScriptEnv ¶ added in v2.36.1
func (s *RealSystem) SetScriptEnv(scriptEnv []string)
SetScriptEnv sets the environment variables for scripts.
func (*RealSystem) Stat ¶
func (s *RealSystem) Stat(name AbsPath) (fs.FileInfo, error)
Stat implements System.Stat.
func (*RealSystem) UnderlyingFS ¶
func (s *RealSystem) UnderlyingFS() vfs.FS
UnderlyingFS implements System.UnderlyingFS.
func (*RealSystem) UnderlyingSystem ¶ added in v2.36.1
func (s *RealSystem) UnderlyingSystem() System
UnderlyingSystem implements System.UnderlyingSystem.
func (*RealSystem) WriteSymlink ¶
func (s *RealSystem) WriteSymlink(oldname string, newname AbsPath) error
WriteSymlink implements System.WriteSymlink.
type RealSystemOption ¶ added in v2.3.0
type RealSystemOption func(*RealSystem)
A RealSystemOption sets an option on a RealSystem.
func RealSystemWithSafe ¶ added in v2.3.0
func RealSystemWithSafe(safe bool) RealSystemOption
RealSystemWithSafe sets the safe flag of the RealSystem.
func RealSystemWithScriptTempDir ¶ added in v2.36.1
func RealSystemWithScriptTempDir(scriptTempDir AbsPath) RealSystemOption
RealSystemWithScriptTempDir sets the script temporary directory of the RealSystem.
type RefreshExternals ¶ added in v2.36.1
type RefreshExternals int
const ( RefreshExternalsAuto RefreshExternals = iota RefreshExternalsAlways RefreshExternalsNever )
func (*RefreshExternals) Set ¶ added in v2.36.1
func (re *RefreshExternals) Set(s string) error
func (RefreshExternals) String ¶ added in v2.36.1
func (re RefreshExternals) String() string
func (RefreshExternals) Type ¶ added in v2.36.1
func (re RefreshExternals) Type() string
type RelPath ¶
type RelPath struct {
// contains filtered or unexported fields
}
A RelPath is a relative path.
func NewRelPath ¶ added in v2.7.4
NewRelPath returns a new RelPath.
func (RelPath) AppendString ¶ added in v2.7.4
AppendString appends s to p.
func (RelPath) HasDirPrefix ¶
HasDirPrefix returns true if p has dir prefix dirPrefix.
func (RelPath) JoinString ¶ added in v2.7.4
JoinString returns a new RelPath with ss appended.
func (RelPath) MarshalJSON ¶ added in v2.7.4
MarshalJSON implements encoding.TextMarshaler.MarshalJSON.
func (RelPath) SourceRelDirPath ¶ added in v2.36.1
func (p RelPath) SourceRelDirPath() SourceRelPath
SourceRelDirPath returns p as a directory SourceRelPath.
func (RelPath) SourceRelPath ¶ added in v2.36.1
func (p RelPath) SourceRelPath() SourceRelPath
SourceRelPath returns p as a SourceRelPath.
type RelPaths ¶
type RelPaths []RelPath
RelPaths is a slice of RelPaths that implements sort.Interface.
type ReplaceFunc ¶ added in v2.36.1
type ReplaceFunc func(targetRelPath RelPath, newSourceStateEntry, oldSourceStateEntry SourceStateEntry) error
A ReplaceFunc is called before a source state entry is replaced.
type RunScriptOptions ¶ added in v2.36.1
type RunScriptOptions struct { Interpreter *Interpreter Condition ScriptCondition }
type ScriptCondition ¶ added in v2.7.0
type ScriptCondition string
A ScriptCondition defines under what conditions a script should be executed.
const ( ScriptConditionNone ScriptCondition = "" ScriptConditionAlways ScriptCondition = "always" ScriptConditionOnce ScriptCondition = "once" ScriptConditionOnChange ScriptCondition = "onchange" )
Script conditions.
type ScriptOrder ¶ added in v2.7.0
type ScriptOrder int
A ScriptOrder defines when a script should be executed.
const ( ScriptOrderBefore ScriptOrder = -1 ScriptOrderDuring ScriptOrder = 0 ScriptOrderAfter ScriptOrder = 1 )
Script orders.
type SourceAttr ¶ added in v2.36.1
type SourceAttr struct { Condition ScriptCondition Encrypted bool External bool Template bool }
A SourceAttr contains attributes of the source.
type SourceDirTargetType ¶ added in v2.36.1
type SourceDirTargetType int
A SourceDirTargetType is the type of a target represented by a directory in the source state.
const ( SourceDirTypeDir SourceDirTargetType = iota SourceDirTypeRemove )
Source dir types.
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 ( SourceFileTypeCreate SourceFileTargetType = iota SourceFileTypeFile SourceFileTypeModify SourceFileTypeRemove 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 string) SourceRelPath
NewSourceRelDirPath returns a new SourceRelPath for a directory.
func NewSourceRelPath ¶
func NewSourceRelPath(relPath string) SourceRelPath
NewSourceRelPath returns a new SourceRelPath.
func (SourceRelPath) Join ¶
func (p SourceRelPath) Join(sourceRelPaths ...SourceRelPath) SourceRelPath
Join appends sourceRelPaths to p.
func (SourceRelPath) Less ¶ added in v2.7.4
func (p SourceRelPath) Less(other SourceRelPath) bool
Less returns true if p is less than other.
func (SourceRelPath) RelPath ¶
func (p SourceRelPath) RelPath() RelPath
RelPath returns p as a relative path.
func (SourceRelPath) Split ¶
func (p SourceRelPath) Split() (SourceRelPath, SourceRelPath)
Split returns the p's file and directory.
func (SourceRelPath) String ¶
func (p SourceRelPath) String() string
func (SourceRelPath) TargetRelPath ¶
func (p SourceRelPath) TargetRelPath(encryptedSuffix string) RelPath
TargetRelPath returns the relative path of p's target.
type SourceState ¶
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]fs.FileInfo, options *AddOptions, ) error
Add adds destAbsPathInfos to s.
func (*SourceState) AddDestAbsPathInfos ¶
func (s *SourceState) AddDestAbsPathInfos( destAbsPathInfos map[AbsPath]fs.FileInfo, system System, destAbsPath AbsPath, fileInfo fs.FileInfo, ) error
AddDestAbsPathInfos adds an fs.FileInfo to destAbsPathInfos for destAbsPath and any of its parents which are not already known.
func (*SourceState) Apply ¶
func (s *SourceState) Apply( targetSystem, destSystem System, persistentState PersistentState, targetDirAbsPath AbsPath, targetRelPath RelPath, options ApplyOptions, ) error
Apply updates targetRelPath in targetDirAbsPath in destSystem to match s.
func (*SourceState) Encryption ¶
func (s *SourceState) Encryption() Encryption
Encryption returns s's encryption.
func (*SourceState) ExecuteTemplateData ¶
func (s *SourceState) ExecuteTemplateData(options ExecuteTemplateDataOptions) ([]byte, error)
ExecuteTemplateData returns the result of executing template data.
func (*SourceState) ForEach ¶ added in v2.7.5
func (s *SourceState) ForEach(f func(RelPath, SourceStateEntry) error) error
ForEach calls f for each source state entry.
func (*SourceState) Get ¶ added in v2.36.1
func (s *SourceState) Get(targetRelPath RelPath) SourceStateEntry
Get returns the source state entry for targetRelPath.
func (*SourceState) Ignore ¶ added in v2.7.2
func (s *SourceState) Ignore(targetRelPath RelPath) bool
Ignore returns if targetRelPath should be ignored.
func (*SourceState) Ignored ¶
func (s *SourceState) Ignored() RelPaths
Ignored returns all ignored RelPaths.
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) PostApply ¶ added in v2.36.1
func (s *SourceState) PostApply( targetSystem System, targetDirAbsPath AbsPath, targetRelPaths RelPaths, ) error
PostApply performs all updates required after s.Apply.
func (*SourceState) Read ¶
func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error
Read reads the source state from the source directory.
func (*SourceState) TargetRelPaths ¶
func (s *SourceState) TargetRelPaths() []RelPath
TargetRelPaths returns all of s's target relative paths in order.
func (*SourceState) TemplateData ¶
func (s *SourceState) TemplateData() map[string]any
TemplateData returns s's template data.
type SourceStateCommand ¶ added in v2.36.1
type SourceStateCommand struct {
// contains filtered or unexported fields
}
A SourceStateCommand represents a command that should be run.
func (*SourceStateCommand) Evaluate ¶ added in v2.36.1
func (s *SourceStateCommand) Evaluate() error
Evaluate evaluates s and returns any error.
func (*SourceStateCommand) MarshalZerologObject ¶ added in v2.36.1
func (s *SourceStateCommand) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements github.com/rs/zerolog.LogObjectMarshaler.MarshalZerologObject.
func (*SourceStateCommand) Order ¶ added in v2.36.1
func (s *SourceStateCommand) Order() ScriptOrder
Order returns s's order.
func (*SourceStateCommand) Origin ¶ added in v2.36.1
func (s *SourceStateCommand) Origin() SourceStateOrigin
Origin returns s's origin.
func (*SourceStateCommand) SourceRelPath ¶ added in v2.36.1
func (s *SourceStateCommand) SourceRelPath() SourceRelPath
SourceRelPath returns s's source relative path.
func (*SourceStateCommand) TargetStateEntry ¶ added in v2.36.1
func (s *SourceStateCommand) TargetStateEntry( destSystem System, destDirAbsPath AbsPath, ) (TargetStateEntry, error)
TargetStateEntry returns s's target state entry.
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) MarshalZerologObject ¶ added in v2.5.0
func (s *SourceStateDir) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements github.com/rs/zerolog.LogObjectMarshaler.MarshalZerologObject.
func (*SourceStateDir) Order ¶
func (s *SourceStateDir) Order() ScriptOrder
Order returns s's order.
func (*SourceStateDir) Origin ¶ added in v2.7.5
func (s *SourceStateDir) Origin() SourceStateOrigin
Origin returns s's origin.
func (*SourceStateDir) SourceRelPath ¶
func (s *SourceStateDir) SourceRelPath() SourceRelPath
SourceRelPath returns s's source relative path.
func (*SourceStateDir) TargetStateEntry ¶
func (s *SourceStateDir) TargetStateEntry( destSystem System, destDirAbsPath AbsPath, ) (TargetStateEntry, error)
TargetStateEntry returns s's target state entry.
type SourceStateEntry ¶
type SourceStateEntry interface { zerolog.LogObjectMarshaler Evaluate() error Order() ScriptOrder Origin() SourceStateOrigin SourceRelPath() SourceRelPath TargetStateEntry(destSystem System, destDirAbsPath AbsPath) (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) ContentsSHA256 ¶
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) MarshalZerologObject ¶ added in v2.5.0
func (s *SourceStateFile) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements github.com/rs/zerolog.LogObjectMarshaler.MarshalZerologObject.
func (*SourceStateFile) Order ¶
func (s *SourceStateFile) Order() ScriptOrder
Order returns s's order.
func (*SourceStateFile) Origin ¶ added in v2.7.5
func (s *SourceStateFile) Origin() SourceStateOrigin
Origin returns s's origin.
func (*SourceStateFile) SourceRelPath ¶
func (s *SourceStateFile) SourceRelPath() SourceRelPath
SourceRelPath returns s's source relative path.
func (*SourceStateFile) TargetStateEntry ¶
func (s *SourceStateFile) TargetStateEntry( destSystem System, destDirAbsPath AbsPath, ) (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 WithBaseSystem ¶ added in v2.2.0
func WithBaseSystem(baseSystem System) SourceStateOption
WithBaseSystem sets the base system.
func WithCacheDir ¶ added in v2.2.0
func WithCacheDir(cacheDirAbsPath AbsPath) SourceStateOption
WithCacheDir sets the cache directory.
func WithDefaultTemplateDataFunc ¶
func WithDefaultTemplateDataFunc(defaultTemplateDataFunc func() map[string]any) 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 WithHTTPClient ¶ added in v2.8.0
func WithHTTPClient(httpClient *http.Client) SourceStateOption
WithHTTPClient sets the HTTP client.
func WithInterpreters ¶ added in v2.0.14
func WithInterpreters(interpreters map[string]*Interpreter) SourceStateOption
WithInterpreters sets the interpreters.
func WithLogger ¶ added in v2.7.0
func WithLogger(logger *zerolog.Logger) SourceStateOption
WithLogger sets the logger.
func WithPriorityTemplateData ¶
func WithPriorityTemplateData(priorityTemplateData map[string]any) SourceStateOption
WithPriorityTemplateData adds priority template data.
func WithReadTemplateData ¶ added in v2.1.5
func WithReadTemplateData(readTemplateData bool) SourceStateOption
WithReadTemplateData sets whether to read .chezmoidata.<format> files.
func WithScriptEnv ¶ added in v2.36.1
func WithScriptEnv(scriptEnv []string) SourceStateOption
WithScriptEnv sets the script environment variables.
func WithSourceDir ¶
func WithSourceDir(sourceDirAbsPath AbsPath) SourceStateOption
WithSourceDir sets the source directory.
func WithTemplateDataOnly ¶ added in v2.10.1
func WithTemplateDataOnly(templateDataOnly bool) SourceStateOption
WithTemplateDataOnly sets whether only template data should be read.
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.
func WithUmask ¶ added in v2.36.1
func WithUmask(umask fs.FileMode) SourceStateOption
WithUmask sets the umask.
func WithVersion ¶ added in v2.9.2
func WithVersion(version semver.Version) SourceStateOption
WithVersion sets the version.
type SourceStateOrigin ¶ added in v2.36.1
A SourceStateOrigin represents the origin of a source state.
type SourceStateOriginAbsPath ¶ added in v2.36.1
type SourceStateOriginAbsPath AbsPath
A SourceStateOriginAbsPath is an absolute path.
func (SourceStateOriginAbsPath) OriginString ¶ added in v2.36.1
func (s SourceStateOriginAbsPath) OriginString() string
OriginString returns s's origin.
func (SourceStateOriginAbsPath) Path ¶ added in v2.36.1
func (s SourceStateOriginAbsPath) Path() AbsPath
Path returns s's path.
type SourceStateOriginRemove ¶ added in v2.36.1
type SourceStateOriginRemove struct{}
A SourceStateOriginRemove is used for removes. The source of the remove is not currently tracked. The remove could come from an exact_ directory, a non-empty_ file with empty contents, or one of many patterns in many .chezmoiignore files.
FIXME remove this when the sources of all removes are tracked.
func (SourceStateOriginRemove) OriginString ¶ added in v2.36.1
func (s SourceStateOriginRemove) OriginString() string
OriginString returns s's origin.
func (SourceStateOriginRemove) Path ¶ added in v2.36.1
func (s SourceStateOriginRemove) Path() AbsPath
Path returns s's path.
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) MarshalZerologObject ¶ added in v2.5.0
func (s *SourceStateRemove) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements zerolog.LogObjectMarshaler.
func (*SourceStateRemove) Order ¶
func (s *SourceStateRemove) Order() ScriptOrder
Order returns s's order.
func (*SourceStateRemove) Origin ¶ added in v2.7.5
func (s *SourceStateRemove) Origin() SourceStateOrigin
Origin returns s's origin.
func (*SourceStateRemove) SourceRelPath ¶
func (s *SourceStateRemove) SourceRelPath() SourceRelPath
SourceRelPath returns s's source relative path.
func (*SourceStateRemove) TargetStateEntry ¶
func (s *SourceStateRemove) TargetStateEntry( destSystem System, destDirAbsPath AbsPath, ) (TargetStateEntry, error)
TargetStateEntry returns s's target state entry.
type System ¶
type System interface { Chmod(name AbsPath, mode fs.FileMode) error Chtimes(name AbsPath, atime, mtime time.Time) error Glob(pattern string) ([]string, error) Link(oldname, newname AbsPath) error Lstat(filename AbsPath) (fs.FileInfo, error) Mkdir(name AbsPath, perm fs.FileMode) error RawPath(absPath AbsPath) (AbsPath, error) ReadDir(name AbsPath) ([]fs.DirEntry, error) ReadFile(name AbsPath) ([]byte, error) Readlink(name AbsPath) (string, error) Remove(name AbsPath) error RemoveAll(name AbsPath) error Rename(oldpath, newpath AbsPath) error RunCmd(cmd *exec.Cmd) error RunScript(scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions) error Stat(name AbsPath) (fs.FileInfo, error) UnderlyingFS() vfs.FS UnderlyingSystem() System WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error WriteSymlink(oldname string, newname AbsPath) error }
A System reads from and writes to a filesystem, runs scripts, and persists state.
type TarWriterSystem ¶ added in v2.9.3
type TarWriterSystem struct {
// contains filtered or unexported fields
}
A TarWriterSystem is a System that writes to a tar archive.
func NewTarWriterSystem ¶ added in v2.9.3
func NewTarWriterSystem(w io.Writer, headerTemplate tar.Header) *TarWriterSystem
NewTarWriterSystem returns a new TarWriterSystem that writes a tar file to w.
func (*TarWriterSystem) Close ¶ added in v2.9.3
func (s *TarWriterSystem) Close() error
Close closes m.
func (*TarWriterSystem) Mkdir ¶ added in v2.9.3
func (s *TarWriterSystem) Mkdir(name AbsPath, perm fs.FileMode) error
Mkdir implements System.Mkdir.
func (*TarWriterSystem) RunCmd ¶ added in v2.9.3
func (s *TarWriterSystem) RunCmd(cmd *exec.Cmd) error
RunCmd implements System.RunCmd.
func (*TarWriterSystem) RunScript ¶ added in v2.9.3
func (s *TarWriterSystem) RunScript( scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions, ) error
RunScript implements System.RunScript.
func (TarWriterSystem) UnderlyingFS ¶ added in v2.9.3
func (*TarWriterSystem) UnderlyingSystem ¶ added in v2.36.1
func (s *TarWriterSystem) UnderlyingSystem() System
UnderlyingSystem implements System.UnderlyingSystem.
func (*TarWriterSystem) WriteSymlink ¶ added in v2.9.3
func (s *TarWriterSystem) WriteSymlink(oldname string, newname AbsPath) error
WriteSymlink implements System.WriteSymlink.
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, ) (bool, error)
Apply updates actualStateEntry to match t. It does not recurse.
func (*TargetStateDir) EntryState ¶
func (t *TargetStateDir) EntryState(umask fs.FileMode) (*EntryState, error)
EntryState returns t's entry state.
func (*TargetStateDir) SkipApply ¶
func (t *TargetStateDir) SkipApply( persistentState PersistentState, targetAbsPath AbsPath, ) (bool, error)
SkipApply implements TargetState.SkipApply.
func (*TargetStateDir) SourceAttr ¶ added in v2.36.1
func (t *TargetStateDir) SourceAttr() SourceAttr
SourceAttr implements TargetStateEntry.SourceAttr.
type TargetStateEntry ¶
type TargetStateEntry interface { Apply( system System, persistentState PersistentState, actualStateEntry ActualStateEntry, ) (bool, error) EntryState(umask fs.FileMode) (*EntryState, error) Evaluate() error SkipApply(persistentState PersistentState, targetAbsPath AbsPath) (bool, error) SourceAttr() SourceAttr }
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, ) (bool, error)
Apply updates actualStateEntry to match t.
func (TargetStateFile) ContentsSHA256 ¶
ContentsSHA256 returns the SHA256 sum of lc's contents.
func (*TargetStateFile) EntryState ¶
func (t *TargetStateFile) EntryState(umask fs.FileMode) (*EntryState, error)
EntryState returns t's entry state.
func (*TargetStateFile) Perm ¶ added in v2.0.13
func (t *TargetStateFile) Perm(umask fs.FileMode) fs.FileMode
Perm returns t's perm.
func (*TargetStateFile) SkipApply ¶
func (t *TargetStateFile) SkipApply( persistentState PersistentState, targetAbsPath AbsPath, ) (bool, error)
SkipApply implements TargetStateEntry.SkipApply.
func (*TargetStateFile) SourceAttr ¶ added in v2.36.1
func (t *TargetStateFile) SourceAttr() SourceAttr
SourceAttr implements TargetStateEntry.SourceAttr.
type TargetStateModifyDirWithCmd ¶ added in v2.36.1
type TargetStateModifyDirWithCmd struct {
// contains filtered or unexported fields
}
A TargetStateModifyDirWithCmd represents running a command that modifies a directory.
func (*TargetStateModifyDirWithCmd) Apply ¶ added in v2.36.1
func (t *TargetStateModifyDirWithCmd) Apply( system System, persistentState PersistentState, actualStateEntry ActualStateEntry, ) (bool, error)
Apply updates actualStateEntry to match t.
func (*TargetStateModifyDirWithCmd) EntryState ¶ added in v2.36.1
func (t *TargetStateModifyDirWithCmd) EntryState(umask fs.FileMode) (*EntryState, error)
EntryState returns t's entry state.
func (*TargetStateModifyDirWithCmd) Evaluate ¶ added in v2.36.1
func (t *TargetStateModifyDirWithCmd) Evaluate() error
Evaluate evaluates t.
func (*TargetStateModifyDirWithCmd) SkipApply ¶ added in v2.36.1
func (t *TargetStateModifyDirWithCmd) SkipApply( persistentState PersistentState, targetAbsPath AbsPath, ) (bool, error)
SkipApply implements TargetStateEntry.SkipApply.
func (*TargetStateModifyDirWithCmd) SourceAttr ¶ added in v2.36.1
func (t *TargetStateModifyDirWithCmd) SourceAttr() SourceAttr
SourceAttr implements TargetStateEntry.SourceAttr.
type TargetStateRemove ¶
type TargetStateRemove struct{}
A TargetStateRemove represents the absence of an entry in the target state.
func (*TargetStateRemove) Apply ¶
func (t *TargetStateRemove) Apply( system System, persistentState PersistentState, actualStateEntry ActualStateEntry, ) (bool, error)
Apply updates actualStateEntry to match t.
func (*TargetStateRemove) EntryState ¶
func (t *TargetStateRemove) EntryState(umask fs.FileMode) (*EntryState, error)
EntryState returns t's entry state.
func (*TargetStateRemove) Evaluate ¶
func (t *TargetStateRemove) Evaluate() error
Evaluate evaluates t.
func (*TargetStateRemove) SkipApply ¶
func (t *TargetStateRemove) SkipApply( persistentState PersistentState, targetAbsPath AbsPath, ) (bool, error)
SkipApply implements TargetStateEntry.SkipApply.
func (*TargetStateRemove) SourceAttr ¶ added in v2.36.1
func (t *TargetStateRemove) SourceAttr() SourceAttr
SourceAttr implements TargetStateEntry.SourceAttr.
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, ) (bool, error)
Apply runs t.
func (TargetStateScript) ContentsSHA256 ¶
ContentsSHA256 returns the SHA256 sum of lc's contents.
func (*TargetStateScript) EntryState ¶
func (t *TargetStateScript) EntryState(umask fs.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, targetAbsPath AbsPath, ) (bool, error)
SkipApply implements TargetStateEntry.SkipApply.
func (*TargetStateScript) SourceAttr ¶ added in v2.36.1
func (t *TargetStateScript) SourceAttr() SourceAttr
SourceAttr implements TargetStateEntry.SourceAttr.
type TargetStateSymlink ¶
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, ) (bool, error)
Apply updates actualStateEntry to match t.
func (*TargetStateSymlink) EntryState ¶
func (t *TargetStateSymlink) EntryState(umask fs.FileMode) (*EntryState, error)
EntryState returns t's entry state.
func (*TargetStateSymlink) Evaluate ¶
func (t *TargetStateSymlink) Evaluate() error
Evaluate evaluates t.
func (TargetStateSymlink) LinknameSHA256 ¶
LinknameSHA256 returns the SHA256 sum of ll's linkname.
func (*TargetStateSymlink) SkipApply ¶
func (t *TargetStateSymlink) SkipApply( persistentState PersistentState, targetAbsPath AbsPath, ) (bool, error)
SkipApply implements TargetStateEntry.SkipApply.
func (*TargetStateSymlink) SourceAttr ¶ added in v2.36.1
func (t *TargetStateSymlink) SourceAttr() SourceAttr
SourceAttr implements TargetStateEntry.SourceAttr.
type Template ¶ added in v2.36.1
type Template struct {
// contains filtered or unexported fields
}
A Template extends text/template.Template with support for directives.
func ParseTemplate ¶ added in v2.36.1
func ParseTemplate( name string, data []byte, funcs template.FuncMap, options TemplateOptions, ) (*Template, error)
ParseTemplate parses a template named name from data with the given funcs and templateOptions.
func (*Template) AddParseTree ¶ added in v2.36.1
AddParseTree adds tmpl's parse tree to t.
type TemplateOptions ¶ added in v2.36.1
type TemplateOptions struct { LeftDelimiter string LineEnding string RightDelimiter string Options []string }
TemplateOptions are template options that can be set with directives.
type TextConvFunc ¶ added in v2.36.1
A TextConvFunc converts the contents of a file into a more human-readable form.
type TooOldError ¶ added in v2.9.2
A TooOldError is returned when the source state requires a newer version of chezmoi.
func (*TooOldError) Error ¶ added in v2.9.2
func (e *TooOldError) Error() string
type UnknownArchiveFormatError ¶ added in v2.36.1
type UnknownArchiveFormatError string
func (UnknownArchiveFormatError) Error ¶ added in v2.36.1
func (e UnknownArchiveFormatError) Error() string
type WalkArchiveFunc ¶ added in v2.9.1
An WalkArchiveFunc is called once for each entry in an archive.
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) Mkdir ¶
func (s *ZIPWriterSystem) Mkdir(name AbsPath, perm fs.FileMode) error
Mkdir implements System.Mkdir.
func (*ZIPWriterSystem) RunCmd ¶
func (s *ZIPWriterSystem) RunCmd(cmd *exec.Cmd) error
RunCmd implements System.RunCmd.
func (*ZIPWriterSystem) RunScript ¶
func (s *ZIPWriterSystem) RunScript( scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions, ) error
RunScript implements System.RunScript.
func (ZIPWriterSystem) UnderlyingFS ¶
func (*ZIPWriterSystem) UnderlyingSystem ¶ added in v2.36.1
func (s *ZIPWriterSystem) UnderlyingSystem() System
UnderlyingSystem implements System.UnderlyingSystem.
func (*ZIPWriterSystem) WriteSymlink ¶
func (s *ZIPWriterSystem) WriteSymlink(oldname string, newname AbsPath) error
WriteSymlink implements System.WriteSymlink.
Source Files
¶
- abspath.go
- actualstateentry.go
- ageencryption.go
- archive.go
- archivereadersystem.go
- attr.go
- boltpersistentstate.go
- chezmoi.go
- chezmoi_go1.20.go
- chezmoi_unix.go
- data.go
- debugencryption.go
- debugpersistentstate.go
- debugsystem.go
- diff.go
- dryrunsystem.go
- dumpsystem.go
- duration.go
- encryption.go
- entrystate.go
- entrytypefilter.go
- entrytypeset.go
- erroronwritesystem.go
- errors.go
- externaldiffsystem.go
- format.go
- gitdiffsystem.go
- github.go
- glob.go
- gpgencryption.go
- hexbytes.go
- interpreter.go
- lazy.go
- lookpath.go
- mockpersistentstate.go
- mode.go
- noencryption.go
- nullpersistentstate.go
- nullsystem.go
- path_unix.go
- patternset.go
- persistentstate.go
- readonlysystem.go
- realsystem.go
- realsystem_unix.go
- recursivemerge.go
- refreshexternals.go
- relpath.go
- set.go
- sourcerelpath.go
- sourcestate.go
- sourcestateentry.go
- sourcestatetreenode.go
- system.go
- targetstateentry.go
- tarwritersystem.go
- template.go
- zipwritersystem.go