drone

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: Apache-2.0 Imports: 9 Imported by: 245

Documentation

Index

Constants

View Source
const (
	EventPush        = "push"
	EventPullRequest = "pull_request"
	EventTag         = "tag"
	EventPromote     = "promote"
	EventRollback    = "rollback"
)

Event values.

View Source
const (
	StatusSkipped  = "skipped"
	StatusBlocked  = "blocked"
	StatusDeclined = "declined"
	StatusWaiting  = "waiting_on_dependencies"
	StatusPending  = "pending"
	StatusRunning  = "running"
	StatusPassing  = "success"
	StatusFailing  = "failure"
	StatusKilled   = "killed"
	StatusError    = "error"
)

Status values.

Variables

This section is empty.

Functions

This section is empty.

Types

type Build

type Build struct {
	ID           int64             `json:"id"`
	RepoID       int64             `json:"repo_id"`
	Trigger      string            `json:"trigger"`
	Number       int64             `json:"number"`
	Parent       int64             `json:"parent,omitempty"`
	Status       string            `json:"status"`
	Error        string            `json:"error,omitempty"`
	Event        string            `json:"event"`
	Action       string            `json:"action"`
	Link         string            `json:"link"`
	Timestamp    int64             `json:"timestamp"`
	Title        string            `json:"title,omitempty"`
	Message      string            `json:"message"`
	Before       string            `json:"before"`
	After        string            `json:"after"`
	Ref          string            `json:"ref"`
	Fork         string            `json:"source_repo"`
	Source       string            `json:"source"`
	Target       string            `json:"target"`
	Author       string            `json:"author_login"`
	AuthorName   string            `json:"author_name"`
	AuthorEmail  string            `json:"author_email"`
	AuthorAvatar string            `json:"author_avatar"`
	Sender       string            `json:"sender"`
	Params       map[string]string `json:"params,omitempty"`
	Cron         string            `json:"cron,omitempty"`
	Deploy       string            `json:"deploy_to,omitempty"`
	DeployID     int64             `json:"deploy_id,omitempty"`
	Debug        bool              `json:"debug"`
	Started      int64             `json:"started"`
	Finished     int64             `json:"finished"`
	Created      int64             `json:"created"`
	Updated      int64             `json:"updated"`
	Version      int64             `json:"version"`
	Stages       []*Stage          `json:"stages,omitempty"`
}

Build defines a build object.

type CardInput added in v1.7.1

type CardInput struct {
	Schema string          `json:"schema"`
	Data   json.RawMessage `json:"data"`
}

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(login string) (*User, error)

	// UserList returns a list of all registered users.
	UserList() ([]*User, error)

	// UserCreate creates a new user account.
	UserCreate(user *User) (*User, error)

	// UserUpdate updates a user account.
	UserUpdate(login string, user *UserPatch) (*User, error)

	// UserDelete deletes a user account.
	UserDelete(login string) error

	// Incomplete returns a list of incomplete builds.
	Incomplete() ([]*Repo, error)

	// IncompleteV2 returns a list of builds/repos/stages that are running/pending.
	IncompleteV2() ([]*RepoBuildStage, error)

	// Repo returns a repository by name.
	Repo(namespace, name string) (*Repo, error)

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

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

	// RepoListAll returns a list of all repositories in
	// the database. This is only available to system admins.
	RepoListAll(opts ListOptions) ([]*Repo, error)

	// RepoEnable activates a repository.
	RepoEnable(namespace, name string) (*Repo, error)

	// RepoUpdate updates a repository.
	RepoUpdate(namespace, name string, repo *RepoPatch) (*Repo, error)

	// RepoChown updates a repository owner.
	RepoChown(namespace, name string) (*Repo, error)

	// RepoRepair repairs the repository hooks.
	RepoRepair(namespace, name string) error

	// RepoDisable disables a repository.
	RepoDisable(namespace, name string) error

	// RepoDelete permanetnly deletes a repository.
	RepoDelete(namespace, name string) error

	// Build returns a repository build by number.
	Build(namespace, name string, build int) (*Build, error)

	// BuildLast returns the latest build by branch. An
	// empty branch will result in the default branch.
	BuildLast(namespace, name, branch string) (*Build, error)

	// BuildList returns a list of recent builds for the
	// the specified repository.
	BuildList(namespace, name string, opts ListOptions) ([]*Build, error)

	// BuildCreate creates a new build by branch or commit.
	BuildCreate(owner, name, commit, branch string, params map[string]string) (*Build, error)

	// BuildRestart re-starts a build.
	BuildRestart(namespace, name string, build int, params map[string]string) (*Build, error)

	// BuildCancel stops the specified running job for
	// given build.
	BuildCancel(namespace, name string, build int) error

	// BuildPurge purges the build history.
	BuildPurge(namespace, name string, before int) error

	// Approve approves a blocked build stage.
	Approve(namespace, name string, build, stage int) error

	// Decline declines a blocked build stage.
	Decline(namespace, name string, build, stage int) error

	// Promote promotes a build to the target environment.
	Promote(namespace, name string, build int, target string, params map[string]string) (*Build, error)

	// Rollback reverts the target environment to an previous build.
	Rollback(namespace, name string, build int, target string, params map[string]string) (*Build, error)

	// Logs gets the logs for the specified step.
	Logs(owner, name string, build, stage, step int) ([]*Line, error)

	// LogsPurge purges the build logs for the specified step.
	LogsPurge(owner, name string, build, stage, step int) error

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

	// SecretList returns a list of all repository secrets.
	SecretList(owner, name string) ([]*Secret, error)

	// SecretCreate creates a registry.
	SecretCreate(owner, name string, secret *Secret) (*Secret, error)

	// SecretUpdate updates a registry.
	SecretUpdate(owner, name string, secret *Secret) (*Secret, error)

	// SecretDelete deletes a secret.
	SecretDelete(owner, name, secret string) error

	// OrgSecret returns a secret by name.
	OrgSecret(namespace, secret string) (*Secret, error)

	// OrgSecretList returns a list of all repository secrets.
	OrgSecretList(namespace string) ([]*Secret, error)

	// OrgSecretListAll returns a list of all repository secrets.
	OrgSecretListAll() ([]*Secret, error)

	// OrgSecretCreate creates a registry.
	OrgSecretCreate(namespace string, secret *Secret) (*Secret, error)

	// OrgSecretUpdate updates a registry.
	OrgSecretUpdate(namespace string, secret *Secret) (*Secret, error)

	// OrgSecretDelete deletes a secret.
	OrgSecretDelete(namespace, name string) error

	// Cron returns a cronjob by name.
	Cron(owner, name, cron string) (*Cron, error)

	// CronList returns a list of all repository cronjobs.
	CronList(owner string, name string) ([]*Cron, error)

	// CronCreate creates a cronjob.
	CronCreate(owner, name string, in *Cron) (*Cron, error)

	// CronDelete deletes a cronjob.
	CronDelete(owner, name, cron string) error

	// CronUpdate enables a cronjob.
	CronUpdate(owner, name, cron string, in *CronPatch) (*Cron, error)

	// CronExec executes a cronjob.
	CronExec(owner, name, cron string) error

	// Sign signs the yaml file.
	Sign(owner, name, file string) (string, error)

	// Verify verifies the yaml signature.
	Verify(owner, name, file string) error

	// Encrypt returns an encrypted secret
	Encrypt(owner, name string, secret *Secret) (string, error)

	// Queue returns a list of queue items.
	Queue() ([]*Stage, error)

	// QueuePause pauses queue operations.
	QueuePause() error

	// QueueResume resumes queue operations.
	QueueResume() error

	// Node returns a node by name.
	Node(name string) (*Node, error)

	// NodeList returns a list of all nodes.
	NodeList() ([]*Node, error)

	// NodeCreate creates a node.
	NodeCreate(in *Node) (*Node, error)

	// NodeDelete deletes a node.
	NodeDelete(name string) error

	// NodeUpdate updates a node.
	NodeUpdate(name string, in *NodePatch) (*Node, error)

	// Server returns the named servers details.
	Server(name string) (*Server, error)

	// ServerList returns a list of all active build servers.
	ServerList() ([]*Server, error)

	// ServerCreate creates a new server.
	ServerCreate() (*Server, error)

	// ServerDelete terminates a server.
	ServerDelete(name string, force bool) error

	// AutoscalePause pauses the autoscaler.
	AutoscalePause() error

	// AutoscaleResume resumes the autoscaler.
	AutoscaleResume() error

	// AutoscaleVersion returns the autoscaler version.
	AutoscaleVersion() (*Version, error)

	// Template returns a template by name.
	Template(namespace string, name string) (*Template, error)

	// TemplateListAll returns a list of all templates.
	TemplateListAll() ([]*Template, error)

	// TemplateList returns a list of all templates by namespace
	TemplateList(namespace string) ([]*Template, error)

	// TemplateCreate creates a template.
	TemplateCreate(namespace string, template *Template) (*Template, error)

	// TemplateUpdate updates template data.
	TemplateUpdate(namespace string, name string, template *Template) (*Template, error)

	// TemplateDelete deletes a template.
	TemplateDelete(namespace string, name string) error
}

Client is used to communicate with a Drone 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 Config added in v1.0.0

type Config struct {
	Data string `json:"data"`
	Kind string `json:"kind"`
}

Config represents a config file.

type Cron added in v1.0.0

type Cron struct {
	ID       int64  `json:"id"`
	RepoID   int64  `json:"repo_id"`
	Name     string `json:"name"`
	Expr     string `json:"expr"`
	Next     int64  `json:"next"`
	Prev     int64  `json:"prev"`
	Event    string `json:"event"`
	Branch   string `json:"branch"`
	Target   string `json:"target"`
	Disabled bool   `json:"disabled"`
	Created  int64  `json:"created"`
	Updated  int64  `json:"updated"`
}

Cron represents a cron job.

type CronPatch added in v1.0.0

type CronPatch struct {
	Event    *string `json:"event"`
	Branch   *string `json:"branch"`
	Target   *string `json:"target"`
	Disabled *bool   `json:"disabled"`
}

CronPatch defines a cron patch request.

type Error added in v1.0.0

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error represents a json-encoded API error.

func (*Error) Error added in v1.0.0

func (e *Error) Error() string

type Line added in v1.0.0

type Line struct {
	Number    int    `json:"pos"`
	Message   string `json:"out"`
	Timestamp int64  `json:"time"`
}

Line represents a line of container logs.

type ListOptions added in v1.0.0

type ListOptions struct {
	Page int
	Size int
}

type Netrc added in v1.0.5

type Netrc struct {
	Machine  string `json:"machine"`
	Login    string `json:"login"`
	Password string `json:"password"`
}

Netrc contains login and initialization information used by an automated login process.

type Node added in v1.0.0

type Node struct {
	ID        int64             `json:"id"`
	UID       string            `json:"uid"`
	Provider  string            `json:"provider"`
	State     string            `json:"state"`
	Name      string            `json:"name"`
	Image     string            `json:"image"`
	Region    string            `json:"region"`
	Size      string            `json:"size"`
	OS        string            `json:"os"`
	Arch      string            `json:"arch"`
	Kernel    string            `json:"kernel"`
	Variant   string            `json:"variant"`
	Address   string            `json:"address"`
	Capacity  int               `json:"capacity"`
	Filters   []string          `json:"filters"`
	Labels    map[string]string `json:"labels"`
	Error     string            `json:"error"`
	CAKey     []byte            `json:"ca_key"`
	CACert    []byte            `json:"ca_cert"`
	TLSKey    []byte            `json:"tls_key"`
	TLSCert   []byte            `json:"tls_cert"`
	TLSName   string            `json:"tls_name"`
	Paused    bool              `json:"paused"`
	Protected bool              `json:"protected"`
	Created   int64             `json:"created"`
	Updated   int64             `json:"updated"`
}

Node provides node details.

type NodePatch added in v1.0.0

type NodePatch struct {
	UID       *string            `json:"uid"`
	Provider  *string            `json:"provider"`
	State     *string            `json:"state"`
	Image     *string            `json:"image"`
	Region    *string            `json:"region"`
	Size      *string            `json:"size"`
	Address   *string            `json:"address"`
	Capacity  *int               `json:"capacity"`
	Filters   *[]string          `json:"filters"`
	Labels    *map[string]string `json:"labels"`
	Error     *string            `json:"error"`
	CAKey     *[]byte            `json:"ca_key"`
	CACert    *[]byte            `json:"ca_cert"`
	TLSKey    *[]byte            `json:"tls_key"`
	TLSCert   *[]byte            `json:"tls_cert"`
	Paused    *bool              `json:"paused"`
	Protected *bool              `json:"protected"`
}

NodePatch defines a node patch request.

type Registry

type Registry struct {
	Address  string `json:"address"`
	Username string `json:"username"`
	Password string `json:"password,omitempty"`
	Email    string `json:"email"`
	Token    string `json:"token"`
	Policy   string `json:"policy,omitempty"`
}

Registry represents a docker registry with credentials. DEPRECATED

type Repo

type Repo struct {
	ID            int64  `json:"id"`
	UID           string `json:"uid"`
	UserID        int64  `json:"user_id"`
	Namespace     string `json:"namespace"`
	Name          string `json:"name"`
	Slug          string `json:"slug"`
	SCM           string `json:"scm"`
	HTTPURL       string `json:"git_http_url"`
	SSHURL        string `json:"git_ssh_url"`
	Link          string `json:"link"`
	Branch        string `json:"default_branch"`
	Private       bool   `json:"private"`
	Visibility    string `json:"visibility"`
	Active        bool   `json:"active"`
	Config        string `json:"config_path"`
	Trusted       bool   `json:"trusted"`
	Protected     bool   `json:"protected"`
	IgnoreForks   bool   `json:"ignore_forks"`
	IgnorePulls   bool   `json:"ignore_pull_requests"`
	CancelPulls   bool   `json:"auto_cancel_pull_requests"`
	CancelPush    bool   `json:"auto_cancel_pushes"`
	CancelRunning bool   `json:"auto_cancel_running"`
	Throttle      int64  `json:"throttle"`
	Timeout       int64  `json:"timeout"`
	Counter       int64  `json:"counter"`
	Synced        int64  `json:"synced"`
	Created       int64  `json:"created"`
	Updated       int64  `json:"updated"`
	Version       int64  `json:"version"`
	Signer        string `json:"signer,omitempty"`
	Secret        string `json:"secret,omitempty"`
	Build         Build  `json:"build,omitempty"`
}

Repo represents a repository.

type RepoBuildStage added in v1.7.0

type RepoBuildStage struct {
	RepoNamespace     string `json:"repo_namespace"`
	RepoName          string `json:"repo_name"`
	RepoSlug          string `json:"repo_slug"`
	BuildNumber       int64  `json:"build_number"`
	BuildAuthor       string `json:"build_author"`
	BuildAuthorName   string `json:"build_author_name"`
	BuildAuthorEmail  string `json:"build_author_email"`
	BuildAuthorAvatar string `json:"build_author_avatar"`
	BuildSender       string `json:"build_sender"`
	BuildStarted      int64  `json:"build_started"`
	BuildFinished     int64  `json:"build_finished"`
	BuildCreated      int64  `json:"build_created"`
	BuildUpdated      int64  `json:"build_updated"`
	StageName         string `json:"stage_name"`
	StageKind         string `json:"stage_kind"`
	StageType         string `json:"stage_type"`
	StageStatus       string `json:"stage_status"`
	StageMachine      string `json:"stage_machine"`
	StageOS           string `json:"stage_os"`
	StageArch         string `json:"stage_arch"`
	StageVariant      string `json:"stage_variant"`
	StageKernel       string `json:"stage_kernel"`
	StageLimit        string `json:"stage_limit"`
	StageLimitRepo    string `json:"stage_limit_repo"`
	StageStarted      int64  `json:"stage_started"`
	StageStopped      int64  `json:"stage_stopped"`
}

type RepoPatch

type RepoPatch struct {
	Config        *string `json:"config_path,omitempty"`
	Protected     *bool   `json:"protected,omitempty"`
	Trusted       *bool   `json:"trusted,omitempty"`
	Throttle      *int64  `json:"throttle,omitempty"`
	Timeout       *int64  `json:"timeout,omitempty"`
	Visibility    *string `json:"visibility,omitempty"`
	IgnoreForks   *bool   `json:"ignore_forks"`
	IgnorePulls   *bool   `json:"ignore_pull_requests"`
	CancelPulls   *bool   `json:"auto_cancel_pull_requests"`
	CancelPush    *bool   `json:"auto_cancel_pushes"`
	CancelRunning *bool   `json:"auto_cancel_running"`
	Counter       *int64  `json:"counter,omitempty"`
}

RepoPatch defines a repository patch request.

type Secret

type Secret struct {
	Namespace       string `json:"namespace,omitempty"`
	Name            string `json:"name,omitempty"`
	Data            string `json:"data,omitempty"`
	PullRequest     bool   `json:"pull_request,omitempty"`
	PullRequestPush bool   `json:"pull_request_push,omitempty"`

	// Deprecated.
	Pull bool `json:"pull,omitempty"`
	Fork bool `json:"fork,omitempty"`
}

Secret represents a secret variable, such as a password or token.

type Server added in v0.8.4

type Server struct {
	ID       string `json:"id"`
	Provider string `json:"provider"`
	State    string `json:"state"`
	Name     string `json:"name"`
	Image    string `json:"image"`
	Region   string `json:"region"`
	Size     string `json:"size"`
	Address  string `json:"address"`
	Capacity int    `json:"capacity"`
	Secret   string `json:"secret"`
	Error    string `json:"error"`
	CAKey    []byte `json:"ca_key"`
	CACert   []byte `json:"ca_cert"`
	TLSKey   []byte `json:"tls_key"`
	TLSCert  []byte `json:"tls_cert"`
	Created  int64  `json:"created"`
	Updated  int64  `json:"updated"`
	Started  int64  `json:"started"`
	Stopped  int64  `json:"stopped"`
}

Server represents a server node.

type Stage added in v1.0.0

type Stage struct {
	ID        int64             `json:"id"`
	BuildID   int64             `json:"build_id"`
	Number    int               `json:"number"`
	Name      string            `json:"name"`
	Kind      string            `json:"kind,omitempty"`
	Type      string            `json:"type,omitempty"`
	Status    string            `json:"status"`
	Error     string            `json:"error,omitempty"`
	ErrIgnore bool              `json:"errignore"`
	ExitCode  int               `json:"exit_code"`
	Machine   string            `json:"machine,omitempty"`
	OS        string            `json:"os"`
	Arch      string            `json:"arch"`
	Variant   string            `json:"variant,omitempty"`
	Kernel    string            `json:"kernel,omitempty"`
	Limit     int               `json:"limit,omitempty"`
	LimitRepo int               `json:"throttle,omitempty"`
	Started   int64             `json:"started"`
	Stopped   int64             `json:"stopped"`
	Created   int64             `json:"created"`
	Updated   int64             `json:"updated"`
	Version   int64             `json:"version"`
	OnSuccess bool              `json:"on_success"`
	OnFailure bool              `json:"on_failure"`
	DependsOn []string          `json:"depends_on,omitempty"`
	Labels    map[string]string `json:"labels,omitempty"`
	Steps     []*Step           `json:"steps,omitempty"`
}

Stage represents a stage of build execution.

type Step added in v1.0.0

type Step struct {
	ID        int64    `json:"id"`
	StageID   int64    `json:"step_id"`
	Number    int      `json:"number"`
	Name      string   `json:"name"`
	Status    string   `json:"status"`
	Error     string   `json:"error,omitempty"`
	ErrIgnore bool     `json:"errignore,omitempty"`
	ExitCode  int      `json:"exit_code"`
	Started   int64    `json:"started,omitempty"`
	Stopped   int64    `json:"stopped,omitempty"`
	Version   int64    `json:"version"`
	DependsOn []string `json:"depends_on,omitempty"`
	Image     string   `json:"image,omitempty"`
	Detached  bool     `json:"detached,omitempty"`
	Schema    string   `json:"schema,omitempty"`
}

Step represents an individual step in the stage.

type System added in v1.0.5

type System struct {
	Proto   string `json:"proto,omitempty"`
	Host    string `json:"host,omitempty"`
	Link    string `json:"link,omitempty"`
	Version string `json:"version,omitempty"`
}

System stores system information.

type Template added in v1.6.1

type Template struct {
	Name string `json:"name,omitempty"`
	Data string `json:"data,omitempty"`
}

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"`
	Machine   bool   `json:"machine"`
	Syncing   bool   `json:"syncing"`
	Synced    int64  `json:"synced"`
	Created   int64  `json:"created"`
	Updated   int64  `json:"updated"`
	LastLogin int64  `json:"last_login"`
	Token     string `json:"token"`
}

User represents a user account.

type UserPatch added in v1.0.0

type UserPatch struct {
	Active  *bool   `json:"active,omitempty"`
	Admin   *bool   `json:"admin,omitempty"`
	Machine *bool   `json:"machine,omitempty"`
	Token   *string `json:"token,omitempty"`
}

UserPatch defines a user patch request.

type Version added in v1.0.0

type Version struct {
	Source  string `json:"source,omitempty"`
	Version string `json:"version,omitempty"`
	Commit  string `json:"commit,omitempty"`
}

Version provides system version details.

Jump to

Keyboard shortcuts

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