model

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RemoteGithub           = "github.com"
	RemoteGitlab           = "gitlab.com"
	RemoteGithubEnterprise = "enterprise.github.com"
	RemoteBitbucket        = "bitbucket.org"
	RemoteStash            = "stash.atlassian.com"
	RemoteGogs             = "gogs"
)
View Source
const (
	StatusNone    = "None"
	StatusEnqueue = "Pending"
	StatusStarted = "Started"
	StatusSuccess = "Success"
	StatusFailure = "Failure"
	StatusError   = "Error"
	StatusKilled  = "Killed"
)

Variables

View Source
var (
	DefaultBranch = "master"

	// default build timeout, in seconds
	DefaultTimeout int64 = 7200
)
View Source
var DefaultExpires = int64(time.Hour.Seconds() * 72)

by default, let's expire the user cache after 72 hours

Functions

func CreateGravatar

func CreateGravatar(email string) string

helper function to create a Gravatar Hash for the given Email address.

func GenerateToken

func GenerateToken() string

GenerateToken generates random strings good for use in URIs to identify unique objects.

Types

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, c *Commit, url string) *CCProjects

type Commit

type Commit struct {
	ID          int64  `meddler:"commit_id,pk"     json:"id"`
	RepoID      int64  `meddler:"repo_id"          json:"-"`
	Status      string `meddler:"commit_status"    json:"status"`
	Started     int64  `meddler:"commit_started"   json:"started_at"`
	Finished    int64  `meddler:"commit_finished"  json:"finished_at"`
	Duration    int64  `meddler:"commit_duration"  json:"duration"`
	Sha         string `meddler:"commit_sha"       json:"sha"`
	Branch      string `meddler:"commit_branch"    json:"branch"`
	PullRequest string `meddler:"commit_pr"        json:"pull_request"`
	Author      string `meddler:"commit_author"    json:"author"`
	Gravatar    string `meddler:"commit_gravatar"  json:"gravatar"`
	Timestamp   string `meddler:"commit_timestamp" json:"timestamp"`
	Message     string `meddler:"commit_message"   json:"message"`
	Config      string `meddler:"commit_yaml"      json:"-"`
	Created     int64  `meddler:"commit_created"   json:"created_at"`
	Updated     int64  `meddler:"commit_updated"   json:"updated_at"`
}

func (*Commit) FinishedString

func (c *Commit) FinishedString() string

Returns the Started Date as an ISO8601 formatted string.

func (*Commit) SetAuthor

func (c *Commit) SetAuthor(email string)

SetAuthor sets the author's email address and calculate the Gravatar hash.

func (*Commit) ShaShort

func (c *Commit) ShaShort() string

Returns the Short (--short) Commit Hash.

type CommitRepo

type CommitRepo struct {
	Remote string `meddler:"repo_remote" json:"remote"`
	Host   string `meddler:"repo_host"   json:"host"`
	Owner  string `meddler:"repo_owner"  json:"owner"`
	Name   string `meddler:"repo_name"   json:"name"`

	CommitID    int64  `meddler:"commit_id,pk"     json:"-"`
	RepoID      int64  `meddler:"repo_id"          json:"-"`
	Status      string `meddler:"commit_status"    json:"status"`
	Started     int64  `meddler:"commit_started"   json:"started_at"`
	Finished    int64  `meddler:"commit_finished"  json:"finished_at"`
	Duration    int64  `meddler:"commit_duration"  json:"duration"`
	Sha         string `meddler:"commit_sha"       json:"sha"`
	Branch      string `meddler:"commit_branch"    json:"branch"`
	PullRequest string `meddler:"commit_pr"        json:"pull_request"`
	Author      string `meddler:"commit_author"    json:"author"`
	Gravatar    string `meddler:"commit_gravatar"  json:"gravatar"`
	Timestamp   string `meddler:"commit_timestamp" json:"timestamp"`
	Message     string `meddler:"commit_message"   json:"message"`
	Config      string `meddler:"commit_yaml"      json:"-"`
	Created     int64  `meddler:"commit_created"   json:"created_at"`
	Updated     int64  `meddler:"commit_updated"   json:"updated_at"`
}

type Hook

type Hook struct {
	Owner       string
	Repo        string
	Sha         string
	Branch      string
	PullRequest string
	Author      string
	Gravatar    string
	Timestamp   string
	Message     string
}

Hook represents a subset of commit meta-data provided by post-commit and pull request hooks.

type Login

type Login struct {
	ID     int64
	Login  string
	Access string
	Secret string
	Name   string
	Email  string
	Expiry int64
}

Login represents a standard subset of user meta-data provided by OAuth login services.

type Perm

type Perm struct {
	ID      int64 `meddler:"perm_id,pk"   json:"-"`
	UserID  int64 `meddler:"user_id"      json:"-"`
	RepoID  int64 `meddler:"repo_id"      json:"-"`
	Read    bool  `meddler:"perm_read"    json:"read"`
	Write   bool  `meddler:"perm_write"   json:"write"`
	Admin   bool  `meddler:"perm_admin"   json:"admin"`
	Guest   bool  `meddler:"-"            json:"guest"`
	Created int64 `meddler:"perm_created" json:"-"`
	Updated int64 `meddler:"perm_updated" json:"-"`
}

type Remote

type Remote struct {
	ID     int64  `meddler:"remote_id,pk"  json:"id"`
	Type   string `meddler:"remote_type"   json:"type"`
	Host   string `meddler:"remote_host"   json:"host"`
	URL    string `meddler:"remote_url"    json:"url"`
	API    string `meddler:"remote_api"    json:"api"`
	Client string `meddler:"remote_client" json:"client"`
	Secret string `meddler:"remote_secret" json:"secret"`
	Open   bool   `meddler:"remote_open"   json:"open"`
}

type Repo

type Repo struct {
	ID     int64  `meddler:"repo_id,pk"        json:"-"`
	UserID int64  `meddler:"user_id"           json:"-"`
	Token  string `meddler:"repo_token"        json:"-"`
	Remote string `meddler:"repo_remote"       json:"remote"`
	Host   string `meddler:"repo_host"         json:"host"`
	Owner  string `meddler:"repo_owner"        json:"owner"`
	Name   string `meddler:"repo_name"         json:"name"`

	URL      string `meddler:"repo_url"       json:"url"`
	CloneURL string `meddler:"repo_clone_url" json:"clone_url"`
	GitURL   string `meddler:"repo_git_url"   json:"git_url"`
	SSHURL   string `meddler:"repo_ssh_url"   json:"ssh_url"`

	Active      bool   `meddler:"repo_active"       json:"active"`
	Private     bool   `meddler:"repo_private"      json:"private"`
	Privileged  bool   `meddler:"repo_privileged"   json:"privileged"`
	PostCommit  bool   `meddler:"repo_post_commit"  json:"post_commits"`
	PullRequest bool   `meddler:"repo_pull_request" json:"pull_requests"`
	PublicKey   string `meddler:"repo_public_key"   json:"-"`
	PrivateKey  string `meddler:"repo_private_key"  json:"-"`
	Params      string `meddler:"repo_params"       json:"-"`
	Timeout     int64  `meddler:"repo_timeout"      json:"timeout"`
	Created     int64  `meddler:"repo_created"      json:"created_at"`
	Updated     int64  `meddler:"repo_updated"      json:"updated_at"`

	// Role defines the user's role relative to this repository.
	// Note that this data is stored separately in the datastore,
	// and must be joined to populate.
	Role *Perm `meddler:"-" json:"role,omitempty"`
}

func NewRepo

func NewRepo(remote, owner, name string) (*Repo, error)

func (*Repo) ParamMap

func (r *Repo) ParamMap() (map[string]string, error)

type RepoParams

type RepoParams map[string]string

RepoParams represents a set of private key value parameters for each Repository.

type Request

type Request struct {
	Host   string  `json:"-"`
	User   *User   `json:"-"`
	Repo   *Repo   `json:"repo"`
	Commit *Commit `json:"commit"`
	Prior  *Commit `json:"prior_commit"`
}

func (*Request) URL

func (r *Request) URL() string

URL returns the link to the commit in string format.

type Token

type Token struct {
	AccessToken  string
	RefreshToken string
	Expiry       int64
}

type User

type User struct {
	ID          int64  `meddler:"user_id,pk"          json:"-"`
	Remote      string `meddler:"user_remote"         json:"remote"`
	Login       string `meddler:"user_login"          json:"login"`
	Access      string `meddler:"user_access"         json:"-"`
	Secret      string `meddler:"user_secret"         json:"-"`
	Name        string `meddler:"user_name"           json:"name"`
	Email       string `meddler:"user_email"          json:"email,omitempty"`
	Gravatar    string `meddler:"user_gravatar"       json:"gravatar"`
	Token       string `meddler:"user_token"          json:"-"`
	Admin       bool   `meddler:"user_admin"          json:"admin"`
	Active      bool   `meddler:"user_active"         json:"active"`
	Syncing     bool   `meddler:"user_syncing"        json:"syncing"`
	Created     int64  `meddler:"user_created"        json:"created_at"`
	Updated     int64  `meddler:"user_updated"        json:"updated_at"`
	Synced      int64  `meddler:"user_synced"         json:"synced_at"`
	TokenExpiry int64  `meddler:"user_access_expires,zeroisnull" json:"-"`
}

func NewUser

func NewUser(remote, login, email string) *User

func (*User) IsStale

func (u *User) IsStale() bool

func (*User) SetEmail

func (u *User) SetEmail(email string)

SetEmail sets the email address and calculate the Gravatar hash.

Jump to

Keyboard shortcuts

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