checksum

package
v0.6.19 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChecksumMismatch     = errors.New("checksum does not match")
	ErrChecksumsUnsupported = errors.New("version precedes checksums")
)
View Source
var (
	ErrChecksumNotFound    = errors.New("checksum not found")
	ErrConflictingChecksum = errors.New("conflicting checksum")
	ErrUnrecognizedFormat  = errors.New("unrecognized format")
)

Functions

func Compare

func Compare[T artifact.Artifact, U Checksums[T]](
	ctx context.Context,
	localArtifact artifact.Local[T],
	localChecksums artifact.Local[U],
) error

Compare takes a local executable archive and a local checksums file for executable archives and validates that the executable archive's checksum matches the expected value.

func Compute

func Compute[T artifact.Artifact](ctx context.Context, h hash.Hash, d artifact.Local[T]) (string, error)

Computes and returns the correct checksum of the specified archive.

func Extract

func Extract[T artifact.Artifact, U Checksums[T]](
	ctx context.Context,
	local artifact.Local[U],
	a T,
) (string, error)

Given a locally-available checksums file, find and return the checksum for the specified archive.

Types

type Checksums

type Checksums[T artifact.Artifact] interface {
	artifact.Artifact

	// Supports is a method to register which artifact the checksums are for.
	Supports(_ T)

	// Hash returns a 'hash.Hash' instance used to compute the checksum of the
	// supported artifact type.
	Hash() hash.Hash
}

An interface for an 'Artifact' representing a checksums file.

Jump to

Keyboard shortcuts

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