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 ¶
- func BinarySalt() (string, error)
- func Digest(ctx context.Context, cb interfaces.Codebase, sel types.FileSelector) ([]byte, error)
- func IsOff(c interfaces.StepCache) bool
- func Key(inputs []byte, toolVersion string, args []string) string
- func NewFromConfig(cfg Config) (interfaces.StepCache, error)
- type Config
- type Kind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinarySalt ¶ added in v0.0.32
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 ¶
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.