core

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

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

Hook event constants.

View Source
const (
	ActionOpen   = "open"
	ActionClose  = "close"
	ActionCreate = "create"
	ActionDelete = "delete"
	ActionSync   = "sync"
)

Hook action constants.

View Source
const (
	LicenseFoss     = "foss"
	LicensePersonal = "personal"
	LicenseStandard = "standard"
	LicenseTrial    = "trial"
)

License types.

View Source
const (
	// RegistryPull policy allows pulling from a registry.
	RegistryPull = "pull"

	// RegistryPush Policy allows pushing to a registry for
	// all event types except pull requests.
	RegistryPush = "push"

	// RegistryPushPullRequest Policy allows pushing to a
	// registry for all event types, including pull requests.
	RegistryPushPullRequest = "push-pull-request"
)
View Source
const (
	VisibilityPublic   = "public"
	VisibilityPrivate  = "private"
	VisibilityInternal = "internal"
)

Repository visibility.

View Source
const (
	VersionControlGit       = "git"
	VersionControlMercurial = "hg"
)

Version control systems.

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 types.

View Source
const (
	TriggerHook = "@hook"
	TriggerCron = "@cron"
)

Trigger types

View Source
const (
	WebhookEventBuild = "build"
	WebhookEventRepo  = "repo"
	WebhookEventUser  = "user"
)

Webhook event types.

View Source
const (
	WebhookActionCreated  = "created"
	WebhookActionUpdated  = "updated"
	WebhookActionDeleted  = "deleted"
	WebhookActionEnabled  = "enabled"
	WebhookActionDisabled = "disabled"
)

Webhook action types.

Variables

View Source
var ErrBuildLimit = errors.New("Build limit exceeded")

ErrBuildLimit is returned when attempting to create a new build but the maximum number of allowed builds is exceeded.

View Source
var ErrRepoLimit = errors.New("Repository limit exceeded")

ErrRepoLimit is returned when attempting to create a new repository but the maximum number of allowed repositories is exceeded.

View Source
var ErrUserLimit = errors.New("User limit exceeded")

ErrUserLimit is returned when attempting to create a new user but the maximum number of allowed user accounts is exceeded.

Functions

This section is empty.

Types

type AdmissionService

type AdmissionService interface {
	Admit(context.Context, *User) error
}

AdmissionService grants access to the system. The service can be used to restrict access to authorized users, such as members of an organization in your source control management system.

type Batch

type Batch struct {
	Insert []*Repository `json:"insert"`
	Update []*Repository `json:"update"`
	Rename []*Repository `json:"rename"`
	Revoke []*Repository `json:"revoke"`
}

Batch represents a Batch request to synchronize the local repository and permission store for a user account.

type Batcher

type Batcher interface {
	Batch(context.Context, *User, *Batch) error
}

Batcher batch updates the user account.

type Build

type Build struct {
	ID           int64             `db:"build_id"             json:"id"`
	RepoID       int64             `db:"build_repo_id"        json:"repo_id"`
	Trigger      string            `db:"build_trigger"        json:"trigger"`
	Number       int64             `db:"build_number"         json:"number"`
	Parent       int64             `db:"build_parent"         json:"parent,omitempty"`
	Status       string            `db:"build_status"         json:"status"`
	Error        string            `db:"build_error"          json:"error,omitempty"`
	Event        string            `db:"build_event"          json:"event"`
	Action       string            `db:"build_action"         json:"action"`
	Link         string            `db:"build_link"           json:"link"`
	Timestamp    int64             `db:"build_timestamp"      json:"timestamp"`
	Title        string            `db:"build_title"          json:"title,omitempty"`
	Message      string            `db:"build_message"        json:"message"`
	Before       string            `db:"build_before"         json:"before"`
	After        string            `db:"build_after"          json:"after"`
	Ref          string            `db:"build_ref"            json:"ref"`
	Fork         string            `db:"build_source_repo"    json:"source_repo"`
	Source       string            `db:"build_source"         json:"source"`
	Target       string            `db:"build_target"         json:"target"`
	Author       string            `db:"build_author"         json:"author_login"`
	AuthorName   string            `db:"build_author_name"    json:"author_name"`
	AuthorEmail  string            `db:"build_author_email"   json:"author_email"`
	AuthorAvatar string            `db:"build_author_avatar"  json:"author_avatar"`
	Sender       string            `db:"build_sender"         json:"sender"`
	Params       map[string]string `db:"build_params"         json:"params,omitempty"`
	Cron         string            `db:"build_cron"           json:"cron,omitempty"`
	Deploy       string            `db:"build_deploy"         json:"deploy_to,omitempty"`
	DeployID     int64             `db:"build_deploy_id"      json:"deploy_id,omitempty"`
	Started      int64             `db:"build_started"        json:"started"`
	Finished     int64             `db:"build_finished"       json:"finished"`
	Created      int64             `db:"build_created"        json:"created"`
	Updated      int64             `db:"build_updated"        json:"updated"`
	Version      int64             `db:"build_version"        json:"version"`
	Stages       []*Stage          `db:"-"                    json:"stages,omitempty"`
}

Build represents a build execution.

type BuildStore

type BuildStore interface {
	// Find returns a build from the datastore.
	Find(context.Context, int64) (*Build, error)

	// FindNumber returns a build from the datastore by build number.
	FindNumber(context.Context, int64, int64) (*Build, error)

	// FindLast returns the last build from the datastore by ref.
	FindRef(context.Context, int64, string) (*Build, error)

	// List returns a list of builds from the datastore by repository id.
	List(context.Context, int64, int, int) ([]*Build, error)

	// ListRef returns a list of builds from the datastore by ref.
	ListRef(context.Context, int64, string, int, int) ([]*Build, error)

	// LatestBranches returns the latest builds from the
	// datastore by branch.
	LatestBranches(context.Context, int64) ([]*Build, error)

	// LatestPulls returns the latest builds from the
	// datastore by pull requeset.
	LatestPulls(context.Context, int64) ([]*Build, error)

	// LatestDeploys returns the latest builds from the
	// datastore by deployment target.
	LatestDeploys(context.Context, int64) ([]*Build, error)

	// Pending returns a list of pending builds from the
	// datastore by repository id (DEPRECATED).
	Pending(context.Context) ([]*Build, error)

	// Running returns a list of running builds from the
	// datastore by repository id (DEPRECATED).
	Running(context.Context) ([]*Build, error)

	// Create persists a build to the datastore.
	Create(context.Context, *Build, []*Stage) error

	// Update updates a build in the datastore.
	Update(context.Context, *Build) error

	// Delete deletes a build from the datastore.
	Delete(context.Context, *Build) error

	// DeletePull deletes a pull request index from the datastore.
	DeletePull(context.Context, int64, int) error

	// DeleteBranch deletes a branch index from the datastore.
	DeleteBranch(context.Context, int64, string) error

	// DeleteDeploy deletes a deploy index from the datastore.
	DeleteDeploy(context.Context, int64, string) error

	// Purge deletes builds from the database where the build number is less than n.
	Purge(context.Context, int64, int64) error

	// Count returns a count of builds.
	Count(context.Context) (int64, error)
}

BuildStore defines operations for working with builds.

type Canceler

type Canceler interface {
	// Cancel cancels the provided build.
	Cancel(context.Context, *Repository, *Build) error

	// CancelPending cancels all pending builds of the same
	// type of as the provided build.
	CancelPending(context.Context, *Repository, *Build) error
}

Canceler cancels a build.

type Change

type Change struct {
	Path    string
	Added   bool
	Renamed bool
	Deleted bool
}

Change represents a file change in a commit.

type Collaborator

type Collaborator struct {
	UserID  int64  `db:"perm_user_id"  json:"user_id"`
	RepoUID string `db:"perm_repo_uid" json:"repo_id"`
	Login   string `db:"user_login"    json:"login"`
	Avatar  string `db:"user_avatar"   json:"avatar"`
	Read    bool   `db:"perm_read"     json:"read"`
	Write   bool   `db:"perm_write"    json:"write"`
	Admin   bool   `db:"perm_admin"    json:"admin"`
	Synced  int64  `db:"perm_synced"   json:"synced"`
	Created int64  `db:"perm_created"  json:"created"`
	Updated int64  `db:"perm_updated"  json:"updated"`
}

Collaborator represents a project collaborator, and provides the account and repository permissions details.

type Commit

type Commit struct {
	Sha       string
	Ref       string
	Message   string
	Author    *Committer
	Committer *Committer
	Link      string
}

Commit represents a git commit.

type CommitService

type CommitService interface {
	// Find returns the commit information by sha.
	Find(ctx context.Context, user *User, repo, sha string) (*Commit, error)

	// FindRef returns the commit information by reference.
	FindRef(ctx context.Context, user *User, repo, ref string) (*Commit, error)

	// ListChanges returns the files change by sha or reference.
	ListChanges(ctx context.Context, user *User, repo, sha, ref string) ([]*Change, error)
}

CommitService provides access to the commit history from the external source code management service (e.g. GitHub).

type Committer

type Committer struct {
	Name   string
	Email  string
	Date   int64
	Login  string
	Avatar string
}

Committer represents the commit author.

type Config

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

Config represents a pipeline config file.

type ConfigArgs

type ConfigArgs struct {
	User   *User       `json:"-"`
	Repo   *Repository `json:"repo,omitempty"`
	Build  *Build      `json:"build,omitempty"`
	Config *Config     `json:"config,omitempty"`
}

ConfigArgs represents a request for the pipeline configuration file (e.g. .drone.yml)

type ConfigService

type ConfigService interface {
	Find(context.Context, *ConfigArgs) (*Config, error)
}

ConfigService provides pipeline configuration from an external service.

type ConvertArgs

type ConvertArgs struct {
	User   *User       `json:"-"`
	Repo   *Repository `json:"repo,omitempty"`
	Build  *Build      `json:"build,omitempty"`
	Config *Config     `json:"config,omitempty"`
}

ConvertArgs represents a request to the pipeline conversion service.

type ConvertService

type ConvertService interface {
	Convert(context.Context, *ConvertArgs) (*Config, error)
}

ConvertService converts non-native pipeline configuration formats to native configuration formats (e.g. jsonnet to yaml).

type Cron

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,omitempty"`
	Disabled bool   `json:"disabled"`
	Created  int64  `json:"created"`
	Updated  int64  `json:"updated"`
	Version  int64  `json:"version"`
}

Cron defines a cron job.

func (*Cron) SetExpr

func (c *Cron) SetExpr(expr string) error

SetExpr sets the cron expression name and updates the next execution date.

func (*Cron) SetName

func (c *Cron) SetName(name string)

SetName sets the cronjob name.

func (*Cron) Update

func (c *Cron) Update() error

Update updates the next Cron execution date.

func (*Cron) Validate

func (c *Cron) Validate() error

Validate validates the required fields and formats.

type CronStore

type CronStore interface {
	// List returns a cron list from the datastore.
	List(context.Context, int64) ([]*Cron, error)

	// Ready returns a cron list from the datastore ready for execution.
	Ready(context.Context, int64) ([]*Cron, error)

	// Find returns a cron job from the datastore.
	Find(context.Context, int64) (*Cron, error)

	// FindName returns a cron job from the datastore.
	FindName(context.Context, int64, string) (*Cron, error)

	// Create persists a new cron job to the datastore.
	Create(context.Context, *Cron) error

	// Update persists an updated cron job to the datastore.
	Update(context.Context, *Cron) error

	// Delete deletes a cron job from the datastore.
	Delete(context.Context, *Cron) error
}

CronStore persists cron information to storage.

type File

type File struct {
	Data []byte
	Hash []byte
}

File represents the raw file contents in the remote version control system.

type FileArgs

type FileArgs struct {
	Commit string
	Ref    string
}

FileArgs provides repository and commit details required to fetch the file from the remote source code management service.

type FileService

type FileService interface {
	Find(ctx context.Context, user *User, repo, commit, ref, path string) (*File, error)
}

FileService provides access to contents of files in the remote source code management service (e.g. GitHub).

type Filter

type Filter struct {
	Kind    string
	Type    string
	OS      string
	Arch    string
	Kernel  string
	Variant string
	Labels  map[string]string
}

Filter provides filter criteria to limit stages requested from the scheduler.

type GlobalSecretStore

type GlobalSecretStore interface {
	// List returns a secret list from the datastore.
	List(ctx context.Context, namespace string) ([]*Secret, error)

	// ListAll returns a secret list from the datastore
	// for all namespaces.
	ListAll(ctx context.Context) ([]*Secret, error)

	// Find returns a secret from the datastore.
	Find(ctx context.Context, id int64) (*Secret, error)

	// FindName returns a secret from the datastore.
	FindName(ctx context.Context, namespace, name string) (*Secret, error)

	// Create persists a new secret to the datastore.
	Create(ctx context.Context, secret *Secret) error

	// Update persists an updated secret to the datastore.
	Update(ctx context.Context, secret *Secret) error

	// Delete deletes a secret from the datastore.
	Delete(ctx context.Context, secret *Secret) error
}

GlobalSecretStore manages global secrets accessible to all repositories in the system.

type Hook

type Hook struct {
	Parent       int64             `json:"parent"`
	Trigger      string            `json:"trigger"`
	Event        string            `json:"event"`
	Action       string            `json:"action"`
	Link         string            `json:"link"`
	Timestamp    int64             `json:"timestamp"`
	Title        string            `json:"title"`
	Message      string            `json:"message"`
	Before       string            `json:"before"`
	After        string            `json:"after"`
	Ref          string            `json:"ref"`
	Fork         string            `json:"hook"`
	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"`
	Deployment   string            `json:"deploy_to"`
	DeploymentID int64             `json:"deploy_id"`
	Cron         string            `json:"cron"`
	Sender       string            `json:"sender"`
	Params       map[string]string `json:"params"`
}

Hook represents the payload of a post-commit hook.

type HookParser

type HookParser interface {
	Parse(req *http.Request, secretFunc func(string) string) (*Hook, *Repository, error)
}

HookParser parses a post-commit hook from the source code management system, and returns normalized data.

type HookService

type HookService interface {
	Create(ctx context.Context, user *User, repo *Repository) error
	Delete(ctx context.Context, user *User, repo *Repository) error
}

HookService manages post-commit hooks in the external source code management service (e.g. GitHub).

type License

type License struct {
	Licensor     string    `json:"-"`
	Subscription string    `json:"-"`
	Expires      time.Time `json:"expires_at,omitempty"`
	Kind         string    `json:"kind,omitempty"`
	Repos        int64     `json:"repos,omitempty"`
	Users        int64     `json:"users,omitempty"`
	Builds       int64     `json:"builds,omitempty"`
	Nodes        int64     `json:"nodes,omitempty"`
}

License defines software license parameters.

func (*License) Expired

func (l *License) Expired() bool

Expired returns true if the license is expired.

type LicenseService

type LicenseService interface {
	// Exceeded returns true if the system has exceeded
	// its limits as defined in the license.
	Exceeded(context.Context) (bool, error)

	// Expired returns true if the license is expired.
	Expired(context.Context) bool
}

LicenseService provides access to the license service and can be used to check for violations and expirations.

type Line

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

Line represents a line in the logs.

type Linker

type Linker interface {
	Link(ctx context.Context, repo, ref, sha string) (string, error)
}

Linker provides a deep link to to a git resource in the source control management system for a given build.

type LogStore

type LogStore interface {
	// Find returns a log stream from the datastore.
	Find(ctx context.Context, stage int64) (io.ReadCloser, error)

	// Create writes copies the log stream from Reader r to the datastore.
	Create(ctx context.Context, stage int64, r io.Reader) error

	// Update writes copies the log stream from Reader r to the datastore.
	Update(ctx context.Context, stage int64, r io.Reader) error

	// Delete purges the log stream from the datastore.
	Delete(ctx context.Context, stage int64) error
}

LogStore persists build output to storage.

type LogStream

type LogStream interface {
	// Create creates the log stream for the step ID.
	Create(context.Context, int64) error

	// Delete deletes the log stream for the step ID.
	Delete(context.Context, int64) error

	// Writes writes to the log stream.
	Write(context.Context, int64, *Line) error

	// Tail tails the log stream.
	Tail(context.Context, int64) (<-chan *Line, <-chan error)

	// Info returns internal stream information.
	Info(context.Context) *LogStreamInfo
}

LogStream manages a live stream of logs.

type LogStreamInfo

type LogStreamInfo struct {
	// Streams is a key-value pair where the key is the step
	// identifier, and the value is the count of subscribers
	// streaming the logs.
	Streams map[int64]int `json:"streams"`
}

LogStreamInfo provides internal stream information. This can be used to monitor the number of registered streams and subscribers.

type Message

type Message struct {
	Repository string
	Visibility string
	Data       []byte
}

Message defines a build change.

type Netrc

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.

func (*Netrc) SetMachine

func (n *Netrc) SetMachine(address string) error

SetMachine sets the netrc machine from a URL value.

func (*Netrc) String

func (n *Netrc) String() string

String returns the string representation of a netrc file.

type NetrcService

type NetrcService interface {
	Create(context.Context, *User, *Repository) (*Netrc, error)
}

NetrcService returns a valid netrc file that can be used to authenticate and clone a private repository. If authentication is not required or enabled, a nil Netrc file and nil error are returned.

type Organization

type Organization struct {
	Name   string
	Avatar string
}

Organization represents an organization in the source code management system (e.g. GitHub).

type OrganizationService

type OrganizationService interface {
	// List returns a list of organization to which the
	// user is a member.
	List(context.Context, *User) ([]*Organization, error)

	// Membership returns true if the user is a member
	// of the organization, and true if the user is an
	// of the organization.
	Membership(context.Context, *User, string) (bool, bool, error)
}

OrganizationService provides access to organization and team access in the external source code management system (e.g. GitHub).

type Perm

type Perm struct {
	UserID  int64  `db:"perm_user_id"  json:"-"`
	RepoUID string `db:"perm_repo_uid" json:"-"`
	Read    bool   `db:"perm_read"     json:"read"`
	Write   bool   `db:"perm_write"    json:"write"`
	Admin   bool   `db:"perm_admin"    json:"admin"`
	Synced  int64  `db:"perm_synced"   json:"-"`
	Created int64  `db:"perm_created"  json:"-"`
	Updated int64  `db:"perm_updated"  json:"-"`
}

Perm represents an individuals repository permission.

type PermStore

type PermStore interface {
	// Find returns a project member from the
	// datastore.
	Find(ctx context.Context, repoUID string, userID int64) (*Perm, error)

	// List returns a list of project members from the
	// datastore.
	List(ctx context.Context, repoUID string) ([]*Collaborator, error)

	// Update persists an updated project member
	// to the datastore.
	Update(context.Context, *Perm) error

	// Delete deletes a project member from the
	// datastore.
	Delete(context.Context, *Perm) error
}

PermStore defines operations for working with repository permissions.

type Pubsub

type Pubsub interface {
	// Publish publishes the message to all subscribers.
	Publish(context.Context, *Message) error

	// Subscribe subscribes to the message broker.
	Subscribe(context.Context) (<-chan *Message, <-chan error)

	// Subscribers returns a count of subscribers.
	Subscribers() int
}

Pubsub provides publish subscriber capabilities, distributing messages from multiple publishers to multiple subscribers.

type Registry

type Registry struct {
	Address  string `json:"address"`
	Username string `json:"username"`
	Password string `json:"password"`
	Policy   string `json:"policy"`
}

Registry represents a docker registry with credentials.

type RegistryArgs

type RegistryArgs struct {
	Repo     *Repository    `json:"repo,omitempty"`
	Build    *Build         `json:"build,omitempty"`
	Conf     *yaml.Manifest `json:"-"`
	Pipeline *yaml.Pipeline `json:"-"`
}

RegistryArgs provides arguments for requesting registry credentials from the remote service.

type RegistryService

type RegistryService interface {
	// List returns registry credentials from the global
	// remote registry plugin.
	List(context.Context, *RegistryArgs) ([]*Registry, error)
}

RegistryService provides registry credentials from an external service.

type Renewer

type Renewer interface {
	Renew(ctx context.Context, user *User, force bool) error
}

Renewer renews the user account authorization. If successful, the user token and token expiry attributes are updated, and persisted to the datastore.

type Repository

type Repository 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"`
	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:"-"`
	Secret      string `json:"-"`
	Build       *Build `json:"build,omitempty"`
	Perms       *Perm  `json:"permissions,omitempty"`
}

Repository represents a source code repository.

type RepositoryService

type RepositoryService interface {
	// List returns a list of repositories.
	List(ctx context.Context, user *User) ([]*Repository, error)

	// Find returns the named repository details.
	Find(ctx context.Context, user *User, repo string) (*Repository, error)

	// FindPerm returns the named repository permissions.
	FindPerm(ctx context.Context, user *User, repo string) (*Perm, error)
}

RepositoryService provides access to repository information in the remote source code management system (e.g. GitHub).

type RepositoryStore

type RepositoryStore interface {
	// List returns a repository list from the datastore.
	List(context.Context, int64) ([]*Repository, error)

	// ListLatest returns a unique repository list form
	// the datastore with the most recent build.
	ListLatest(context.Context, int64) ([]*Repository, error)

	// ListRecent returns a non-unique repository list form
	// the datastore with the most recent builds.
	ListRecent(context.Context, int64) ([]*Repository, error)

	// ListIncomplete returns a non-unique repository list form
	// the datastore with incomplete builds.
	ListIncomplete(context.Context) ([]*Repository, error)

	// ListAll returns a paginated list of all repositories
	// stored in the database, including disabled repositories.
	ListAll(ctx context.Context, limit, offset int) ([]*Repository, error)

	// Find returns a repository from the datastore.
	Find(context.Context, int64) (*Repository, error)

	// FindName returns a named repository from the datastore.
	FindName(context.Context, string, string) (*Repository, error)

	// Create persists a new repository in the datastore.
	Create(context.Context, *Repository) error

	// Activate persists the activated repository to the datastore.
	Activate(context.Context, *Repository) error

	// Update persists repository changes to the datastore.
	Update(context.Context, *Repository) error

	// Delete deletes a repository from the datastore.
	Delete(context.Context, *Repository) error

	// Count returns a count of activated repositories.
	Count(context.Context) (int64, error)

	// Increment returns an incremented build number
	Increment(context.Context, *Repository) (*Repository, error)
}

RepositoryStore defines operations for working with repositories.

type Scheduler

type Scheduler interface {
	// Schedule schedules the stage for execution.
	Schedule(context.Context, *Stage) error

	// Request requests the next stage scheduled for execution.
	Request(context.Context, Filter) (*Stage, error)

	// Cancel cancels scheduled or running jobs associated
	// with the parent build ID.
	Cancel(context.Context, int64) error

	// Cancelled blocks and listens for a cancellation event and
	// returns true if the build has been cancelled.
	Cancelled(context.Context, int64) (bool, error)

	// Pause pauses the scheduler and prevents new pipelines
	// from being scheduled for execution.
	Pause(context.Context) error

	// Resume unpauses the scheduler, allowing new pipelines
	// to be scheduled for execution.
	Resume(context.Context) error

	// Stats provides statistics for underlying scheduler. The
	// data format is scheduler-specific.
	Stats(context.Context) (interface{}, error)
}

Scheduler schedules Build stages for execution.

type Secret

type Secret struct {
	ID              int64  `json:"id,omitempty"`
	RepoID          int64  `json:"repo_id,omitempty"`
	Namespace       string `json:"namespace,omitempty"`
	Name            string `json:"name,omitempty"`
	Type            string `json:"type,omitempty"`
	Data            string `json:"data,omitempty"`
	PullRequest     bool   `json:"pull_request,omitempty"`
	PullRequestPush bool   `json:"pull_request_push,omitempty"`
}

Secret represents a secret variable, such as a password or token, that is provided to the build at runtime.

func (*Secret) Copy

func (s *Secret) Copy() *Secret

Copy makes a copy of the secret without the value.

func (*Secret) Validate

func (s *Secret) Validate() error

Validate validates the required fields and formats.

type SecretArgs

type SecretArgs struct {
	Name  string         `json:"name"`
	Repo  *Repository    `json:"repo,omitempty"`
	Build *Build         `json:"build,omitempty"`
	Conf  *yaml.Manifest `json:"-"`
}

SecretArgs provides arguments for requesting secrets from the remote service.

type SecretService

type SecretService interface {
	// Find returns a named secret from the global remote service.
	Find(context.Context, *SecretArgs) (*Secret, error)
}

SecretService provides secrets from an external service.

type SecretStore

type SecretStore interface {
	// List returns a secret list from the datastore.
	List(context.Context, int64) ([]*Secret, error)

	// Find returns a secret from the datastore.
	Find(context.Context, int64) (*Secret, error)

	// FindName returns a secret from the datastore.
	FindName(context.Context, int64, string) (*Secret, error)

	// Create persists a new secret to the datastore.
	Create(context.Context, *Secret) error

	// Update persists an updated secret to the datastore.
	Update(context.Context, *Secret) error

	// Delete deletes a secret from the datastore.
	Delete(context.Context, *Secret) error
}

SecretStore manages repository secrets.

type Session

type Session interface {
	// Create creates a new user session and writes the
	// session to the http.Response.
	Create(http.ResponseWriter, *User) error

	// Delete deletes the user session from the http.Response.
	Delete(http.ResponseWriter) error

	// Get returns the session from the http.Request. If no
	// session exists a nil user is returned. Returning an
	// error is optional, for debugging purposes only.
	Get(*http.Request) (*User, error)
}

Session provides session management for authenticated users.

type Stage

type Stage struct {
	ID        int64             `json:"id"`
	RepoID    int64             `json:"repo_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"`
	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.

func (*Stage) IsDone

func (s *Stage) IsDone() bool

IsDone returns true if the step has a completed state.

func (*Stage) IsFailed

func (s *Stage) IsFailed() bool

IsFailed returns true if the step has failed

type StageStore

type StageStore interface {
	// List returns a build stage list from the datastore.
	List(context.Context, int64) ([]*Stage, error)

	// List returns a build stage list from the datastore
	// where the stage is incomplete (pending or running).
	ListIncomplete(ctx context.Context) ([]*Stage, error)

	// ListSteps returns a build stage list from the datastore,
	// with the individual steps included.
	ListSteps(context.Context, int64) ([]*Stage, error)

	// ListState returns a build stage list from the database
	// across all repositories.
	ListState(context.Context, string) ([]*Stage, error)

	// Find returns a build stage from the datastore by ID.
	Find(context.Context, int64) (*Stage, error)

	// FindNumber returns a stage from the datastore by number.
	FindNumber(context.Context, int64, int) (*Stage, error)

	// Create persists a new stage to the datastore.
	Create(context.Context, *Stage) error

	// Update persists an updated stage to the datastore.
	Update(context.Context, *Stage) error
}

StageStore persists build stage information to storage.

type Status

type Status struct {
	State  string
	Label  string
	Desc   string
	Target string
}

Status represents a commit status.

type StatusInput

type StatusInput struct {
	Repo  *Repository
	Build *Build
}

StatusInput provides the necessary metadata to set the commit or deployment status.

type StatusService

type StatusService interface {
	Send(ctx context.Context, user *User, req *StatusInput) error
}

StatusService sends the commit status to an external external source code management service (e.g. GitHub).

type Step

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"`
}

Step represents an individual step in the stage.

func (*Step) IsDone

func (s *Step) IsDone() bool

IsDone returns true if the step has a completed state.

type StepStore

type StepStore interface {
	// List returns a build stage list from the datastore.
	List(context.Context, int64) ([]*Step, error)

	// Find returns a build stage from the datastore by ID.
	Find(context.Context, int64) (*Step, error)

	// FindNumber returns a stage from the datastore by number.
	FindNumber(context.Context, int64, int) (*Step, error)

	// Create persists a new stage to the datastore.
	Create(context.Context, *Step) error

	// Update persists an updated stage to the datastore.
	Update(context.Context, *Step) error
}

StepStore persists build step information to storage.

type Syncer

type Syncer interface {
	Sync(context.Context, *User) (*Batch, error)
}

Syncer synchronizes the account repository list.

type System

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 Triggerer

type Triggerer interface {
	Trigger(context.Context, *Repository, *Hook) (*Build, error)
}

Triggerer is responsible for triggering a Build from an incoming drone. If a build is skipped a nil value is returned.

type User

type User struct {
	ID        int64  `json:"id"`
	Login     string `json:"login"`
	Email     string `json:"email"`
	Machine   bool   `json:"machine"`
	Admin     bool   `json:"admin"`
	Active    bool   `json:"active"`
	Avatar    string `json:"avatar"`
	Syncing   bool   `json:"syncing"`
	Synced    int64  `json:"synced"`
	Created   int64  `json:"created"`
	Updated   int64  `json:"updated"`
	LastLogin int64  `json:"last_login"`
	Token     string `json:"-"`
	Refresh   string `json:"-"`
	Expiry    int64  `json:"-"`
	Hash      string `json:"-"`
}

User represents a user of the system.

func (*User) Validate

func (u *User) Validate() error

Validate valides the user and returns an error if the validation fails.

type UserService

type UserService interface {
	// Find returns the authenticated user.
	Find(ctx context.Context, access, refresh string) (*User, error)

	// FindLogin returns a user by username.
	FindLogin(ctx context.Context, user *User, login string) (*User, error)
}

UserService provides access to user account resources in the remote system (e.g. GitHub).

type UserStore

type UserStore interface {
	// Find returns a user from the datastore.
	Find(context.Context, int64) (*User, error)

	// FindLogin returns a user from the datastore by username.
	FindLogin(context.Context, string) (*User, error)

	// FindToken returns a user from the datastore by token.
	FindToken(context.Context, string) (*User, error)

	// List returns a list of users from the datastore.
	List(context.Context) ([]*User, error)

	// Create persists a new user to the datastore.
	Create(context.Context, *User) error

	// Update persists an updated user to the datastore.
	Update(context.Context, *User) error

	// Delete deletes a user from the datastore.
	Delete(context.Context, *User) error

	// Count returns a count of human and machine users.
	Count(context.Context) (int64, error)

	// CountHuman returns a count of human users.
	CountHuman(context.Context) (int64, error)
}

UserStore defines operations for working with users.

type ValidateArgs

type ValidateArgs struct {
	User   *User       `json:"-"`
	Repo   *Repository `json:"repo,omitempty"`
	Build  *Build      `json:"build,omitempty"`
	Config *Config     `json:"config,omitempty"`
}

ValidateArgs represents a request to the pipeline validation service.

type ValidateService

type ValidateService interface {
	Validate(context.Context, *ValidateArgs) error
}

ValidateService validates the yaml configuration and returns an error if the yaml is deemed invalid.

type Webhook

type Webhook struct {
	Endpoint   string `json:"endpoint,omitempty"`
	Signer     string `json:"-"`
	SkipVerify bool   `json:"skip_verify,omitempty"`
}

Webhook defines an integration endpoint.

type WebhookData

type WebhookData struct {
	Event  string      `json:"event"`
	Action string      `json:"action"`
	User   *User       `json:"user,omitempty"`
	Repo   *Repository `json:"repo,omitempty"`
	Build  *Build      `json:"build,omitempty"`
	Config *Config     `json:"config,omitempty"`
}

WebhookData provides the webhook data.

type WebhookSender

type WebhookSender interface {
	// Send sends the webhook to the global endpoint.
	Send(context.Context, *WebhookData) error
}

WebhookSender sends the webhook payload.

Jump to

Keyboard shortcuts

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