checksums

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeHash

func ComputeHash(filepath string, algorithm string) (string, error)

ComputeHash computes the hash of a file using the specified algorithm

Types

type EmbedMode

type EmbedMode string

EmbedMode represents the checksum acquisition mode

const (
	// EmbedModeDownload downloads checksum files from GitHub releases
	EmbedModeDownload EmbedMode = "download"
	// EmbedModeChecksumFile uses a local checksum file
	EmbedModeChecksumFile EmbedMode = "checksum-file"
	// EmbedModeCalculate downloads assets and calculates checksums
	EmbedModeCalculate EmbedMode = "calculate"
)

type Embedder

type Embedder struct {
	Mode         EmbedMode
	Version      string
	Spec         *spec.InstallSpec
	SpecAST      *ast.File
	ChecksumFile string
}

Embedder manages the process of embedding checksums

func (*Embedder) Embed

func (e *Embedder) Embed() error

Embed performs the checksum embedding process and returns the updated spec

type GitHubReleaseAsset added in v0.3.1

type GitHubReleaseAsset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
	// GitHub API sometimes includes digest information
	Digest string `json:"digest,omitempty"`
}

GitHubReleaseAsset represents a GitHub release asset

type GitHubReleaseResponse added in v0.3.1

type GitHubReleaseResponse struct {
	TagName string               `json:"tag_name"`
	Assets  []GitHubReleaseAsset `json:"assets"`
}

GitHubReleaseResponse represents a GitHub release API response

type Verifier added in v0.9.2

type Verifier struct {
	Spec    *spec.InstallSpec
	Version string
}

Verifier handles checksum verification for downloaded assets

func NewVerifier added in v0.9.2

func NewVerifier(spec *spec.InstallSpec, version string) *Verifier

NewVerifier creates a new checksum verifier

func (*Verifier) GetChecksum added in v0.9.2

func (v *Verifier) GetChecksum(ctx context.Context, filename string) (string, error)

GetChecksum retrieves the checksum for a given filename It first checks embedded checksums, then tries to download checksum file

func (*Verifier) VerifyFile added in v0.9.2

func (v *Verifier) VerifyFile(ctx context.Context, filepath, filename string) error

VerifyFile verifies a file against its expected checksum

Jump to

Keyboard shortcuts

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