stepcache

package
v0.0.42 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package stepcache builds a StepCache from config: off (the default, never hits) or dir (one marker file per passed key under a directory), and derives the content-addressed key a step is cached under.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinarySalt added in v0.0.32

func BinarySalt() (string, error)

BinarySalt is the hex SHA-256 of the running executable: the Config.Salt that ties cached passes to the build that judged them.

func Digest added in v0.0.20

func Digest(
	ctx context.Context,
	cb interfaces.Codebase,
	sel types.FileSelector,
) ([]byte, error)

Digest is the SHA-256 of the paths and contents of the files sel selects in cb, in path order: the inputs part of a step's Key.

func IsOff added in v0.0.19

func IsOff(c interfaces.StepCache) bool

IsOff reports whether c is the off cache (or nil), so a caller can skip computing keys nothing will ever look up.

func Key

func Key(inputs []byte, toolVersion string, args []string) string

Key is the hex SHA-256 of a step's inputs, its tool's version and its arguments. Each field is length-prefixed, so no two different field lists share a key.

func NewFromConfig

func NewFromConfig(cfg Config) (interfaces.StepCache, error)

NewFromConfig builds the cache cfg.Kind selects. An unknown kind, or KindDir with no Dir, is CodeInvalidInput. It does no I/O: a dir cache derives its salt on first use.

Types

type Config

type Config struct {
	// Kind selects the implementation; empty means KindOff.
	Kind Kind `yaml:"kind" mapstructure:"kind"`

	// Dir is KindDir's directory, created on the first Record.
	Dir string `yaml:"dir" mapstructure:"dir"`

	// Salt partitions KindDir's keys: a key recorded under one salt never hits under
	// another. A key covers a step's inputs and definition, not the code judging them, so
	// a caller salts with that code's build (BinarySalt) to stop a rebuilt checker
	// trusting its predecessor's passes. Empty is a salt of its own.
	Salt string `yaml:"salt" mapstructure:"salt"`

	// SaltDirs adds the paths and contents of every file under these directories to the
	// salt (a missing one adds nothing): the configuration a checker reads beyond its
	// own row.
	SaltDirs []string `yaml:"salt_dirs" mapstructure:"salt_dirs"`

	// SaltBinary adds the running executable's hash (BinarySalt) to the salt.
	SaltBinary bool `yaml:"salt_binary" mapstructure:"salt_binary"`
}

Config selects and locates the cache.

type Kind

type Kind string

Kind selects a StepCache implementation.

const (
	// KindOff never hits and records nothing (the default).
	KindOff Kind = "off"

	// KindDir records each passed key as a marker file under Config.Dir.
	KindDir Kind = "dir"
)

Jump to

Keyboard shortcuts

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