checksum

package
v0.8.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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

View Source
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

func CountEntries(bundleDir string) int

CountEntries returns the number of entries in a checksums.txt file.

func GenerateChecksums

func GenerateChecksums(ctx context.Context, bundleDir string, files []string) error

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

func GetChecksumFilePath(bundleDir string) string

GetChecksumFilePath returns the full path to the checksums.txt file in the given bundle directory.

func SHA256Raw added in v0.8.0

func SHA256Raw(path string) ([]byte, error)

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

func VerifyChecksums(bundleDir string) []string

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

func VerifyChecksumsFromData(bundleDir string, data []byte) []string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL