woodpecker

package
v2.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const (
	EventPush       = "push"
	EventPull       = "pull_request"
	EventPullClosed = "pull_request_closed"
	EventTag        = "tag"
	EventRelease    = "release"
	EventDeploy     = "deployment"
	EventCron       = "cron"
	EventManual     = "manual"
)

Event values.

View Source
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"`
	Token       string `json:"token"`
	LastContact int64  `json:"last_contact"`
	Platform    string `json:"platform"`
	Backend     string `json:"backend"`
	Capacity    int32  `json:"capacity"`
	Version     string `json:"version"`
	NoSchedule  bool   `json:"no_schedule"`
}

Agent is the JSON data for an agent

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() ([]*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() ([]*Repo, error)

	// RepoListOpts returns a list of all repositories to which the user has
	// explicit access in the host system.
	RepoListOpts(bool) ([]*Repo, error)

	// RepoPost activates a repository.
	RepoPost(forgeRemoteID int64) (*Repo, error)

	// RepoPatch updates a repository.
	RepoPatch(repoID int64, repo *RepoPatch) (*Repo, error)

	// RepoMove moves the repository
	RepoMove(repoID int64, dst string) 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 by branch. An empty branch
	// will result in the default branch.
	PipelineLast(repoID int64, branch string) (*Pipeline, error)

	// PipelineList returns a list of recent pipelines for the
	// the specified repository.
	PipelineList(repoID int64) ([]*Pipeline, 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, params map[string]string) (*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)

	// PipelineKill force kills the running pipeline.
	PipelineKill(repoID, pipeline int64) 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, env string, params map[string]string) (*Pipeline, error)

	// LogsPurge purges the pipeline logs for the specified pipeline.
	LogsPurge(repoID, pipeline 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) ([]*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

	// Secret returns a secret by name.
	Secret(repoID int64, secret string) (*Secret, error)

	// SecretList returns a list of all repository secrets.
	SecretList(repoID int64) ([]*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) ([]*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() ([]*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) ([]*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.

func New

func New(uri string) Client

New returns a client at the specified url.

func NewClient

func NewClient(uri string, cli *http.Client) Client

NewClient returns a client at the specified url.

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_at"`
	Branch    string `json:"branch"`
}

Cron is the JSON data of a cron job

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_at,omitempty"`
	Started  int64  `json:"started_at,omitempty"`
	Finished int64  `json:"finished_at,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 {
	Stats struct {
		Workers       int `json:"worker_count"`
		Pending       int `json:"pending_count"`
		WaitingOnDeps int `json:"waiting_on_deps_count"`
		Running       int `json:"running_count"`
		Complete      int `json:"completed_count"`
	} `json:"stats"`
	Paused bool `json:"paused,omitempty"`
}

Info provides queue stats.

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 Org

type Org struct {
	ID     int64  `json:"id"`
	Name   string `json:"name"`
	IsUser bool   `json:"is_user"`
}

Org is the JSON data for an organization

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"`
	// Deprecated TODO remove in 3.x
	Enqueued  int64       `json:"enqueued_at"`
	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"`
	CloneURL  string      `json:"clone_url"`
	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 PipelineError struct {
	Type      string `json:"type"`
	Message   string `json:"message"`
	IsWarning bool   `json:"is_warning"`
	Data      any    `json:"data"`
}

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 Registry

type Registry struct {
	ID       int64  `json:"id"`
	Address  string `json:"address"`
	Username string `json:"username"`
	Password string `json:"password,omitempty"`
	// Deprecated
	Email string `json:"email"` // TODO remove in 3.x
	// Deprecated
	Token string `json:"token"` // TODO remove in 3.x
}

Registry represents a docker registry with credentials.

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"`
	DefaultBranch                string   `json:"default_branch,omitempty"`
	SCMKind                      string   `json:"scm,omitempty"`
	Timeout                      int64    `json:"timeout,omitempty"`
	Visibility                   string   `json:"visibility"`
	IsSCMPrivate                 bool     `json:"private"`
	IsTrusted                    bool     `json:"trusted"`
	IsGated                      bool     `json:"gated"`
	IsActive                     bool     `json:"active"`
	AllowPullRequests            bool     `json:"allow_pr"`
	Config                       string   `json:"config_file"`
	CancelPreviousPipelineEvents []string `json:"cancel_previous_pipeline_events"`
	NetrcOnlyTrusted             bool     `json:"netrc_only_trusted"`
}

Repo represents a repository.

type RepoPatch

type RepoPatch struct {
	Config          *string `json:"config_file,omitempty"`
	IsTrusted       *bool   `json:"trusted,omitempty"`
	IsGated         *bool   `json:"gated,omitempty"`
	Timeout         *int64  `json:"timeout,omitempty"`
	Visibility      *string `json:"visibility"`
	AllowPull       *bool   `json:"allow_pr,omitempty"`
	PipelineCounter *int    `json:"pipeline_counter,omitempty"`
}

RepoPatch defines a repository patch request.

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 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 StepType

type StepType string

StepType identifies the type of step

const (
	StepTypeClone    StepType = "clone"
	StepTypeService  StepType = "service"
	StepTypePlugin   StepType = "plugin"
	StepTypeCommands StepType = "commands"
	StepTypeCache    StepType = "cache"
)

type Task

type Task struct {
	ID           string            `json:"id"`
	Data         []byte            `json:"data"`
	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 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 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.

Jump to

Keyboard shortcuts

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