Documentation
¶
Index ¶
- Constants
- type Agent
- type ApprovalMode
- type Client
- type ClientError
- type Cron
- type CronListOptions
- type DeployOptions
- type Feed
- type Info
- type ListOptions
- type LogEntry
- type LogEntryType
- type LogLevel
- type Org
- type Pipeline
- type PipelineError
- type PipelineLastOptions
- type PipelineListOptions
- type PipelineOptions
- type PipelineStartOptions
- type QueueStats
- type Registry
- type RegistryListOptions
- type Repo
- type RepoListOptions
- type RepoMoveOptions
- type RepoPatch
- type RepoPostOptions
- type Secret
- type SecretListOptions
- type Step
- type StepType
- type Task
- type TrustedConfiguration
- type User
- type UserListOptions
- type Version
- type Workflow
Constants ¶
const ( EventPush = "push" EventPull = "pull_request" EventPullClosed = "pull_request_closed" EventPullEdited = "pull_request_edited" EventTag = "tag" EventRelease = "release" EventDeploy = "deployment" EventCron = "cron" EventManual = "manual" )
Event values.
const ( StatusBlocked = "blocked" StatusSkipped = "skipped" StatusPending = "pending" StatusRunning = "running" StatusSuccess = "success" StatusFailure = "failure" StatusKilled = "killed" StatusError = "error" )
Status values.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
ID int64 `json:"id"`
Created int64 `json:"created"`
Updated int64 `json:"updated"`
Name string `json:"name"`
OwnerID int64 `json:"owner_id"`
OrgID int64 `json:"org_id"`
Token string `json:"token"`
LastContact int64 `json:"last_contact"`
LastWork int64 `json:"last_work"`
Platform string `json:"platform"`
Backend string `json:"backend"`
Capacity int32 `json:"capacity"`
Version string `json:"version"`
NoSchedule bool `json:"no_schedule"`
CustomLabels map[string]string `json:"custom_labels"`
}
Agent is the JSON data for an agent.
type ApprovalMode ¶
type ApprovalMode string
var ( RequireApprovalNone ApprovalMode = "none" // require approval for no events RequireApprovalForks ApprovalMode = "forks" // require approval for PRs from forks RequireApprovalPullRequests ApprovalMode = "pull_requests" // require approval for all PRs (default) RequireApprovalAllEvents ApprovalMode = "all_events" // require approval for all events )
func (ApprovalMode) Valid ¶
func (mode ApprovalMode) Valid() bool
type Client ¶
type Client interface {
// SetClient sets the http.Client.
SetClient(*http.Client)
// SetAddress sets the server address.
SetAddress(string)
// Self returns the currently authenticated user.
Self() (*User, error)
// User returns a user by login.
User(string) (*User, error)
// UserList returns a list of all registered users.
UserList(opt UserListOptions) ([]*User, error)
// UserPost creates a new user account.
UserPost(*User) (*User, error)
// UserPatch updates a user account.
UserPatch(*User) (*User, error)
// UserDel deletes a user account.
UserDel(string) error
// Repo returns a repository by name.
Repo(repoID int64) (*Repo, error)
// RepoLookup returns a repository id by the owner and name.
RepoLookup(repoFullName string) (*Repo, error)
// RepoList returns a list of all repositories to which the user has explicit
// access in the host system.
RepoList(opt RepoListOptions) ([]*Repo, error)
// RepoPost activates a repository.
RepoPost(opt RepoPostOptions) (*Repo, error)
// RepoPatch updates a repository.
RepoPatch(repoID int64, repo *RepoPatch) (*Repo, error)
// RepoMove moves the repository
RepoMove(repoID int64, opt RepoMoveOptions) error
// RepoChown updates a repository owner.
RepoChown(repoID int64) (*Repo, error)
// RepoRepair repairs the repository hooks.
RepoRepair(repoID int64) error
// RepoDel deletes a repository.
RepoDel(repoID int64) error
// Pipeline returns a repository pipeline by number.
Pipeline(repoID, pipeline int64) (*Pipeline, error)
// PipelineLast returns the latest repository pipeline.
PipelineLast(repoID int64, opt PipelineLastOptions) (*Pipeline, error)
// PipelineList returns a list of recent pipelines for the
// the specified repository.
PipelineList(repoID int64, opt PipelineListOptions) ([]*Pipeline, error)
PipelineDelete(repoID, pipeline int64) error
// PipelineQueue returns a list of enqueued pipelines.
PipelineQueue() ([]*Feed, error)
// PipelineCreate returns creates a pipeline on specified branch.
PipelineCreate(repoID int64, opts *PipelineOptions) (*Pipeline, error)
// PipelineStart re-starts a stopped pipeline.
PipelineStart(repoID, num int64, opt PipelineStartOptions) (*Pipeline, error)
// PipelineStop stops the given pipeline.
PipelineStop(repoID, pipeline int64) error
// PipelineApprove approves a blocked pipeline.
PipelineApprove(repoID, pipeline int64) (*Pipeline, error)
// PipelineDecline declines a blocked pipeline.
PipelineDecline(repoID, pipeline int64) (*Pipeline, error)
// PipelineMetadata returns metadata for a pipeline.
PipelineMetadata(repoID int64, pipelineNumber int) ([]byte, error)
// StepLogEntries returns the LogEntries for the given pipeline step
StepLogEntries(repoID, pipeline, stepID int64) ([]*LogEntry, error)
// Deploy triggers a deployment for an existing pipeline using the specified
// target environment.
Deploy(repoID, pipeline int64, opt DeployOptions) (*Pipeline, error)
// LogsPurge purges the pipeline logs for the specified pipeline.
LogsPurge(repoID, pipeline int64) error
// StepLogsPurge purges the pipeline logs for the specified step.
StepLogsPurge(repoID, pipelineNumber, stepID int64) error
// Registry returns a registry by hostname.
Registry(repoID int64, hostname string) (*Registry, error)
// RegistryList returns a list of all repository registries.
RegistryList(repoID int64, opt RegistryListOptions) ([]*Registry, error)
// RegistryCreate creates a registry.
RegistryCreate(repoID int64, registry *Registry) (*Registry, error)
// RegistryUpdate updates a registry.
RegistryUpdate(repoID int64, registry *Registry) (*Registry, error)
// RegistryDelete deletes a registry.
RegistryDelete(repoID int64, hostname string) error
// OrgRegistry returns an organization registry by address.
OrgRegistry(orgID int64, registry string) (*Registry, error)
// OrgRegistryList returns a list of all organization registries.
OrgRegistryList(orgID int64, opt RegistryListOptions) ([]*Registry, error)
// OrgRegistryCreate creates an organization registry.
OrgRegistryCreate(orgID int64, registry *Registry) (*Registry, error)
// OrgRegistryUpdate updates an organization registry.
OrgRegistryUpdate(orgID int64, registry *Registry) (*Registry, error)
// OrgRegistryDelete deletes an organization registry.
OrgRegistryDelete(orgID int64, registry string) error
// GlobalRegistry returns an global registry by address.
GlobalRegistry(registry string) (*Registry, error)
// GlobalRegistryList returns a list of all global registries.
GlobalRegistryList(opt RegistryListOptions) ([]*Registry, error)
// GlobalRegistryCreate creates a global registry.
GlobalRegistryCreate(registry *Registry) (*Registry, error)
// GlobalRegistryUpdate updates a global registry.
GlobalRegistryUpdate(registry *Registry) (*Registry, error)
// GlobalRegistryDelete deletes a global registry.
GlobalRegistryDelete(registry string) error
// Secret returns a secret by name.
Secret(repoID int64, secret string) (*Secret, error)
// SecretList returns a list of all repository secrets.
SecretList(repoID int64, opt SecretListOptions) ([]*Secret, error)
// SecretCreate creates a secret.
SecretCreate(repoID int64, secret *Secret) (*Secret, error)
// SecretUpdate updates a secret.
SecretUpdate(repoID int64, secret *Secret) (*Secret, error)
// SecretDelete deletes a secret.
SecretDelete(repoID int64, secret string) error
// Org returns an organization by name.
Org(orgID int64) (*Org, error)
// OrgLookup returns an organization id by name.
OrgLookup(orgName string) (*Org, error)
// OrgSecret returns an organization secret by name.
OrgSecret(orgID int64, secret string) (*Secret, error)
// OrgSecretList returns a list of all organization secrets.
OrgSecretList(orgID int64, opt SecretListOptions) ([]*Secret, error)
// OrgSecretCreate creates an organization secret.
OrgSecretCreate(orgID int64, secret *Secret) (*Secret, error)
// OrgSecretUpdate updates an organization secret.
OrgSecretUpdate(orgID int64, secret *Secret) (*Secret, error)
// OrgSecretDelete deletes an organization secret.
OrgSecretDelete(orgID int64, secret string) error
// GlobalSecret returns an global secret by name.
GlobalSecret(secret string) (*Secret, error)
// GlobalSecretList returns a list of all global secrets.
GlobalSecretList(opt SecretListOptions) ([]*Secret, error)
// GlobalSecretCreate creates a global secret.
GlobalSecretCreate(secret *Secret) (*Secret, error)
// GlobalSecretUpdate updates a global secret.
GlobalSecretUpdate(secret *Secret) (*Secret, error)
// GlobalSecretDelete deletes a global secret.
GlobalSecretDelete(secret string) error
// QueueInfo returns the queue state.
QueueInfo() (*Info, error)
// LogLevel returns the current logging level.
LogLevel() (*LogLevel, error)
// SetLogLevel sets the server's logging level.
SetLogLevel(logLevel *LogLevel) (*LogLevel, error)
// CronList list all cron jobs of a repo.
CronList(repoID int64, opt CronListOptions) ([]*Cron, error)
// CronGet get a specific cron job of a repo by id.
CronGet(repoID, cronID int64) (*Cron, error)
// CronDelete delete a specific cron job of a repo by id.
CronDelete(repoID, cronID int64) error
// CronCreate create a new cron job in a repo.
CronCreate(repoID int64, cron *Cron) (*Cron, error)
// CronUpdate update an existing cron job of a repo.
CronUpdate(repoID int64, cron *Cron) (*Cron, error)
// AgentList returns a list of all registered agents.
AgentList() ([]*Agent, error)
// Agent returns an agent by id.
Agent(int64) (*Agent, error)
// AgentCreate creates a new agent.
AgentCreate(*Agent) (*Agent, error)
// AgentUpdate updates an existing agent.
AgentUpdate(*Agent) (*Agent, error)
// AgentDelete deletes an agent.
AgentDelete(int64) error
// AgentTasksList returns a list of all tasks executed by an agent.
AgentTasksList(int64) ([]*Task, error)
}
Client is used to communicate with a Woodpecker server.
type ClientError ¶
func (*ClientError) Error ¶
func (e *ClientError) Error() string
type Cron ¶
type Cron struct {
ID int64 `json:"id"`
Name string `json:"name"`
RepoID int64 `json:"repo_id"`
CreatorID int64 `json:"creator_id"`
NextExec int64 `json:"next_exec"`
Schedule string `json:"schedule"`
Created int64 `json:"created"`
Branch string `json:"branch"`
}
Cron is the JSON data of a cron job.
type CronListOptions ¶
type CronListOptions struct {
ListOptions
}
type DeployOptions ¶
type DeployOptions struct {
DeployTo string // override the target deploy value
Params map[string]string // custom KEY=value parameters to be injected into the step environment
}
func (*DeployOptions) QueryEncode ¶
func (opt *DeployOptions) QueryEncode() string
QueryEncode returns the URL query parameters for the DeployOptions.
type Feed ¶
type Feed struct {
RepoID int64 `json:"repo_id"`
ID int64 `json:"id,omitempty"`
Number int64 `json:"number,omitempty"`
Event string `json:"event,omitempty"`
Status string `json:"status,omitempty"`
Created int64 `json:"created,omitempty"`
Started int64 `json:"started,omitempty"`
Finished int64 `json:"finished,omitempty"`
Commit string `json:"commit,omitempty"`
Branch string `json:"branch,omitempty"`
Ref string `json:"ref,omitempty"`
Refspec string `json:"refspec,omitempty"`
Remote string `json:"remote,omitempty"`
Title string `json:"title,omitempty"`
Message string `json:"message,omitempty"`
Author string `json:"author,omitempty"`
Avatar string `json:"author_avatar,omitempty"`
Email string `json:"author_email,omitempty"`
}
Feed represents an item in the user's feed or timeline.
type Info ¶
type Info struct {
Pending []Task `json:"pending"`
WaitingOnDeps []Task `json:"waiting_on_deps"`
Running []Task `json:"running"`
Stats QueueStats `json:"stats"`
Paused bool `json:"paused,omitempty"`
}
Info provides queue stats.
type ListOptions ¶
ListOptions represents the options for the Woodpecker API pagination.
type LogEntry ¶
type LogEntry struct {
ID int64 `json:"id"`
StepID int64 `json:"step_id"`
Time int64 `json:"time"`
Line int `json:"line"`
Data []byte `json:"data"`
Type LogEntryType `json:"type"`
}
LogEntry is a single log entry.
type LogEntryType ¶
type LogEntryType int
LogEntryType identifies the type of line in the logs.
const ( LogEntryStdout LogEntryType = iota LogEntryStderr LogEntryExitCode LogEntryMetadata LogEntryProgress )
type LogLevel ¶
type LogLevel struct {
Level string `json:"log-level"`
}
LogLevel is for checking/setting logging level.
type Pipeline ¶
type Pipeline struct {
ID int64 `json:"id"`
Number int64 `json:"number"`
Parent int64 `json:"parent"`
Event string `json:"event"`
Status string `json:"status"`
Errors []*PipelineError `json:"errors"`
Created int64 `json:"created_at"`
Updated int64 `json:"updated_at"`
Started int64 `json:"started_at"`
Finished int64 `json:"finished_at"`
Deploy string `json:"deploy_to"`
Commit string `json:"commit"`
Branch string `json:"branch"`
Ref string `json:"ref"`
Refspec string `json:"refspec"`
Title string `json:"title"`
Message string `json:"message"`
Timestamp int64 `json:"timestamp"`
Sender string `json:"sender"`
Author string `json:"author"`
Avatar string `json:"author_avatar"`
Email string `json:"author_email"`
ForgeURL string `json:"forge_url"`
Reviewer string `json:"reviewed_by"`
Reviewed int64 `json:"reviewed_at"`
Workflows []*Workflow `json:"workflows,omitempty"`
}
Pipeline defines a pipeline object.
type PipelineError ¶
type PipelineLastOptions ¶
type PipelineLastOptions struct {
Branch string // last pipeline from given branch, an empty branch will result in the default branch
}
func (*PipelineLastOptions) QueryEncode ¶
func (opt *PipelineLastOptions) QueryEncode() string
QueryEncode returns the URL query parameters for the PipelineLastOptions.
type PipelineListOptions ¶
type PipelineListOptions struct {
ListOptions
Before time.Time
After time.Time
Branch string
Events []string
RefContains string
Status string
}
func (*PipelineListOptions) QueryEncode ¶
func (opt *PipelineListOptions) QueryEncode() string
QueryEncode returns the URL query parameters for the PipelineListOptions.
type PipelineOptions ¶
type PipelineOptions struct {
Branch string `json:"branch"`
Variables map[string]string `json:"variables"`
}
PipelineOptions is the JSON data for creating a new pipeline.
type PipelineStartOptions ¶
type PipelineStartOptions struct {
Params map[string]string // custom KEY=value parameters to be injected into the step environment
}
func (*PipelineStartOptions) QueryEncode ¶
func (opt *PipelineStartOptions) QueryEncode() string
QueryEncode returns the URL query parameters for the PipelineStartOptions.
type QueueStats ¶
type Registry ¶
type Registry struct {
ID int64 `json:"id"`
OrgID int64 `json:"org_id"`
RepoID int64 `json:"repo_id"`
Address string `json:"address"`
Username string `json:"username"`
Password string `json:"password,omitempty"`
}
Registry represents a docker registry with credentials.
type RegistryListOptions ¶
type RegistryListOptions struct {
ListOptions
}
type Repo ¶
type Repo struct {
ID int64 `json:"id,omitempty"`
ForgeRemoteID string `json:"forge_remote_id"`
Owner string `json:"owner"`
Name string `json:"name"`
FullName string `json:"full_name"`
Avatar string `json:"avatar_url,omitempty"`
ForgeURL string `json:"forge_url,omitempty"`
Clone string `json:"clone_url,omitempty"`
Branch string `json:"default_branch,omitempty"`
SCMKind string `json:"scm,omitempty"`
Timeout int64 `json:"timeout,omitempty"`
Visibility string `json:"visibility"`
IsSCMPrivate bool `json:"private"`
Trusted TrustedConfiguration `json:"trusted"`
RequireApproval ApprovalMode `json:"require_approval"`
IsActive bool `json:"active"`
AllowPull bool `json:"allow_pr"`
Config string `json:"config_file"`
CancelPreviousPipelineEvents []string `json:"cancel_previous_pipeline_events"`
NetrcTrustedPlugins []string `json:"netrc_trusted"`
LogsPipelinesKeepMin int64 `json:"logs_keep_min"`
LogsDurationKeep string `json:"logs_keep_duration"`
}
Repo represents a repository.
type RepoListOptions ¶
type RepoListOptions struct {
All bool // query all repos, including inactive ones
}
func (*RepoListOptions) QueryEncode ¶
func (opt *RepoListOptions) QueryEncode() string
QueryEncode returns the URL query parameters for the RepoListOptions.
type RepoMoveOptions ¶
type RepoMoveOptions struct {
To string
}
func (*RepoMoveOptions) QueryEncode ¶
func (opt *RepoMoveOptions) QueryEncode() string
QueryEncode returns the URL query parameters for the RepoMoveOptions.
type RepoPatch ¶
type RepoPatch struct {
Config *string `json:"config_file,omitempty"`
IsTrusted *bool `json:"trusted,omitempty"`
RequireApproval *ApprovalMode `json:"require_approval,omitempty"`
Timeout *int64 `json:"timeout,omitempty"`
Visibility *string `json:"visibility"`
AllowPull *bool `json:"allow_pr,omitempty"`
PipelineCounter *int `json:"pipeline_counter,omitempty"`
LogsPipelinesKeepMin *int64 `json:"logs_keep_min"`
LogsDurationKeep *string `json:"logs_keep_duration"`
}
RepoPatch defines a repository patch request.
type RepoPostOptions ¶
type RepoPostOptions struct {
ForgeRemoteID int64
}
func (*RepoPostOptions) QueryEncode ¶
func (opt *RepoPostOptions) QueryEncode() string
QueryEncode returns the URL query parameters for the RepoPostOptions.
type Secret ¶
type Secret struct {
ID int64 `json:"id"`
OrgID int64 `json:"org_id"`
RepoID int64 `json:"repo_id"`
Name string `json:"name"`
Value string `json:"value,omitempty"`
Images []string `json:"images"`
Events []string `json:"events"`
}
Secret represents a secret variable, such as a password or token.
type SecretListOptions ¶
type SecretListOptions struct {
ListOptions
}
type Step ¶
type Step struct {
ID int64 `json:"id"`
PID int `json:"pid"`
PPID int `json:"ppid"`
Name string `json:"name"`
State string `json:"state"`
Error string `json:"error,omitempty"`
ExitCode int `json:"exit_code"`
Started int64 `json:"start_time,omitempty"`
Stopped int64 `json:"end_time,omitempty"`
Type StepType `json:"type,omitempty"`
}
Step represents a process in the pipeline.
type Task ¶
type Task struct {
ID string `json:"id"`
Labels map[string]string `json:"labels"`
Dependencies []string `json:"dependencies"`
RunOn []string `json:"run_on"`
DepStatus map[string]string `json:"dep_status"`
AgentID int64 `json:"agent_id"`
}
Task is the JSON data for a task.
type TrustedConfiguration ¶
type User ¶
type User struct {
ID int64 `json:"id"`
Login string `json:"login"`
Email string `json:"email"`
Avatar string `json:"avatar_url"`
Active bool `json:"active"`
Admin bool `json:"admin"`
}
User represents a user account.
type UserListOptions ¶
type UserListOptions struct {
ListOptions
}
type Version ¶
type Version struct {
Source string `json:"source,omitempty"`
Version string `json:"version,omitempty"`
Commit string `json:"commit,omitempty"`
}
Version provides system version details.
type Workflow ¶
type Workflow struct {
ID int64 `json:"id"`
PID int `json:"pid"`
Name string `json:"name"`
State string `json:"state"`
Error string `json:"error,omitempty"`
Started int64 `json:"start_time,omitempty"`
Stopped int64 `json:"end_time,omitempty"`
AgentID int64 `json:"agent_id,omitempty"`
Platform string `json:"platform,omitempty"`
Environ map[string]string `json:"environ,omitempty"`
Children []*Step `json:"children,omitempty"`
}
Workflow represents a workflow in the pipeline.