Documentation ¶
Index ¶
- Variables
- func GetIndexFs() afero.Fs
- func SetIndexFs(fs afero.Fs)
- type Config
- type Entry
- type Index
- func (idx *Index) Add(path string, info os.FileInfo) error
- func (idx *Index) AddEntry(entry Entry) error
- func (idx *Index) ForEach(f func(Entry))
- func (idx *Index) Get(path string) (Entry, bool)
- func (idx *Index) GetRelativePath(path string) string
- func (idx *Index) Root() string
- func (idx *Index) Size() int
- func (idx *Index) Store(path string) error
- func (idx *Index) String() string
- func (idx *Index) StringWithEntries() string
- func (idx *Index) Timestamp() time.Time
Constants ¶
This section is empty.
Variables ¶
var ConfigViperHook func(v *viper.Viper)
ConfigViperHook is a hook function meant for testing. This is called after the Viper instance is created but before the Config is loaded from the file system.
Functions ¶
func GetIndexFs ¶
GetIndexFs gets the current filesystem used by the Index. Meant for testing.
func SetIndexFs ¶
SetIndexFs sets the current filesystem used by the Index. Meant for testing. The behavior is undefined if this function is called between building an Index and adding Entries to it.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents the information need to load and store an Index on the filesystem.
func (Config) IgnoreDir ¶
IgnoreDir returns true if the given directory matches any of the ignored directory regular expressions.
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry represents the data for a single file in the Index.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index stores data for all files under a particular root directory.
func Load ¶
Load loads an existing index from the given path. Bad data in the Index will be logged but processing will continue to the end of the file.
func New ¶
New creates a new, empty index rooted at the given path. This path _must_ use / as the separator.
func (*Index) Add ¶
Add the given file to the index after parsing it to a new Entry. The given path must include the index's root.
func (*Index) Get ¶
Get the entry for the given path. This path _must be_ relative to the index root; see GetRelativePath()
func (*Index) GetRelativePath ¶
GetRelativePath returns the given path without the Index root.
func (*Index) Root ¶
Root returns the base path for the Entries in the index. Entry.Path should be combined with this path to get the absolute path of a file.
func (*Index) Store ¶
Store writes the index to the file system at the given path. This path should be a file. Callers are responsible for naming the file.
func (*Index) StringWithEntries ¶
StringWithEntries returns the Index as JSON string that contains all of the Entries.