model

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2017 License: Apache-2.0 Imports: 4 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"
)
View Source
const (
	RepoGit      = "git"
	RepoHg       = "hg"
	RepoFossil   = "fossil"
	RepoPerforce = "perforce"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent added in v0.5.0

type Agent struct {
	ID       int64  `json:"id"         meddler:"agent_id,pk"`
	Address  string `json:"address"    meddler:"agent_addr"`
	Platform string `json:"platform"   meddler:"agent_platform"`
	Capacity int    `json:"capacity"   meddler:"agent_capacity"`
	Created  int64  `json:"created_at" meddler:"agent_created"`
	Updated  int64  `json:"updated_at" meddler:"agent_updated"`
}

type Build

type Build struct {
	ID        int64  `json:"id"            meddler:"build_id,pk"`
	RepoID    int64  `json:"-"             meddler:"build_repo_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"`
	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"`
	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"`
	Verified  bool   `json:"verified"      meddler:"build_verified"`
	Jobs      []*Job `json:"jobs,omitempty" meddler:"-"`
}

swagger:model build

type BuildGroup

type BuildGroup struct {
	Date   string
	Builds []*Build
}

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 {
	Open   bool            // Enables open registration
	Yaml   string          // Customize the Yaml configuration file name
	Shasum string          // Customize the Yaml checksum file name
	Secret string          // Secret token used to authenticate agents
	Admins map[string]bool // Administrative users
	Orgs   map[string]bool // Organization whitelist
}

Config defines system configuration parameters.

func (*Config) IsAdmin added in v0.5.0

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

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

func (*Config) IsMember added in v0.5.0

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

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

type Event added in v0.5.0

type Event struct {
	Type  EventType `json:"type"`
	Repo  Repo      `json:"repo"`
	Build Build     `json:"build"`
	Job   Job       `json:"job"`
}

Event represents a build event.

func NewBuildEvent added in v0.5.0

func NewBuildEvent(t EventType, r *Repo, b *Build) *Event

func NewEvent added in v0.5.0

func NewEvent(t EventType, r *Repo, b *Build, j *Job) *Event

NewEvent creates a new Event for the build, using copies of the build data to avoid possible mutation or race conditions.

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 Job

type Job struct {
	ID       int64  `json:"id"           meddler:"job_id,pk"`
	BuildID  int64  `json:"-"            meddler:"job_build_id"`
	NodeID   int64  `json:"-"            meddler:"job_node_id"`
	Number   int    `json:"number"       meddler:"job_number"`
	Error    string `json:"error"        meddler:"job_error"`
	Status   string `json:"status"       meddler:"job_status"`
	ExitCode int    `json:"exit_code"    meddler:"job_exit_code"`
	Enqueued int64  `json:"enqueued_at"  meddler:"job_enqueued"`
	Started  int64  `json:"started_at"   meddler:"job_started"`
	Finished int64  `json:"finished_at"  meddler:"job_finished"`

	Environment map[string]string `json:"environment" meddler:"job_environment,json"`
}

swagger:model job

type Key

type Key struct {
	ID      int64  `json:"-"       meddler:"key_id,pk"`
	RepoID  int64  `json:"-"       meddler:"key_repo_id"`
	Public  string `json:"public"  meddler:"key_public"`
	Private string `json:"private" meddler:"key_private"`
}

type Log

type Log struct {
	ID    int64  `meddler:"log_id,pk"`
	JobID int64  `meddler:"log_job_id"`
	Data  []byte `meddler:"log_data"`
}

type Netrc

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

type Perm

type Perm struct {
	Pull  bool `json:"pull"`
	Push  bool `json:"push"`
	Admin bool `json:"admin"`
}

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"`
	Addr     string `json:"addr"     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"`
}

func (*Registry) Validate added in v0.4.2

func (r *Registry) Validate() error

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"`
	IsPrivate   bool   `json:"private,omitempty"        meddler:"repo_private"`
	IsTrusted   bool   `json:"trusted"                  meddler:"repo_trusted"`
	IsStarred   bool   `json:"starred,omitempty"        meddler:"-"`
	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"`
	Hash        string `json:"-"                        meddler:"repo_hash"`
}

Repo represents a repository.

swagger:model 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 RepoSecret added in v0.5.0

type RepoSecret struct {
	// the id for this secret.
	ID int64 `json:"id" meddler:"secret_id,pk"`

	// the foreign key for this secret.
	RepoID int64 `json:"-" meddler:"secret_repo_id"`

	// the name of the secret which will be used as the environment variable
	// name at runtime.
	Name string `json:"name" meddler:"secret_name"`

	// the value of the secret which will be provided to the runtime environment
	// as a named environment variable.
	Value string `json:"value" meddler:"secret_value"`

	// the secret is restricted to this list of images.
	Images []string `json:"image,omitempty" meddler:"secret_images,json"`

	// the secret is restricted to this list of events.
	Events []string `json:"event,omitempty" meddler:"secret_events,json"`

	// whether the secret requires verification
	SkipVerify bool `json:"skip_verify" meddler:"secret_skip_verify"`

	// whether the secret should be concealed in the build log
	Conceal bool `json:"conceal" meddler:"secret_conceal"`
}

func (*RepoSecret) Clone added in v0.5.0

func (s *RepoSecret) Clone() *RepoSecret

Clone provides a repo secrets clone without the value.

func (*RepoSecret) Secret added in v0.5.0

func (s *RepoSecret) Secret() *Secret

Secret transforms a repo secret into a simple secret.

func (*RepoSecret) Validate added in v0.5.0

func (s *RepoSecret) Validate() error

Validate validates the required fields and formats.

type Secret added in v0.4.2

type Secret struct {
	// the name of the secret which will be used as the environment variable
	// name at runtime.
	Name string `json:"name"`

	// the value of the secret which will be provided to the runtime environment
	// as a named environment variable.
	Value string `json:"value"`

	// the secret is restricted to this list of images.
	Images []string `json:"image,omitempty"`

	// the secret is restricted to this list of events.
	Events []string `json:"event,omitempty"`

	// whether the secret requires verification
	SkipVerify bool `json:"skip_verify"`

	// whether the secret should be concealed in the build log
	Conceal bool `json:"conceal"`
}

func (*Secret) Match added in v0.4.2

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

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

func (*Secret) MatchEvent added in v0.4.2

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

MatchEvent returns true if an event matches the restricted list.

func (*Secret) MatchImage added in v0.4.2

func (s *Secret) MatchImage(image string) bool

MatchImage returns true if an image matches the restricted list.

func (*Secret) Validate added in v0.4.2

func (s *Secret) Validate() error

Validate validates the required fields and formats.

type System

type System struct {
	Version   string   `json:"version"`
	Link      string   `json:"link_url"`
	Plugins   []string `json:"plugins"`
	Globals   []string `json:"globals"`
	Escalates []string `json:"privileged_plugins"`
}

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 TeamSecret added in v0.5.0

type TeamSecret struct {
	// the id for this secret.
	ID int64 `json:"id" meddler:"team_secret_id,pk"`

	// the foreign key for this secret.
	Key string `json:"-" meddler:"team_secret_key"`

	// the name of the secret which will be used as the environment variable
	// name at runtime.
	Name string `json:"name" meddler:"team_secret_name"`

	// the value of the secret which will be provided to the runtime environment
	// as a named environment variable.
	Value string `json:"value" meddler:"team_secret_value"`

	// the secret is restricted to this list of images.
	Images []string `json:"image,omitempty" meddler:"team_secret_images,json"`

	// the secret is restricted to this list of events.
	Events []string `json:"event,omitempty" meddler:"team_secret_events,json"`

	// whether the secret requires verification
	SkipVerify bool `json:"skip_verify" meddler:"team_secret_skip_verify"`

	// whether the secret should be concealed in the build log
	Conceal bool `json:"conceal" meddler:"team_secret_conceal"`
}

func (*TeamSecret) Clone added in v0.5.0

func (s *TeamSecret) Clone() *TeamSecret

Clone provides a repo secrets clone without the value.

func (*TeamSecret) Secret added in v0.5.0

func (s *TeamSecret) Secret() *Secret

Secret transforms a repo secret into a simple secret.

func (*TeamSecret) Validate added in v0.5.0

func (s *TeamSecret) Validate() error

Validate validates the required fields and formats.

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

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

type Work added in v0.5.0

type Work struct {
	Signed    bool      `json:"signed"`
	Verified  bool      `json:"verified"`
	Yaml      string    `json:"config"`
	YamlEnc   string    `json:"secret"`
	Repo      *Repo     `json:"repo"`
	Build     *Build    `json:"build"`
	BuildLast *Build    `json:"build_last"`
	Job       *Job      `json:"job"`
	Netrc     *Netrc    `json:"netrc"`
	Keys      *Key      `json:"keys"`
	System    *System   `json:"system"`
	Secrets   []*Secret `json:"secrets"`
	User      *User     `json:"user"`
}

Work represents an item for work to be processed by a worker.

Jump to

Keyboard shortcuts

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