Documentation ¶
Overview ¶
Package fswalker contains functionality to walk a file system and compare the differences.
Index ¶
- Variables
- func NormalizePath(path string, isDir bool) string
- func WalkFilename(hostname string, t time.Time) string
- type ActionData
- type Report
- type Reporter
- func (r *Reporter) Compare(before, after *fspb.Walk) (*Report, error)
- func (r *Reporter) PrintDiffSummary(out io.Writer, report *Report)
- func (r *Reporter) PrintReportSummary(out io.Writer, report *Report)
- func (r *Reporter) PrintRuleSummary(out io.Writer, report *Report)
- func (r *Reporter) ReadLastGoodWalk(ctx context.Context, hostname, reviewFile string) (*WalkFile, error)
- func (r *Reporter) ReadLatestWalk(ctx context.Context, hostname, walkPath string) (*WalkFile, error)
- func (r *Reporter) ReadWalk(ctx context.Context, path string) (*WalkFile, error)
- func (r *Reporter) UpdateReviewProto(ctx context.Context, walkFile *WalkFile, reviewFile string) error
- type WalkCallback
- type WalkFile
- type Walker
Constants ¶
This section is empty.
Variables ¶
var Glob = func(_ context.Context, pattern string) ([]string, error) { return filepath.Glob(pattern) }
Glob returns the names of all files matching pattern or nil if there is no matching file.
var ReadFile = func(_ context.Context, filename string) ([]byte, error) { return ioutil.ReadFile(filename) }
ReadFile reads the file named by filename and returns the contents.
var WriteFile = func(_ context.Context, filename string, data []byte, perm os.FileMode) error { return ioutil.WriteFile(filename, data, perm) }
WriteFile writes data to a file named by filename.
Functions ¶
func NormalizePath ¶ added in v0.1.0
NormalizePath returns a cleaned up path with a path separator at the end if it's a directory. It should always be used when printing or comparing paths.
Types ¶
type ActionData ¶ added in v0.1.0
ActionData contains a diff between two files in different Walks.
type Report ¶ added in v0.1.0
type Report struct { Added []ActionData Deleted []ActionData Modified []ActionData Errors []ActionData Counter *metrics.Counter WalkBefore *fspb.Walk WalkAfter *fspb.Walk }
Report contains the result of the comparison between two Walks.
type Reporter ¶
type Reporter struct { // Verbose, when true, makes Reporter print more information for all diffs found. Verbose bool // contains filtered or unexported fields }
Reporter compares two Walks against each other based on the config provided and prints a list of diffs between the two.
func ReporterFromConfigFile ¶
ReporterFromConfigFile creates a new Reporter based on a config path.
func (*Reporter) PrintDiffSummary ¶ added in v0.1.0
PrintDiffSummary prints the diffs found in a Report.
func (*Reporter) PrintReportSummary ¶
PrintReportSummary prints a few key information pieces around the Report.
func (*Reporter) PrintRuleSummary ¶
PrintRuleSummary prints the configs and policies involved in creating the Walk and Report.
func (*Reporter) ReadLastGoodWalk ¶ added in v0.1.0
func (r *Reporter) ReadLastGoodWalk(ctx context.Context, hostname, reviewFile string) (*WalkFile, error)
ReadLastGoodWalk reads the designated review file and attempts to find an entry matching the given hostname. Note that if it can't find one but the review file itself was read successfully, it will return an empty Walk and no error. It returns the file path it ended up reading, the Walk it read and the fingerprint for it.
func (*Reporter) ReadLatestWalk ¶ added in v0.1.0
func (r *Reporter) ReadLatestWalk(ctx context.Context, hostname, walkPath string) (*WalkFile, error)
ReadLatestWalk looks for the latest Walk in a given folder for a given hostname. It returns the file path it ended up reading, the Walk it read and the fingerprint for it.
type WalkCallback ¶
WalkCallback is called by Walker at the end of the Run. The callback is typically used to dump the walk to disk and/or perform any other checks. The error return value is propagated back to the Run callers.
type WalkFile ¶ added in v0.1.0
type WalkFile struct { Path string Walk *fspb.Walk Fingerprint *fspb.Fingerprint }
WalkFile contains info about a Walk file.
type Walker ¶
type Walker struct { // Function to call once the Walk is complete i.e. to inspect or write the Walk. WalkCallback WalkCallback // Verbose, when true, makes Walker print file metadata to stdout. Verbose bool // Counter records stats over all processed files, if non-nil. Counter *metrics.Counter // contains filtered or unexported fields }
Walker is able to walk a file structure starting with a list of given includes as roots. All paths starting with any prefix specified in the excludes are ignored. The list of specific files in the hash list are read and a hash sum built for each. Note that this is expensive and should not be done for large files or a large number of files.
func WalkerFromPolicyFile ¶
WalkerFromPolicyFile creates a new Walker based on a policy path.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
reporter
Reporter is a CLI tool to process file system report files generated by Walker.
|
Reporter is a CLI tool to process file system report files generated by Walker. |
walker
Walker is a CLI tool to walk over a set of directories and process all discovered files.
|
Walker is a CLI tool to walk over a set of directories and process all discovered files. |
internal
|
|
fsstat
Package fsstat provides access to platform specific file stat info.
|
Package fsstat provides access to platform specific file stat info. |
metrics
Package metrics implements generic metrics.
|
Package metrics implements generic metrics. |
proto
|
|