harness

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitSuccess           = 0
	ExitUsage             = 2
	ExitMissingDependency = 3
	ExitContractFailure   = 4
	ExitExecutionFailure  = 5
	ExitIOFailure         = 6
	ExitInternalFailure   = 7
)
View Source
const SummarySchemaVersion = "harness.v1"

Variables

This section is empty.

Functions

func ExitCodeFor

func ExitCodeFor(err error) int

func IsCode

func IsCode(err error, code FailureCode) bool

func NewFailure

func NewFailure(code FailureCode, message, hint string, retryable bool) error

func RenderSummary

func RenderSummary(summary CommandSummary, format string, noColor bool) (string, error)

func WrapFailure

func WrapFailure(code FailureCode, message, hint string, retryable bool, cause error) error

Types

type Artifact

type Artifact struct {
	Name string `json:"name,omitempty"`
	Kind string `json:"kind,omitempty"`
	Path string `json:"path,omitempty"`
}

type ArtifactSpec

type ArtifactSpec struct {
	Name        string `json:"name"`
	Kind        string `json:"kind,omitempty"`
	PathHint    string `json:"path_hint,omitempty"`
	Description string `json:"description,omitempty"`
}

type Capabilities

type Capabilities struct {
	SchemaVersion string              `json:"schema_version"`
	GlobalFlags   []FlagSpec          `json:"global_flags"`
	Commands      []CommandCapability `json:"commands"`
}

func DefaultCapabilities

func DefaultCapabilities() Capabilities

type CheckResult

type CheckResult struct {
	Name    string `json:"name"`
	Status  Status `json:"status"`
	Details string `json:"details,omitempty"`
}

type CommandCapability

type CommandCapability struct {
	Name        string         `json:"name"`
	Description string         `json:"description,omitempty"`
	Flags       []FlagSpec     `json:"flags,omitempty"`
	Artifacts   []ArtifactSpec `json:"artifacts,omitempty"`
}

type CommandInput

type CommandInput struct {
	Name        string
	SummaryPath string
	DryRun      bool
	Explain     bool
	Execute     ExecuteFunc
}

type CommandOutcome

type CommandOutcome struct {
	Checks    []CheckResult
	Failures  []Failure
	Artifacts []Artifact
	Data      any
}

type CommandSummary

type CommandSummary struct {
	SchemaVersion string        `json:"schema_version"`
	Command       string        `json:"command"`
	Status        Status        `json:"status"`
	StartedAt     time.Time     `json:"started_at"`
	FinishedAt    time.Time     `json:"finished_at"`
	DurationMs    int64         `json:"duration_ms"`
	Checks        []CheckResult `json:"checks,omitempty"`
	Failures      []Failure     `json:"failures,omitempty"`
	Artifacts     []Artifact    `json:"artifacts,omitempty"`
	Data          any           `json:"data,omitempty"`
}

func Run

func Run(input CommandInput) (CommandSummary, error)

type Context

type Context struct {
	DryRun  bool
	Explain bool
}

type ExecuteFunc

type ExecuteFunc func(ctx Context) (CommandOutcome, error)

type Failure

type Failure struct {
	Code      string `json:"code"`
	Message   string `json:"message"`
	Hint      string `json:"hint,omitempty"`
	Retryable bool   `json:"retryable"`
}

func FailureFromError

func FailureFromError(err error) Failure

type FailureCode

type FailureCode string
const (
	CodeUsage              FailureCode = "usage"
	CodeMissingDependency  FailureCode = "missing_dependency"
	CodeContractValidation FailureCode = "contract_validation"
	CodeExecution          FailureCode = "execution"
	CodeFileIO             FailureCode = "file_io"
	CodeInternal           FailureCode = "internal"
)

type FailureError

type FailureError struct {
	Failure Failure
	Cause   error
}

func (*FailureError) Error

func (e *FailureError) Error() string

func (*FailureError) Unwrap

func (e *FailureError) Unwrap() error

type FlagSpec

type FlagSpec struct {
	Name        string `json:"name"`
	Type        string `json:"type,omitempty"`
	Required    bool   `json:"required,omitempty"`
	Default     string `json:"default,omitempty"`
	Description string `json:"description,omitempty"`
}

type Status

type Status string
const (
	StatusOK   Status = "ok"
	StatusFail Status = "fail"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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