hook

package
v0.2.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfigInvalid    = errors.New("ticket hook config is invalid")
	ErrExecutionBlocked = errors.New("ticket hook blocked ticket progress")
)

Functions

This section is empty.

Types

type Definition

type Definition struct {
	Command   string
	Timeout   time.Duration
	Workdir   string
	OnFailure FailurePolicy
}

type Env

type Env struct {
	TicketID         uuid.UUID
	ProjectID        uuid.UUID
	TicketIdentifier string
	Workspace        string
	Repos            []Repo
	AgentName        string
	WorkflowType     string
	WorkflowFamily   string
	Attempt          int
	APIURL           string
	AgentToken       string
}

type Executor

type Executor interface {
	RunAll(ctx context.Context, hookName TicketHookName, hooks []Definition, env Env) ([]Result, error)
}

func NewRemoteShellExecutor

func NewRemoteShellExecutor(pool remoteSessionFactory, machine catalogdomain.Machine) Executor

func NewShellExecutor

func NewShellExecutor() Executor

type FailurePolicy

type FailurePolicy string
const (
	FailurePolicyBlock  FailurePolicy = "block"
	FailurePolicyWarn   FailurePolicy = "warn"
	FailurePolicyIgnore FailurePolicy = "ignore"
)

type Outcome

type Outcome string
const (
	OutcomePass    Outcome = "pass"
	OutcomeError   Outcome = "error"
	OutcomeTimeout Outcome = "timeout"
)

type RemoteShellExecutor

type RemoteShellExecutor struct {
	// contains filtered or unexported fields
}

func (*RemoteShellExecutor) RunAll

func (e *RemoteShellExecutor) RunAll(ctx context.Context, hookName TicketHookName, hooks []Definition, env Env) ([]Result, error)

type Repo

type Repo struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

type Result

type Result struct {
	Name             string         `json:"name"`
	HookName         TicketHookName `json:"hook_name"`
	Command          string         `json:"command"`
	WorkingDirectory string         `json:"working_directory"`
	Policy           FailurePolicy  `json:"policy"`
	Outcome          Outcome        `json:"outcome"`
	Duration         time.Duration  `json:"duration"`
	ExitCode         *int           `json:"exit_code,omitempty"`
	TimedOut         bool           `json:"timed_out"`
	Stdout           string         `json:"stdout,omitempty"`
	Stderr           string         `json:"stderr,omitempty"`
	Error            string         `json:"error,omitempty"`
}

type ShellExecutor

type ShellExecutor struct{}

func (*ShellExecutor) RunAll

func (e *ShellExecutor) RunAll(ctx context.Context, hookName TicketHookName, hooks []Definition, env Env) ([]Result, error)

type TicketHookName

type TicketHookName string
const (
	TicketHookOnClaim    TicketHookName = "on_claim"
	TicketHookOnStart    TicketHookName = "on_start"
	TicketHookOnComplete TicketHookName = "on_complete"
	TicketHookOnDone     TicketHookName = "on_done"
	TicketHookOnError    TicketHookName = "on_error"
	TicketHookOnCancel   TicketHookName = "on_cancel"
)

type TicketHooks

type TicketHooks struct {
	OnClaim    []Definition
	OnStart    []Definition
	OnComplete []Definition
	OnDone     []Definition
	OnError    []Definition
	OnCancel   []Definition
}

func ParseTicketHooks

func ParseTicketHooks(raw map[string]any) (TicketHooks, error)

Jump to

Keyboard shortcuts

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