Documentation
¶
Overview ¶
Package checksum provides SHA256 checksum generation for bundle verification.
Used by component bundlers (GPU Operator, Network Operator, etc.) and deployers (Helm, ArgoCD) to generate checksums.txt files for integrity verification.
Usage:
err := checksum.GenerateChecksums(ctx, "/path/to/bundle", fileList)
if err != nil {
return err
}
The checksums.txt file format is compatible with sha256sum:
sha256sum -c checksums.txt
Index ¶
- Constants
- func CountEntries(bundleDir string) int
- func GenerateChecksums(ctx context.Context, bundleDir string, files []string) error
- func GetChecksumFilePath(bundleDir string) string
- func SHA256Raw(path string) ([]byte, error)
- func VerifyChecksums(bundleDir string) []string
- func VerifyChecksumsFromData(bundleDir string, data []byte) []string
Constants ¶
const ChecksumFileName = "checksums.txt"
ChecksumFileName is the standard name for checksum files.
Variables ¶
This section is empty.
Functions ¶
func CountEntries ¶ added in v0.8.0
CountEntries returns the number of entries in a checksums.txt file.
func GenerateChecksums ¶
GenerateChecksums creates a checksums.txt file containing SHA256 checksums for all provided files. The checksums are written relative to the bundle directory.
Parameters:
- ctx: Context for cancellation
- bundleDir: The base directory for relative path calculation
- files: List of absolute file paths to include in checksums
Returns an error if the context is canceled, any file cannot be read, or the checksums file cannot be written.
func GetChecksumFilePath ¶
GetChecksumFilePath returns the full path to the checksums.txt file in the given bundle directory.
func SHA256Raw ¶ added in v0.8.0
SHA256Raw computes a file's SHA256 digest using streaming I/O and returns the raw bytes. Does not load the entire file into memory.
func VerifyChecksums ¶ added in v0.8.0
VerifyChecksums reads a checksums.txt file and verifies each file's SHA256 digest. Returns a list of error descriptions for any mismatches or read failures. An empty return means all checksums are valid.
func VerifyChecksumsFromData ¶ added in v0.8.0
VerifyChecksumsFromData verifies checksums using pre-read checksums.txt content. This avoids re-reading the file, preventing TOCTOU races when the same data is also used for digest computation.
Types ¶
This section is empty.