99 lines
3.6 KiB
Go
99 lines
3.6 KiB
Go
// Package woodpecker is a minimal, focused client for the Woodpecker CI REST
|
|
// API. It only implements what the MCP tools need: authenticated GET requests
|
|
// against the API endpoints that are relevant for debugging pipelines.
|
|
package woodpecker
|
|
|
|
// Domain types mirroring the Woodpecker CI API payloads.
|
|
// Fields that the API may omit or return as null are pointers so the output
|
|
// JSON can distinguish "absent" from an empty value.
|
|
|
|
// Repo is a Woodpecker repository (project).
|
|
type Repo struct {
|
|
ID int64 `json:"id"`
|
|
ForgeRemoteID string `json:"forge_remote_id"`
|
|
Name string `json:"name"`
|
|
Owner string `json:"owner"`
|
|
FullName string `json:"full_name"`
|
|
DefaultBranch *string `json:"default_branch,omitempty"`
|
|
Private bool `json:"private"`
|
|
Trusted bool `json:"trusted"`
|
|
Active bool `json:"active"`
|
|
ConfigFile *string `json:"config_file,omitempty"`
|
|
Timeout *int64 `json:"timeout,omitempty"`
|
|
ForgeID int64 `json:"forge_id"`
|
|
}
|
|
|
|
// PipelineError is a linter/compiler issue reported for a pipeline.
|
|
type PipelineError struct {
|
|
Type string `json:"type"`
|
|
Message string `json:"message"`
|
|
IsWarning bool `json:"is_warning"`
|
|
Data any `json:"data,omitempty"`
|
|
}
|
|
|
|
// Step is a single step within a workflow.
|
|
type Step struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
UUID string `json:"uuid"`
|
|
Type string `json:"type"`
|
|
State string `json:"state"`
|
|
Error *string `json:"error,omitempty"`
|
|
ExitCode *int64 `json:"exit_code,omitempty"`
|
|
StartTime *int64 `json:"start_time,omitempty"`
|
|
EndTime *int64 `json:"end_time,omitempty"`
|
|
PipelineID int64 `json:"pipeline_id"`
|
|
}
|
|
|
|
// Workflow is a workflow within a pipeline; Children holds its steps.
|
|
type Workflow struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
State string `json:"state"`
|
|
Error *string `json:"error,omitempty"`
|
|
StartTime *int64 `json:"start_time,omitempty"`
|
|
EndTime *int64 `json:"end_time,omitempty"`
|
|
PipelineID int64 `json:"pipeline_id"`
|
|
Children []Step `json:"children,omitempty"`
|
|
}
|
|
|
|
// Pipeline is a Woodpecker pipeline (run of a commit).
|
|
type Pipeline struct {
|
|
ID int64 `json:"id"`
|
|
Number int64 `json:"number"`
|
|
Parent *int64 `json:"parent,omitempty"`
|
|
Event string `json:"event"`
|
|
Status string `json:"status"`
|
|
Errors []PipelineError `json:"errors,omitempty"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
StartedAt *int64 `json:"started_at,omitempty"`
|
|
FinishedAt *int64 `json:"finished_at,omitempty"`
|
|
Commit string `json:"commit"`
|
|
Branch string `json:"branch"`
|
|
Ref string `json:"ref"`
|
|
Title *string `json:"title,omitempty"`
|
|
Message *string `json:"message,omitempty"`
|
|
Author *string `json:"author,omitempty"`
|
|
AuthorEmail *string `json:"author_email,omitempty"`
|
|
Workflows []Workflow `json:"workflows,omitempty"`
|
|
}
|
|
|
|
// LogEntry is one line of step output. Data is base64-encoded UTF-8.
|
|
type LogEntry struct {
|
|
ID int64 `json:"id"`
|
|
StepID int64 `json:"step_id"`
|
|
Time int64 `json:"time"`
|
|
Line int64 `json:"line"`
|
|
Data *string `json:"data"`
|
|
Type int `json:"type"`
|
|
}
|
|
|
|
// Config is a pipeline configuration file (.woodpecker.yml). Data is
|
|
// base64-encoded UTF-8.
|
|
type Config struct {
|
|
Name string `json:"name"`
|
|
Data string `json:"data"`
|
|
Hash string `json:"hash"`
|
|
}
|