Documentation
¶
Index ¶
- Constants
- func ExitCodeFor(err error) int
- func IsCode(err error, code FailureCode) bool
- func NewFailure(code FailureCode, message, hint string, retryable bool) error
- func RenderSummary(summary CommandSummary, format string, noColor bool) (string, error)
- func WrapFailure(code FailureCode, message, hint string, retryable bool, cause error) error
- type Artifact
- type ArtifactSpec
- type Capabilities
- type CheckResult
- type CommandCapability
- type CommandInput
- type CommandOutcome
- type CommandSummary
- type Context
- type ExecuteFunc
- type Failure
- type FailureCode
- type FailureError
- type FlagSpec
- type Status
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 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 ArtifactSpec ¶
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 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 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 ¶
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 ¶
func (*FailureError) Error ¶
func (e *FailureError) Error() string
func (*FailureError) Unwrap ¶
func (e *FailureError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.