model

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventPush   = "push"
	EventPull   = "pull_request"
	EventTag    = "tag"
	EventDeploy = "deployment"
)
View Source
const (
	StatusSkipped  = "skipped"
	StatusPending  = "pending"
	StatusRunning  = "running"
	StatusSuccess  = "success"
	StatusFailure  = "failure"
	StatusKilled   = "killed"
	StatusError    = "error"
	StatusBlocked  = "blocked"
	StatusDeclined = "declined"
)
View Source
const (
	RepoGit      = "git"
	RepoHg       = "hg"
	RepoFossil   = "fossil"
	RepoPerforce = "perforce"
)
View Source
const (
	VisibilityPublic   = "public"
	VisibilityPrivate  = "private"
	VisibilityInternal = "internal"
)

Variables

This section is empty.

Functions

func ParseRepo added in v0.8.0

func ParseRepo(str string) (user, repo string, err error)

ParseRepo parses the repository owner and name from a string.

func WithTaskStore added in v0.6.0

func WithTaskStore(q queue.Queue, s TaskStore) queue.Queue

WithTaskStore returns a queue that is backed by the TaskStore. This ensures the task Queue can be restored when the system starts.

Types

type Build

type Build struct {
	ID        int64   `json:"id"            meddler:"build_id,pk"`
	RepoID    int64   `json:"-"             meddler:"build_repo_id"`
	ConfigID  int64   `json:"-"             meddler:"build_config_id"`
	Number    int     `json:"number"        meddler:"build_number"`
	Parent    int     `json:"parent"        meddler:"build_parent"`
	Event     string  `json:"event"         meddler:"build_event"`
	Status    string  `json:"status"        meddler:"build_status"`
	Error     string  `json:"error"         meddler:"build_error"`
	Enqueued  int64   `json:"enqueued_at"   meddler:"build_enqueued"`
	Created   int64   `json:"created_at"    meddler:"build_created"`
	Started   int64   `json:"started_at"    meddler:"build_started"`
	Finished  int64   `json:"finished_at"   meddler:"build_finished"`
	Deploy    string  `json:"deploy_to"     meddler:"build_deploy"`
	Commit    string  `json:"commit"        meddler:"build_commit"`
	Branch    string  `json:"branch"        meddler:"build_branch"`
	Ref       string  `json:"ref"           meddler:"build_ref"`
	Refspec   string  `json:"refspec"       meddler:"build_refspec"`
	Remote    string  `json:"remote"        meddler:"build_remote"`
	Title     string  `json:"title"         meddler:"build_title"`
	Message   string  `json:"message"       meddler:"build_message"`
	Timestamp int64   `json:"timestamp"     meddler:"build_timestamp"`
	Sender    string  `json:"sender"        meddler:"build_sender"`
	Author    string  `json:"author"        meddler:"build_author"`
	Avatar    string  `json:"author_avatar" meddler:"build_avatar"`
	Email     string  `json:"author_email"  meddler:"build_email"`
	Link      string  `json:"link_url"      meddler:"build_link"`
	Signed    bool    `json:"signed"        meddler:"build_signed"`   // deprecate
	Verified  bool    `json:"verified"      meddler:"build_verified"` // deprecate
	Reviewer  string  `json:"reviewed_by"   meddler:"build_reviewer"`
	Reviewed  int64   `json:"reviewed_at"   meddler:"build_reviewed"`
	Procs     []*Proc `json:"procs,omitempty" meddler:"-"`
	Files     []*File `json:"files,omitempty" meddler:"-"`
}

swagger:model build

func (*Build) Trim added in v0.7.0

func (b *Build) Trim()

Trim trims string values that would otherwise exceed the database column sizes and fail to insert.

type CCProject

type CCProject struct {
	XMLName         xml.Name `xml:"Project"`
	Name            string   `xml:"name,attr"`
	Activity        string   `xml:"activity,attr"`
	LastBuildStatus string   `xml:"lastBuildStatus,attr"`
	LastBuildLabel  string   `xml:"lastBuildLabel,attr"`
	LastBuildTime   string   `xml:"lastBuildTime,attr"`
	WebURL          string   `xml:"webUrl,attr"`
}

type CCProjects

type CCProjects struct {
	XMLName xml.Name   `xml:"Projects"`
	Project *CCProject `xml:"Project"`
}

func NewCC

func NewCC(r *Repo, b *Build, link string) *CCProjects

type Config added in v0.5.0

type Config struct {
	ID     int64  `json:"-"    meddler:"config_id,pk"`
	RepoID int64  `json:"-"    meddler:"config_repo_id"`
	Data   string `json:"data" meddler:"config_data"`
	Hash   string `json:"hash" meddler:"config_hash"`
}

Config represents a pipeline configuration.

type ConfigStore added in v0.6.0

type ConfigStore interface {
	ConfigLoad(int64) (*Config, error)
	ConfigFind(*Repo, string) (*Config, error)
	ConfigFindApproved(*Config) (bool, error)
	ConfigCreate(*Config) error
}

ConfigStore persists pipeline configuration to storage.

type Environ added in v0.7.3

type Environ struct {
	ID    int64  `json:"id"              meddler:"env_id,pk"`
	Name  string `json:"name"            meddler:"env_name"`
	Value string `json:"value,omitempty" meddler:"env_value"`
}

Environ represents an environment variable. swagger:model environ

func (*Environ) Copy added in v0.7.3

func (e *Environ) Copy() *Environ

Copy makes a copy of the environment variable without the value.

func (*Environ) Validate added in v0.7.3

func (e *Environ) Validate() error

Validate validates the required fields and formats.

type EnvironService added in v0.7.3

type EnvironService interface {
	EnvironList(*Repo) ([]*Environ, error)
}

EnvironService defines a service for managing environment variables.

type EnvironStore added in v0.7.3

type EnvironStore interface {
	EnvironList(*Repo) ([]*Environ, error)
}

EnvironStore persists environment information to storage.

type Event added in v0.5.0

type Event struct {
	Type  EventType `json:"type"`
	Repo  Repo      `json:"repo"`
	Build Build     `json:"build"`
	Proc  Proc      `json:"proc"`
}

Event represents a build event.

type EventType added in v0.5.0

type EventType string

EventType defines the possible types of build events.

const (
	Enqueued  EventType = "enqueued"
	Started   EventType = "started"
	Finished  EventType = "finished"
	Cancelled EventType = "cancelled"
)

type Feed

type Feed struct {
	Owner    string `json:"owner"         meddler:"repo_owner"`
	Name     string `json:"name"          meddler:"repo_name"`
	FullName string `json:"full_name"     meddler:"repo_full_name"`

	Number   int    `json:"number,omitempty"        meddler:"build_number,zeroisnull"`
	Event    string `json:"event,omitempty"         meddler:"build_event,zeroisnull"`
	Status   string `json:"status,omitempty"        meddler:"build_status,zeroisnull"`
	Created  int64  `json:"created_at,omitempty"    meddler:"build_created,zeroisnull"`
	Started  int64  `json:"started_at,omitempty"    meddler:"build_started,zeroisnull"`
	Finished int64  `json:"finished_at,omitempty"   meddler:"build_finished,zeroisnull"`
	Commit   string `json:"commit,omitempty"        meddler:"build_commit,zeroisnull"`
	Branch   string `json:"branch,omitempty"        meddler:"build_branch,zeroisnull"`
	Ref      string `json:"ref,omitempty"           meddler:"build_ref,zeroisnull"`
	Refspec  string `json:"refspec,omitempty"       meddler:"build_refspec,zeroisnull"`
	Remote   string `json:"remote,omitempty"        meddler:"build_remote,zeroisnull"`
	Title    string `json:"title,omitempty"         meddler:"build_title,zeroisnull"`
	Message  string `json:"message,omitempty"       meddler:"build_message,zeroisnull"`
	Author   string `json:"author,omitempty"        meddler:"build_author,zeroisnull"`
	Avatar   string `json:"author_avatar,omitempty" meddler:"build_avatar,zeroisnull"`
	Email    string `json:"author_email,omitempty"  meddler:"build_email,zeroisnull"`
}

Feed represents an item in the user's feed or timeline.

swagger:model feed

type File added in v0.6.0

type File struct {
	ID      int64  `json:"id"      meddler:"file_id,pk"`
	BuildID int64  `json:"-"       meddler:"file_build_id"`
	ProcID  int64  `json:"proc_id" meddler:"file_proc_id"`
	PID     int    `json:"pid"     meddler:"file_pid"`
	Name    string `json:"name"    meddler:"file_name"`
	Size    int    `json:"size"    meddler:"file_size"`
	Mime    string `json:"mime"    meddler:"file_mime"`
	Time    int64  `json:"time"    meddler:"file_time"`
	Passed  int    `json:"passed"  meddler:"file_meta_passed"`
	Failed  int    `json:"failed"  meddler:"file_meta_failed"`
	Skipped int    `json:"skipped" meddler:"file_meta_skipped"`
}

File represents a pipeline artifact.

type FileStore added in v0.6.0

type FileStore interface {
	FileList(*Build) ([]*File, error)
	FileFind(*Proc, string) (*File, error)
	FileRead(*Proc, string) (io.ReadCloser, error)
	FileCreate(*File, io.Reader) error
}

FileStore persists pipeline artifacts to storage.

type Limiter added in v0.6.0

type Limiter interface {
	LimitUser(*User) error
	LimitRepo(*User, *Repo) error
	LimitRepos(*User, []*Repo) []*Repo
	LimitBuild(*User, *Repo, *Build) error
}

Limiter defines an interface for limiting repository creation. This could be used, for example, to limit repository creation to a specific organization or a specific set of users.

type Netrc

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

type NoLimit added in v0.6.0

type NoLimit struct{}

NoLimit impliments the Limiter interface without enforcing any actual limits. All limiting functions are no-ops.

func (NoLimit) LimitBuild added in v0.6.0

func (NoLimit) LimitBuild(*User, *Repo, *Build) error

LimitBuild is a no-op for limiting build creation.

func (NoLimit) LimitRepo added in v0.6.0

func (NoLimit) LimitRepo(*User, *Repo) error

LimitRepo is a no-op for limiting repo creation.

func (NoLimit) LimitRepos added in v0.8.1

func (NoLimit) LimitRepos(user *User, repos []*Repo) []*Repo

LimitRepos is a no-op for limiting repository listings.

func (NoLimit) LimitUser added in v0.6.0

func (NoLimit) LimitUser(*User) error

LimitUser is a no-op for limiting user creation.

type Perm

type Perm struct {
	UserID int64  `json:"-"      meddler:"perm_user_id"`
	RepoID int64  `json:"-"      meddler:"perm_repo_id"`
	Repo   string `json:"-"      meddler:"-"`
	Pull   bool   `json:"pull"   meddler:"perm_pull"`
	Push   bool   `json:"push"   meddler:"perm_push"`
	Admin  bool   `json:"admin"  meddler:"perm_admin"`
	Synced int64  `json:"synced" meddler:"perm_synced"`
}

Perm defines a repository permission for an individual user.

type PermStore added in v0.8.0

type PermStore interface {
	PermFind(user *User, repo *Repo) (*Perm, error)
	PermUpsert(perm *Perm) error
	PermBatch(perms []*Perm) error
	PermDelete(perm *Perm) error
	PermFlush(user *User, before int64) error
}

PermStore persists repository permissions information to storage.

type Proc added in v0.6.0

type Proc struct {
	ID       int64             `json:"id"                   meddler:"proc_id,pk"`
	BuildID  int64             `json:"build_id"             meddler:"proc_build_id"`
	PID      int               `json:"pid"                  meddler:"proc_pid"`
	PPID     int               `json:"ppid"                 meddler:"proc_ppid"`
	PGID     int               `json:"pgid"                 meddler:"proc_pgid"`
	Name     string            `json:"name"                 meddler:"proc_name"`
	State    string            `json:"state"                meddler:"proc_state"`
	Error    string            `json:"error,omitempty"      meddler:"proc_error"`
	ExitCode int               `json:"exit_code"            meddler:"proc_exit_code"`
	Started  int64             `json:"start_time,omitempty" meddler:"proc_started"`
	Stopped  int64             `json:"end_time,omitempty"   meddler:"proc_stopped"`
	Machine  string            `json:"machine,omitempty"    meddler:"proc_machine"`
	Platform string            `json:"platform,omitempty"   meddler:"proc_platform"`
	Environ  map[string]string `json:"environ,omitempty"    meddler:"proc_environ,json"`
	Children []*Proc           `json:"children,omitempty"   meddler:"-"`
}

Proc represents a process in the build pipeline. swagger:model proc

func Tree added in v0.6.0

func Tree(procs []*Proc) []*Proc

Tree creates a process tree from a flat process list.

func (*Proc) Failing added in v0.6.0

func (p *Proc) Failing() bool

Failing returns true if the process state is failed, killed or error.

func (*Proc) Running added in v0.6.0

func (p *Proc) Running() bool

Running returns true if the process state is pending or running.

type ProcStore added in v0.6.0

type ProcStore interface {
	ProcLoad(int64) (*Proc, error)
	ProcFind(*Build, int) (*Proc, error)
	ProcChild(*Build, int, string) (*Proc, error)
	ProcList(*Build) ([]*Proc, error)
	ProcCreate([]*Proc) error
	ProcUpdate(*Proc) error
	ProcClear(*Build) error
}

ProcStore persists process information to storage.

type Registry added in v0.4.2

type Registry struct {
	ID       int64  `json:"id"       meddler:"registry_id,pk"`
	RepoID   int64  `json:"-"        meddler:"registry_repo_id"`
	Address  string `json:"address"  meddler:"registry_addr"`
	Username string `json:"username" meddler:"registry_username"`
	Password string `json:"password" meddler:"registry_password"`
	Email    string `json:"email"    meddler:"registry_email"`
	Token    string `json:"token"    meddler:"registry_token"`
}

Registry represents a docker registry with credentials. swagger:model registry

func (*Registry) Copy added in v0.6.0

func (r *Registry) Copy() *Registry

Copy makes a copy of the registry without the password.

func (*Registry) Validate added in v0.4.2

func (r *Registry) Validate() error

Validate validates the registry information.

type RegistryService added in v0.6.0

type RegistryService interface {
	RegistryFind(*Repo, string) (*Registry, error)
	RegistryList(*Repo) ([]*Registry, error)
	RegistryCreate(*Repo, *Registry) error
	RegistryUpdate(*Repo, *Registry) error
	RegistryDelete(*Repo, string) error
}

RegistryService defines a service for managing registries.

type RegistryStore added in v0.6.0

type RegistryStore interface {
	RegistryFind(*Repo, string) (*Registry, error)
	RegistryList(*Repo) ([]*Registry, error)
	RegistryCreate(*Registry) error
	RegistryUpdate(*Registry) error
	RegistryDelete(*Registry) error
}

RegistryStore persists registry information to storage.

type Repo

type Repo struct {
	ID          int64  `json:"id,omitempty"             meddler:"repo_id,pk"`
	UserID      int64  `json:"-"                        meddler:"repo_user_id"`
	Owner       string `json:"owner"                    meddler:"repo_owner"`
	Name        string `json:"name"                     meddler:"repo_name"`
	FullName    string `json:"full_name"                meddler:"repo_full_name"`
	Avatar      string `json:"avatar_url,omitempty"     meddler:"repo_avatar"`
	Link        string `json:"link_url,omitempty"       meddler:"repo_link"`
	Kind        string `json:"scm,omitempty"            meddler:"repo_scm"`
	Clone       string `json:"clone_url,omitempty"      meddler:"repo_clone"`
	Branch      string `json:"default_branch,omitempty" meddler:"repo_branch"`
	Timeout     int64  `json:"timeout,omitempty"        meddler:"repo_timeout"`
	Visibility  string `json:"visibility"               meddler:"repo_visibility"`
	IsPrivate   bool   `json:"private"                  meddler:"repo_private"`
	IsTrusted   bool   `json:"trusted"                  meddler:"repo_trusted"`
	IsStarred   bool   `json:"starred,omitempty"        meddler:"-"`
	IsGated     bool   `json:"gated"                    meddler:"repo_gated"`
	IsActive    bool   `json:"active"                   meddler:"repo_active"`
	AllowPull   bool   `json:"allow_pr"                 meddler:"repo_allow_pr"`
	AllowPush   bool   `json:"allow_push"               meddler:"repo_allow_push"`
	AllowDeploy bool   `json:"allow_deploys"            meddler:"repo_allow_deploys"`
	AllowTag    bool   `json:"allow_tags"               meddler:"repo_allow_tags"`
	Counter     int    `json:"last_build"               meddler:"repo_counter"`
	Config      string `json:"config_file"              meddler:"repo_config_path"`
	Hash        string `json:"-"                        meddler:"repo_hash"`
	Perm        *Perm  `json:"-"                        meddler:"-"`
}

Repo represents a repository.

swagger:model repo

func (*Repo) ResetVisibility added in v0.8.0

func (r *Repo) ResetVisibility()

func (*Repo) Update added in v0.8.0

func (r *Repo) Update(from *Repo)

Update updates the repository with values from the given Repo.

type RepoLite

type RepoLite struct {
	Owner    string `json:"owner"`
	Name     string `json:"name"`
	FullName string `json:"full_name"`
	Avatar   string `json:"avatar_url"`
}

type RepoPatch added in v0.6.0

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,omitempty"`
	AllowPull    *bool   `json:"allow_pr,omitempty"`
	AllowPush    *bool   `json:"allow_push,omitempty"`
	AllowDeploy  *bool   `json:"allow_deploy,omitempty"`
	AllowTag     *bool   `json:"allow_tag,omitempty"`
	BuildCounter *int    `json:"build_counter,omitempty"`
}

RepoPatch represents a repository patch object.

type ResourceLimit added in v0.7.3

type ResourceLimit struct {
	MemSwapLimit int64
	MemLimit     int64
	ShmSize      int64
	CPUQuota     int64
	CPUShares    int64
	CPUSet       string
}

ResourceLimit is the resource limit to set on pipeline steps

type Secret added in v0.4.2

type Secret struct {
	ID         int64    `json:"id"              meddler:"secret_id,pk"`
	RepoID     int64    `json:"-"               meddler:"secret_repo_id"`
	Name       string   `json:"name"            meddler:"secret_name"`
	Value      string   `json:"value,omitempty" meddler:"secret_value"`
	Images     []string `json:"image"           meddler:"secret_images,json"`
	Events     []string `json:"event"           meddler:"secret_events,json"`
	SkipVerify bool     `json:"-"               meddler:"secret_skip_verify"`
	Conceal    bool     `json:"-"               meddler:"secret_conceal"`
}

Secret represents a secret variable, such as a password or token. swagger:model registry

func (*Secret) Copy added in v0.6.0

func (s *Secret) Copy() *Secret

Copy makes a copy of the secret without the value.

func (*Secret) Match added in v0.4.2

func (s *Secret) Match(event string) bool

Match returns true if an image and event match the restricted list.

func (*Secret) Validate added in v0.4.2

func (s *Secret) Validate() error

Validate validates the required fields and formats.

type SecretService added in v0.6.0

type SecretService interface {
	SecretFind(*Repo, string) (*Secret, error)
	SecretList(*Repo) ([]*Secret, error)
	SecretListBuild(*Repo, *Build) ([]*Secret, error)
	SecretCreate(*Repo, *Secret) error
	SecretUpdate(*Repo, *Secret) error
	SecretDelete(*Repo, string) error
}

SecretService defines a service for managing secrets.

type SecretStore added in v0.6.0

type SecretStore interface {
	SecretFind(*Repo, string) (*Secret, error)
	SecretList(*Repo) ([]*Secret, error)
	SecretCreate(*Secret) error
	SecretUpdate(*Secret) error
	SecretDelete(*Secret) error
}

SecretStore persists secret information to storage.

type Sender added in v0.6.0

type Sender struct {
	ID     int64    `json:"-"      meddler:"sender_id,pk"`
	RepoID int64    `json:"-"      meddler:"sender_repo_id"`
	Login  string   `json:"login"  meddler:"sender_login"`
	Allow  bool     `json:"allow"  meddler:"sender_allow"`
	Block  bool     `json:"block"  meddler:"sender_block"`
	Branch []string `json:"branch" meddler:"-"`
	Deploy []string `json:"deploy" meddler:"-"`
	Event  []string `json:"event"  meddler:"-"`
}

type SenderService added in v0.6.0

type SenderService interface {
	SenderAllowed(*User, *Repo, *Build, *Config) (bool, error)
	SenderCreate(*Repo, *Sender) error
	SenderUpdate(*Repo, *Sender) error
	SenderDelete(*Repo, string) error
	SenderList(*Repo) ([]*Sender, error)
}

type SenderStore added in v0.6.0

type SenderStore interface {
	SenderFind(*Repo, string) (*Sender, error)
	SenderList(*Repo) ([]*Sender, error)
	SenderCreate(*Sender) error
	SenderUpdate(*Sender) error
	SenderDelete(*Sender) error
}

type Settings added in v0.6.0

type Settings struct {
	Open   bool            // Enables open registration
	Secret string          // Secret token used to authenticate agents
	Admins map[string]bool // Administrative users
	Orgs   map[string]bool // Organization whitelist
}

Settings defines system configuration parameters.

func (*Settings) IsAdmin added in v0.6.0

func (c *Settings) IsAdmin(user *User) bool

IsAdmin returns true if the user is a member of the administrator list.

func (*Settings) IsMember added in v0.6.0

func (c *Settings) IsMember(teams []*Team) bool

IsMember returns true if the user is a member of the whitelisted teams.

type Task added in v0.6.0

type Task struct {
	ID     string            `meddler:"task_id"`
	Data   []byte            `meddler:"task_data"`
	Labels map[string]string `meddler:"task_labels,json"`
}

Task defines scheduled pipeline Task.

type TaskStore added in v0.6.0

type TaskStore interface {
	TaskList() ([]*Task, error)
	TaskInsert(*Task) error
	TaskDelete(string) error
}

TaskStore defines storage for scheduled Tasks.

type Team added in v0.5.0

type Team struct {
	// Login is the username for this team.
	Login string `json:"login"`

	// the avatar url for this team.
	Avatar string `json:"avatar_url"`
}

Team represents a team or organization in the remote version control system.

swagger:model user

type User

type User struct {
	// the id for this user.
	//
	// required: true
	ID int64 `json:"id" meddler:"user_id,pk"`

	// Login is the username for this user.
	//
	// required: true
	Login string `json:"login"  meddler:"user_login"`

	// Token is the oauth2 token.
	Token string `json:"-"  meddler:"user_token"`

	// Secret is the oauth2 token secret.
	Secret string `json:"-" meddler:"user_secret"`

	// Expiry is the token and secret expriation timestamp.
	Expiry int64 `json:"-" meddler:"user_expiry"`

	// Email is the email address for this user.
	//
	// required: true
	Email string `json:"email" meddler:"user_email"`

	// the avatar url for this user.
	Avatar string `json:"avatar_url" meddler:"user_avatar"`

	// Activate indicates the user is active in the system.
	Active bool `json:"active" meddler:"user_active"`

	// Synced is the timestamp when the user was synced with the remote system.
	Synced int64 `json:"synced" meddler:"user_synced"`

	// Admin indicates the user is a system administrator.
	//
	// NOTE: This is sourced from the DRONE_ADMINS environment variable and is no
	// longer persisted in the database.
	Admin bool `json:"admin,omitempty" meddler:"-"`

	// Hash is a unique token used to sign tokens.
	Hash string `json:"-" meddler:"user_hash"`

	// DEPRECATED Admin indicates the user is a system administrator.
	XAdmin bool `json:"-" meddler:"user_admin"`
}

User represents a registered user.

swagger:model user

func (*User) Validate added in v0.8.0

func (u *User) Validate() error

Validate validates the required fields and formats.

Jump to

Keyboard shortcuts

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