Remove codebase structure section from README
godoc provides this documentation automatically
This commit is contained in:
parent
019fe41c3d
commit
308c583d57
193
README.md
193
README.md
@ -52,199 +52,6 @@ Reading file contents and computing cryptographic hashes for manifest generation
|
||||
- **NO_COLOR:** Respect the `NO_COLOR` environment variable for disabling colored output.
|
||||
- **Options pattern:** Use `NewWithOptions(opts *Options)` constructor pattern for configurable types.
|
||||
|
||||
# Codebase Structure
|
||||
|
||||
## cmd/mfer/
|
||||
|
||||
### main.go
|
||||
|
||||
- **Variables**
|
||||
- `Appname string` - Application name
|
||||
- `Version string` - Version string (set at build time)
|
||||
- `Gitrev string` - Git revision (set at build time)
|
||||
|
||||
## internal/cli/
|
||||
|
||||
### entry.go
|
||||
|
||||
- **Variables**
|
||||
- `NO_COLOR bool` - Disables color output when NO_COLOR env var is set
|
||||
- **Functions**
|
||||
- `Run(Appname, Version, Gitrev string) int` - Main entry point for the CLI
|
||||
|
||||
### mfer.go
|
||||
|
||||
- **Types**
|
||||
- `CLIApp struct` - Main CLI application container
|
||||
- **Methods**
|
||||
- `(*CLIApp) VersionString() string` - Returns formatted version string
|
||||
|
||||
## internal/log/
|
||||
|
||||
### log.go
|
||||
|
||||
- **Functions**
|
||||
- `Init()` - Initializes the logger
|
||||
- `Info(arg string)` - Logs at info level
|
||||
- `Infof(format string, args ...interface{})` - Logs at info level with formatting
|
||||
- `Debug(arg string)` - Logs at debug level with caller info
|
||||
- `Debugf(format string, args ...interface{})` - Logs at debug level with formatting and caller info
|
||||
- `Dump(args ...interface{})` - Logs spew dump at debug level
|
||||
- `Progressf(format string, args ...interface{})` - Prints progress message (overwrites current line)
|
||||
- `ProgressDone()` - Completes progress line with newline
|
||||
- `EnableDebugLogging()` - Sets log level to debug
|
||||
- `SetLevel(arg log.Level)` - Sets log level
|
||||
- `SetLevelFromVerbosity(l int)` - Sets log level from verbosity count
|
||||
- `GetLevel() log.Level` - Returns current log level
|
||||
- `GetLogger() *log.Logger` - Returns underlying logger
|
||||
- `WithError(e error) *log.Entry` - Returns log entry with error attached
|
||||
- `DisableStyling()` - Disables colors and styling (for NO_COLOR)
|
||||
|
||||
## internal/scanner/
|
||||
|
||||
### scanner.go
|
||||
|
||||
- **Types**
|
||||
- `Options struct` - Options for scanner behavior
|
||||
- `IncludeDotfiles bool` - Include dot (hidden) files (excluded by default)
|
||||
- `FollowSymLinks bool`
|
||||
- `EnumerateStatus struct` - Progress information for enumeration phase
|
||||
- `FilesFound int64`
|
||||
- `BytesFound int64`
|
||||
- `ScanStatus struct` - Progress information for scan phase
|
||||
- `TotalFiles int64`
|
||||
- `ScannedFiles int64`
|
||||
- `TotalBytes int64`
|
||||
- `ScannedBytes int64`
|
||||
- `BytesPerSec float64`
|
||||
- `ETA time.Duration`
|
||||
- `FileEntry struct` - Represents an enumerated file
|
||||
- `Path string` - Relative path (used in manifest)
|
||||
- `AbsPath string` - Absolute path (used for reading file content)
|
||||
- `Size int64`
|
||||
- `Mtime time.Time`
|
||||
- `Ctime time.Time`
|
||||
- `Scanner struct` - Accumulates files and generates manifests
|
||||
- **Functions**
|
||||
- `New() *Scanner` - Creates a new Scanner with default options
|
||||
- `NewWithOptions(opts *Options) *Scanner` - Creates a new Scanner with given options
|
||||
- **Methods (Enumeration Phase)**
|
||||
- `(*Scanner) EnumerateFile(path string) error` - Enumerates a single file, calling stat() for metadata
|
||||
- `(*Scanner) EnumeratePath(inputPath string, progress chan<- EnumerateStatus) error` - Walks a directory and enumerates all files
|
||||
- `(*Scanner) EnumeratePaths(progress chan<- EnumerateStatus, inputPaths ...string) error` - Walks multiple directories
|
||||
- `(*Scanner) EnumerateFS(afs afero.Fs, basePath string, progress chan<- EnumerateStatus) error` - Walks an afero filesystem
|
||||
- **Methods (Accessors)**
|
||||
- `(*Scanner) Files() []*FileEntry` - Returns copy of all enumerated files
|
||||
- `(*Scanner) FileCount() int64` - Returns number of files
|
||||
- `(*Scanner) TotalBytes() int64` - Returns total size of all files
|
||||
- **Methods (Scan Phase)**
|
||||
- `(*Scanner) ToManifest(ctx context.Context, w io.Writer, progress chan<- ScanStatus) error` - Reads file contents, computes hashes, generates manifest
|
||||
|
||||
## internal/checker/
|
||||
|
||||
### checker.go
|
||||
|
||||
- **Types**
|
||||
- `Result struct` - Outcome of checking a single file
|
||||
- `Path string` - File path from manifest
|
||||
- `Status Status` - Verification status
|
||||
- `Message string` - Error or status message
|
||||
- `Status int` - Verification status enumeration
|
||||
- `StatusOK` - File matches manifest
|
||||
- `StatusMissing` - File not found
|
||||
- `StatusSizeMismatch` - File size differs from manifest
|
||||
- `StatusHashMismatch` - File hash differs from manifest
|
||||
- `StatusError` - Error occurred during verification
|
||||
- `CheckStatus struct` - Progress information for check operation
|
||||
- `TotalFiles int64`
|
||||
- `CheckedFiles int64`
|
||||
- `TotalBytes int64`
|
||||
- `CheckedBytes int64`
|
||||
- `BytesPerSec float64`
|
||||
- `ETA time.Duration`
|
||||
- `Failures int64`
|
||||
- `Checker struct` - Verifies files against a manifest
|
||||
- **Functions**
|
||||
- `NewChecker(manifestPath string, basePath string) (*Checker, error)` - Creates a new Checker for the given manifest and base path
|
||||
- **Methods**
|
||||
- `(s Status) String() string` - Returns string representation of status
|
||||
- `(*Checker) FileCount() int64` - Returns number of files in the manifest
|
||||
- `(*Checker) TotalBytes() int64` - Returns total size of all files in manifest
|
||||
- `(*Checker) Check(ctx context.Context, results chan<- Result, progress chan<- CheckStatus) error` - Verifies all files against the manifest
|
||||
|
||||
## mfer/
|
||||
|
||||
### manifest.go
|
||||
|
||||
- **Types**
|
||||
- `manifest struct` - Internal representation of a manifest file
|
||||
- **Methods**
|
||||
- `(*manifest) Files() []*MFFilePath` - Returns all file entries from a loaded manifest
|
||||
|
||||
### builder.go
|
||||
|
||||
- **Types**
|
||||
- `FileHashProgress struct` - Progress info during file hashing (BytesRead int64)
|
||||
- `Builder struct` - Constructs manifests by adding files one at a time
|
||||
- **Functions**
|
||||
- `NewBuilder() *Builder` - Creates a new Builder
|
||||
- **Methods**
|
||||
- `(*Builder) AddFile(path string, size int64, mtime time.Time, reader io.Reader, progress chan<- FileHashProgress) (int64, error)` - Reads file, computes hash, adds to manifest
|
||||
- `(*Builder) AddFileWithHash(path string, size int64, mtime time.Time, hash []byte) error` - Adds file with pre-computed hash
|
||||
- `(*Builder) FileCount() int` - Returns number of files added
|
||||
- `(*Builder) Build(w io.Writer) error` - Finalizes and writes manifest
|
||||
|
||||
### serialize.go
|
||||
|
||||
- **Constants**
|
||||
- `MAGIC string` - Magic bytes prefix for manifest files ("ZNAVSRFG")
|
||||
|
||||
### deserialize.go
|
||||
|
||||
- **Functions**
|
||||
- `NewManifestFromReader(input io.Reader) (*manifest, error)` - Reads and parses manifest from io.Reader
|
||||
- `NewManifestFromFile(fs afero.Fs, path string) (*manifest, error)` - Reads and parses manifest from file path
|
||||
|
||||
### mf.pb.go (generated from mf.proto)
|
||||
|
||||
- **Enum Types**
|
||||
- `MFFileOuter_Version` - Outer file format version
|
||||
- `MFFileOuter_VERSION_NONE`
|
||||
- `MFFileOuter_VERSION_ONE`
|
||||
- `MFFileOuter_CompressionType` - Compression type for inner message
|
||||
- `MFFileOuter_COMPRESSION_NONE`
|
||||
- `MFFileOuter_COMPRESSION_ZSTD`
|
||||
- `MFFile_Version` - Inner file format version
|
||||
- `MFFile_VERSION_NONE`
|
||||
- `MFFile_VERSION_ONE`
|
||||
- **Message Types**
|
||||
- `Timestamp struct` - Timestamp with seconds and nanoseconds
|
||||
- `GetSeconds() int64`
|
||||
- `GetNanos() int32`
|
||||
- `MFFileOuter struct` - Outer wrapper containing compressed/signed inner message
|
||||
- `GetVersion() MFFileOuter_Version`
|
||||
- `GetCompressionType() MFFileOuter_CompressionType`
|
||||
- `GetSize() int64`
|
||||
- `GetSha256() []byte`
|
||||
- `GetInnerMessage() []byte`
|
||||
- `GetSignature() []byte`
|
||||
- `GetSigner() []byte`
|
||||
- `GetSigningPubKey() []byte`
|
||||
- `MFFilePath struct` - Individual file entry in manifest
|
||||
- `GetPath() string`
|
||||
- `GetSize() int64`
|
||||
- `GetHashes() []*MFFileChecksum`
|
||||
- `GetMimeType() string`
|
||||
- `GetMtime() *Timestamp`
|
||||
- `GetCtime() *Timestamp`
|
||||
- `GetAtime() *Timestamp`
|
||||
- `MFFileChecksum struct` - File checksum using multihash
|
||||
- `GetMultiHash() []byte`
|
||||
- `MFFile struct` - Inner manifest containing file list
|
||||
- `GetVersion() MFFile_Version`
|
||||
- `GetFiles() []*MFFilePath`
|
||||
- `GetCreatedAt() *Timestamp`
|
||||
|
||||
# Build Status
|
||||
|
||||
[](https://drone.datavi.be/sneak/mfer)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user