validate

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 300

DefaultTimeout is the per-command execution timeout in seconds.

Variables

This section is empty.

Functions

func List

func List(cfg *ProjectConfig, streams iostream.Streams) error

List prints all configured command names and their run strings.

func RunAll

func RunAll(ctx context.Context, workDir string, force bool, cfg *ProjectConfig, streams iostream.Streams) error

RunAll runs all configured commands with optional cache bypass.

func RunDryRun

func RunDryRun(cfg *ProjectConfig, name string, streams iostream.Streams) error

RunDryRun prints commands without executing them.

func RunInline

func RunInline(ctx context.Context, workDir, name, command string, force bool, streams iostream.Streams) error

RunInline runs an inline command string, caching the result under the given name.

func RunNamed

func RunNamed(ctx context.Context, workDir, name string, force bool, cfg *ProjectConfig, streams iostream.Streams) error

RunNamed runs a single named command from config with caching.

func RunRemote

func RunRemote(ctx context.Context, client *circleci.Client, cfg *ProjectConfig, sandboxID, _ string, streams iostream.Streams) error

RunRemote runs commands on a remote sandbox.

func SaveCommand

func SaveCommand(workDir, name, command string) error

SaveCommand upserts a command in .chunk/config.json.

func SaveProjectConfig

func SaveProjectConfig(workDir string, cfg *ProjectConfig) error

SaveProjectConfig writes the config back to .chunk/config.json.

func Status

func Status(workDir, name string, cfg *ProjectConfig, streams iostream.Streams) error

Status checks the cache for each command (or a single named command) and prints its status.

func WriteCache

func WriteCache(workDir, name, fileExt string, exitCode int, output string) error

WriteCache writes a result sentinel to the cache directory. fileExt optionally scopes the content hash to files matching the extension.

Types

type CachedResult

type CachedResult struct {
	Status      string `json:"status"` // "pass" or "fail"
	ExitCode    int    `json:"exitCode"`
	Output      string `json:"output"`
	ContentHash string `json:"contentHash"`
	Timestamp   int64  `json:"timestamp"`
}

CachedResult is the sentinel file format for validate command caching.

func CheckCache

func CheckCache(workDir, name, fileExt string) *CachedResult

CheckCache reads a cached result and returns it if the content hash still matches. fileExt optionally scopes the content hash to files matching the extension.

type Command

type Command struct {
	Name    string `json:"name"`
	Run     string `json:"run"`
	FileExt string `json:"fileExt,omitempty"`
	Timeout int    `json:"timeout,omitempty"`
}

type ProjectConfig

type ProjectConfig struct {
	Commands []Command `json:"commands"`
}

func LoadProjectConfig

func LoadProjectConfig(workDir string) (*ProjectConfig, error)

func (*ProjectConfig) FindCommand

func (c *ProjectConfig) FindCommand(name string) *Command

FindCommand returns the command with the given name, or nil if not found.

func (*ProjectConfig) HasCommands

func (c *ProjectConfig) HasCommands() bool

Jump to

Keyboard shortcuts

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