Documentation ¶
Index ¶
- Variables
- func MakeStatus(res, set bool) *bool
- func MakeTime(ts *timestamp.Timestamp, nullable bool) *time.Time
- func MakeTimestamp(t *time.Time) *timestamp.Timestamp
- func MakeUserList(users []*User) []*types.User
- type Capability
- type Model
- func (m *Model) AddCapabilityToUser(u *User, cap Capability) error
- func (m *Model) AddSubscriptionsForUser(u *User, repos []*Repository) error
- func (m *Model) AssignRepository(repo *Repository, owner *User) error
- func (m *Model) CancelRefByName(repoID int64, refName, baseURL string, gh github.Client) error
- func (m *Model) CancelRun(runID int64, baseURL string, gh github.Client) error
- func (m *Model) CancelSubmissionByID(id int64, baseURL string, client github.Client) error
- func (m *Model) CancelTask(task *Task, baseURL string, gh github.Client) error
- func (m *Model) CancelTaskByID(id int64, baseURL string, gh github.Client) error
- func (m *Model) CancelTasksForPR(repository string, prID int64, baseURL string) error
- func (m *Model) CountRunsForTask(id int64) (int64, error)
- func (m *Model) CountTasks(repository, sha string) (int64, error)
- func (m *Model) CreateUser(username string, token *topTypes.OAuthToken) (*User, error)
- func (m *Model) DeleteError(u *User, id int64) error
- func (m *Model) DeleteToken(name string) error
- func (m *Model) DisableRepository(repo *Repository) error
- func (m *Model) EnableRepository(repo *Repository, owner *User) error
- func (m *Model) FindUserByID(id int64) (*User, error)
- func (m *Model) FindUserByName(username string) (*User, error)
- func (m *Model) FindUserByNameWithSubscriptions(username, search string) (*User, error)
- func (m *Model) GetAllPublicRepos(search string) (RepositoryList, error)
- func (m *Model) GetCancelForRun(runID int64) (bool, error)
- func (m *Model) GetCapabilities(u *User, fixedCaps map[string][]string) ([]Capability, error)
- func (m *Model) GetOwnedRepos(u *User, search string) (RepositoryList, error)
- func (m *Model) GetPrivateReposForUser(u *User, search string) (RepositoryList, error)
- func (m *Model) GetRefByNameAndSHA(repoName string, sha string) (*Ref, error)
- func (m *Model) GetRepositoryByName(name string) (*Repository, error)
- func (m *Model) GetRepositoryByNameForUser(name string, u *User) (*Repository, error)
- func (m *Model) GetRunsForTask(id, page, perPage int64) ([]*Run, error)
- func (m *Model) GetSubmissionByID(id int64) (*Submission, error)
- func (m *Model) GetToken(name string) (string, error)
- func (m *Model) GetVisibleReposForUser(u *User, search string) (RepositoryList, error)
- func (m *Model) HasCapability(u *User, cap Capability, fixedCaps map[string][]string) (bool, error)
- func (m *Model) ListSubscribedTasksForUser(userID, page, perPage int64) ([]*Task, error)
- func (m *Model) ListTasks(repository, sha string, page, perPage int64) ([]*Task, error)
- func (m *Model) LoadSession(id string) (*Session, error)
- func (m *Model) NewSubmissionFromMessage(sub *types.Submission) (*Submission, error)
- func (m *Model) NextQueueItem(runningOn string, queueName string) (*QueueItem, error)
- func (m *Model) OAuthRegisterState(state string, scopes []string) error
- func (m *Model) OAuthValidateState(state string) (*OAuth, error)
- func (m *Model) PutRef(ref *Ref) error
- func (m *Model) QueueList(page, perPage int64) ([]*QueueItem, error)
- func (m *Model) QueueListForRepository(repo *Repository, page, perPage int64) ([]*QueueItem, error)
- func (m *Model) QueuePipelineAdd(qis []*QueueItem) ([]*QueueItem, error)
- func (m *Model) QueueTotalCount() (int64, error)
- func (m *Model) QueueTotalCountForRepository(repo *Repository) (int64, error)
- func (m *Model) RemoveCapabilityFromUser(u *User, cap Capability) error
- func (m *Model) RemoveSubscriptionForUser(u *User, repo *Repository) error
- func (m *Model) RunList(page, perPage int64, repository, sha string) ([]*Run, error)
- func (m *Model) RunListForRepository(repo *Repository, ref *Ref, page, perPage int64) ([]*Run, error)
- func (m *Model) RunTotalCount() (int64, error)
- func (m *Model) RunTotalCountForRepository(repo *Repository) (int64, error)
- func (m *Model) RunTotalCountForRepositoryAndSHA(repo *Repository, sha string) (int64, error)
- func (m *Model) RunsForSubmission(sub *Submission, page, perPage int64) ([]*Run, error)
- func (m *Model) RunsForTicket(repoName string, ticketID int) ([]*Run, error)
- func (m *Model) SaveRepositories(repos []*gh.Repository, username string, autoCreated bool) error
- func (m *Model) SaveSession(session *Session) error
- func (m *Model) SetRunStatus(runID int64, gh github.Client, status, canceled bool, url, addlMessage string) error
- func (m *Model) SubmissionCount(repository, sha string) (int64, error)
- func (m *Model) SubmissionList(page, perPage int64, repository, sha string) ([]*Submission, error)
- func (m *Model) SubmissionListForRepository(repo, sha string, page, perPage int64) ([]*Submission, error)
- func (m *Model) TasksForSubmission(sub *Submission, page, perPage int64) ([]*Task, error)
- func (m *Model) UpdateTaskStatus(task *Task) error
- func (m *Model) ValidateToken(token string) (*User, error)
- func (m *Model) WrapError(call *gorm.DB, msg string) error
- type OAuth
- type QueueItem
- type Ref
- type Repository
- func (r *Repository) AfterFind(tx *gorm.DB) error
- func (r *Repository) BeforeCreate(tx *gorm.DB) error
- func (r *Repository) BeforeSave(tx *gorm.DB) error
- func (r *Repository) Enabled() bool
- func (r *Repository) OwnerRepo() (string, string, error)
- func (r *Repository) ToProto() *types.Repository
- func (r *Repository) Validate(validOwner bool) error
- type RepositoryList
- type Run
- type Session
- type Submission
- type Task
- type User
- func (u *User) AddError(err error)
- func (u *User) AfterFind(tx *gorm.DB) error
- func (u *User) BeforeCreate(tx *gorm.DB) error
- func (u *User) BeforeSave(tx *gorm.DB) error
- func (u *User) FetchToken() error
- func (u *User) SetToken() error
- func (u *User) ToProto() *types.User
- func (u *User) Validate() error
- func (u *User) ValidateWrite() error
- type UserError
Constants ¶
This section is empty.
Variables ¶
var ( // AllCapabilities comprises the superuser account's list of capabilities. AllCapabilities = []Capability{CapabilityModifyCI, CapabilityModifyUser, CapabilitySubmit, CapabilityCancel} // TokenCryptKey is the standard token crypt key. // NOTE: the default is only used by tests; it is overwritten on service boot; see config/auth.go. TokenCryptKey = []byte{1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8} )
var OAuthExpiration = 10 * time.Minute
OAuthExpiration is a constant for the oauth state expiration time. It really should be in the configuration.
Functions ¶
func MakeStatus ¶
MakeStatus returns nil if set is false and the bool is false, indicating that it is not set.
func MakeTime ¶
MakeTime takes a protobuf timestamp and makes a time.Time out of it. If you pass true to the second argument, it will return nil if the argument is the zero value. Otherwise, it returns a time.Unix(0, 0).
func MakeTimestamp ¶
MakeTimestamp takes a time.Time and makes a protobuf timestamp out of it.
func MakeUserList ¶
MakeUserList returns the inverse of MakeUsers.
Types ¶
type Capability ¶
type Capability string
Capability is a type of access gating mechanism. If present on the user account access is granted, otherwise not.
const ( // CapabilityModifyCI is required for modifying CI properties such as adding or removing a repo. CapabilityModifyCI Capability = "modify:ci" // CapabilityModifyUser allows you to modify users; including caps. CapabilityModifyUser Capability = "modify:user" // CapabilitySubmit allows manual submissions CapabilitySubmit Capability = "submit" // CapabilityCancel allows cancels CapabilityCancel Capability = "cancel" )
type Model ¶
Model is the outer layer of our internal database model, which will primarily be used by the data service.
func (*Model) AddCapabilityToUser ¶
func (m *Model) AddCapabilityToUser(u *User, cap Capability) error
AddCapabilityToUser adds a capability to a user account.
func (*Model) AddSubscriptionsForUser ¶
func (m *Model) AddSubscriptionsForUser(u *User, repos []*Repository) error
AddSubscriptionsForUser adds the repositories to the subscriptions table. Access is validated at the API level, not here.
func (*Model) AssignRepository ¶
func (m *Model) AssignRepository(repo *Repository, owner *User) error
AssignRepository assigns the repository to the user explicitly.
func (*Model) CancelRefByName ¶
CancelRefByName is used in auto cancellation on new queue item arrivals. It finds all the runs associated with the ref and cancels them if they are in queue still. Do note that it does not match the SHA; more often than not this is caused by an --amend + force push which updates the SHA, or a new commit which also changes the SHA. The name is the only reliable data in this case.
func (*Model) CancelRun ¶
CancelRun is a thin facade for the CancelTask functionality, loading the record from the ID provided.
func (*Model) CancelSubmissionByID ¶
CancelSubmissionByID cancels all related tasks (and thusly, runs) in a submission that are outstanding.
func (*Model) CancelTask ¶
CancelTask finds the queue items and runs for the task, removes them, cancels the associated runs for the task, and finally, saves the task itself. It will fail to do all of this if the task is already finished.
func (*Model) CancelTaskByID ¶
CancelTaskByID cancels a task by ID
func (*Model) CancelTasksForPR ¶
CancelTasksForPR cancels all tasks for a PR.
func (*Model) CountRunsForTask ¶
CountRunsForTask retrieves the total count of runs for the given task.
func (*Model) CountTasks ¶
CountTasks counts all the tasks, optionally based on the repository and sha.
func (*Model) CreateUser ¶
CreateUser initializes a user struct and writes it to the db.
func (*Model) DeleteError ¶
DeleteError deletes a given error for a user.
func (*Model) DeleteToken ¶
DeleteToken removes the existing token.
func (*Model) DisableRepository ¶
func (m *Model) DisableRepository(repo *Repository) error
DisableRepository removes it from CI.
func (*Model) EnableRepository ¶
func (m *Model) EnableRepository(repo *Repository, owner *User) error
EnableRepository adds it to CI.
func (*Model) FindUserByID ¶
FindUserByID finds the user by integer ID.
func (*Model) FindUserByName ¶
FindUserByName finds a user by unique key username.
func (*Model) FindUserByNameWithSubscriptions ¶
FindUserByNameWithSubscriptions finds a user by unique key username. It also fetches the subscriptions for the user.
func (*Model) GetAllPublicRepos ¶
func (m *Model) GetAllPublicRepos(search string) (RepositoryList, error)
GetAllPublicRepos retrieves all repos that are not private
func (*Model) GetCancelForRun ¶
GetCancelForRun satisfies the datasvc interface by finding the underlying task's canceled state.
func (*Model) GetCapabilities ¶
GetCapabilities returns the capabilities the supplied user account has.
func (*Model) GetOwnedRepos ¶
func (m *Model) GetOwnedRepos(u *User, search string) (RepositoryList, error)
GetOwnedRepos returns all repos the user owns.
func (*Model) GetPrivateReposForUser ¶
func (m *Model) GetPrivateReposForUser(u *User, search string) (RepositoryList, error)
GetPrivateReposForUser retrieves all private repos that the user owns.
func (*Model) GetRefByNameAndSHA ¶
GetRefByNameAndSHA returns the ref matching the name/sha combination.
func (*Model) GetRepositoryByName ¶
func (m *Model) GetRepositoryByName(name string) (*Repository, error)
GetRepositoryByName retrieves the repository by its unique name.
func (*Model) GetRepositoryByNameForUser ¶
func (m *Model) GetRepositoryByNameForUser(name string, u *User) (*Repository, error)
GetRepositoryByNameForUser retrieves the repository by name if the user can see it (aka, if it's not private or if it's owned by them)
func (*Model) GetRunsForTask ¶
GetRunsForTask is just a join of all runs that belong to a task.
func (*Model) GetSubmissionByID ¶
func (m *Model) GetSubmissionByID(id int64) (*Submission, error)
GetSubmissionByID returns a submission by internal identifier
func (*Model) GetToken ¶
GetToken retrieves a new token for logging in. If one exists, the DeleteToken method must be called first; otherwise this routine will throw an error.
func (*Model) GetVisibleReposForUser ¶
func (m *Model) GetVisibleReposForUser(u *User, search string) (RepositoryList, error)
GetVisibleReposForUser retrieves all repos the user can "see" in the database.
func (*Model) HasCapability ¶
HasCapability returns true if the user is capable of performing the operation.
func (*Model) ListSubscribedTasksForUser ¶
ListSubscribedTasksForUser lists all tasks related to the subscribed repositories for the user.
func (*Model) ListTasks ¶
ListTasks gathers all the tasks based on the page and perPage values. It can optionally filter by repository and SHA.
func (*Model) LoadSession ¶
LoadSession loads a session based on the key and returns it to the client
func (*Model) NewSubmissionFromMessage ¶
func (m *Model) NewSubmissionFromMessage(sub *types.Submission) (*Submission, error)
NewSubmissionFromMessage creates a blank record populated by the appropriate data reaped from the message type in types/submission.go.
func (*Model) NextQueueItem ¶
NextQueueItem returns the next item in the named queue. If for some reason the queueName is an empty string, the string `default` will be used instead.
func (*Model) OAuthRegisterState ¶
OAuthRegisterState registers a state code in a uniqueness table that tracks it.
func (*Model) OAuthValidateState ¶
OAuthValidateState validates that the state we sent actually exists and is ready to be consumed. In the event it is not, it returns error.
func (*Model) QueueListForRepository ¶
func (m *Model) QueueListForRepository(repo *Repository, page, perPage int64) ([]*QueueItem, error)
QueueListForRepository returns a list of queue items with pagination.
func (*Model) QueuePipelineAdd ¶
QueuePipelineAdd adds a group of queue items in a transaction.
func (*Model) QueueTotalCount ¶
QueueTotalCount returns the number of items in the queue
func (*Model) QueueTotalCountForRepository ¶
func (m *Model) QueueTotalCountForRepository(repo *Repository) (int64, error)
QueueTotalCountForRepository returns the number of items in the queue where the parent fork matches the repository name given
func (*Model) RemoveCapabilityFromUser ¶
func (m *Model) RemoveCapabilityFromUser(u *User, cap Capability) error
RemoveCapabilityFromUser removes a capability from a user account.
func (*Model) RemoveSubscriptionForUser ¶
func (m *Model) RemoveSubscriptionForUser(u *User, repo *Repository) error
RemoveSubscriptionForUser removes an item from the subscriptions table.
func (*Model) RunListForRepository ¶
func (m *Model) RunListForRepository(repo *Repository, ref *Ref, page, perPage int64) ([]*Run, error)
RunListForRepository returns a list of queue items with pagination. If ref is non-nil, it will isolate to the ref only.
func (*Model) RunTotalCount ¶
RunTotalCount returns the number of items in the runs table
func (*Model) RunTotalCountForRepository ¶
func (m *Model) RunTotalCountForRepository(repo *Repository) (int64, error)
RunTotalCountForRepository returns the number of items in the queue where the parent fork matches the repository name given
func (*Model) RunTotalCountForRepositoryAndSHA ¶
func (m *Model) RunTotalCountForRepositoryAndSHA(repo *Repository, sha string) (int64, error)
RunTotalCountForRepositoryAndSHA returns the number of items in the queue where the parent fork matches the repository name given
func (*Model) RunsForSubmission ¶
func (m *Model) RunsForSubmission(sub *Submission, page, perPage int64) ([]*Run, error)
RunsForSubmission returns all the runs that are associated with the given submission.
func (*Model) RunsForTicket ¶
RunsForTicket all the runs that belong to a repository's PR.
func (*Model) SaveRepositories ¶
SaveRepositories saves github repositories; it sets the *User provided to the owner of it.
func (*Model) SaveSession ¶
SaveSession does the opposite of LoadSession
func (*Model) SetRunStatus ¶
func (m *Model) SetRunStatus(runID int64, gh github.Client, status, canceled bool, url, addlMessage string) error
SetRunStatus sets the status for the run; fails if it is already set.
func (*Model) SubmissionCount ¶
SubmissionCount counts the number of submissions with an optional repo/sha filter
func (*Model) SubmissionList ¶
func (m *Model) SubmissionList(page, perPage int64, repository, sha string) ([]*Submission, error)
SubmissionList returns a list of submissions with pagination and repo/sha filtering.
func (*Model) SubmissionListForRepository ¶
func (m *Model) SubmissionListForRepository(repo, sha string, page, perPage int64) ([]*Submission, error)
SubmissionListForRepository returns a list of submissions with pagination. If ref is non-nil, it will isolate to the ref only and ignore the repo.
func (*Model) TasksForSubmission ¶
func (m *Model) TasksForSubmission(sub *Submission, page, perPage int64) ([]*Task, error)
TasksForSubmission returns all the tasks for a given submission.
func (*Model) UpdateTaskStatus ¶
UpdateTaskStatus is triggered when a run state change happens that is *not* a cancellation.
func (*Model) ValidateToken ¶
ValidateToken checks that a token is valid for a given user.
type OAuth ¶
type OAuth struct { State string `gorm:"primary key" json:"state"` Scopes string `json:"scopes"` ExpiresOn time.Time `json:"expires_on"` }
OAuth schema is for checking state return values from github.
func (*OAuth) GetScopesList ¶
GetScopesList returns the split list of scopes
func (*OAuth) SetScopes ¶
SetScopes takes a []string of scope names, and marshals them to the struct field.
func (*OAuth) ToProto ¶
func (o *OAuth) ToProto() *data.OAuthState
ToProto returns a protobuf representation of the model oauth request
type QueueItem ¶
type QueueItem struct { ID int64 `gorm:"primary_key" json:"id"` Run *Run `json:"run"` RunID int64 `json:"-"` Running bool `json:"running"` RunningOn *string `json:"running_on,omitempty"` StartedAt *time.Time `json:"started_at,omitempty"` QueueName string `json:"queue_name"` }
QueueItem represents an item in the queue table in the database.
func NewQueueItemFromProto ¶
NewQueueItemFromProto converts in the opposite direction of ToProto.
func (*QueueItem) AfterFind ¶
AfterFind validates the output from the database before releasing it to the hook chain
func (*QueueItem) BeforeCreate ¶
BeforeCreate just calls BeforeSave.
func (*QueueItem) BeforeSave ¶
BeforeSave is a gorm hook to marshal the token JSON before saving the record
type Ref ¶
type Ref struct { ID int64 `gorm:"primary_key" json:"id"` Repository *Repository `json:"repository" gorm:"unique;association_autoupdate:false"` RepositoryID int64 `json:"-"` RefName string `gorm:"column:ref" json:"ref_name"` SHA string `json:"sha"` }
Ref encapsulates git ref -- sha or branch name -- which is tied to a task (and multiple runs, potentially)
func NewRefFromProto ¶
NewRefFromProto converts a proto ref to a real ref.
func (*Ref) AfterFind ¶
AfterFind validates the output from the database before releasing it to the hook chain
func (*Ref) BeforeCreate ¶
BeforeCreate just calls BeforeSave.
func (*Ref) BeforeSave ¶
BeforeSave is a gorm hook to marshal the token JSON before saving the record
type Repository ¶
type Repository struct { ID int64 `gorm:"primary_key" json:"id"` Name string `gorm:"unique" json:"name"` Private bool `json:"private"` Disabled bool `json:"disabled"` GithubJSON []byte `gorm:"column:github" json:"-"` OwnerID int64 `json:"-"` Owner *User `gorm:"association_autoupdate:false" json:"-"` AutoCreated bool `json:"auto_created"` HookSecret string `json:"-"` Github *gh.Repository `json:"github"` }
Repository is the encapsulation of a git repository.
func NewRepositoryFromProto ¶
func NewRepositoryFromProto(r *types.Repository) (*Repository, error)
NewRepositoryFromProto converts a proto repository to a model repository.
func (*Repository) AfterFind ¶
func (r *Repository) AfterFind(tx *gorm.DB) error
AfterFind validates the output from the database before releasing it to the hook chain
func (*Repository) BeforeCreate ¶
func (r *Repository) BeforeCreate(tx *gorm.DB) error
BeforeCreate just calls BeforeSave.
func (*Repository) BeforeSave ¶
func (r *Repository) BeforeSave(tx *gorm.DB) error
BeforeSave is a gorm hook to marshal the token JSON before saving the record
func (*Repository) Enabled ¶
func (r *Repository) Enabled() bool
Enabled is merely a predicate to determine if the repo can be used or not
func (*Repository) OwnerRepo ¶
func (r *Repository) OwnerRepo() (string, string, error)
OwnerRepo validates the owner/repo github path then returns each part.
func (*Repository) ToProto ¶
func (r *Repository) ToProto() *types.Repository
ToProto returns the protobuf representation of the repository
func (*Repository) Validate ¶
func (r *Repository) Validate(validOwner bool) error
Validate validates the repository object
type RepositoryList ¶
type RepositoryList []*Repository
RepositoryList conforms to the sort.Interface interface
func (RepositoryList) Less ¶
func (rl RepositoryList) Less(i, j int) bool
Less determines the order of the list
func (RepositoryList) Swap ¶
func (rl RepositoryList) Swap(i, j int)
func (RepositoryList) ToProto ¶
func (rl RepositoryList) ToProto() *types.RepositoryList
ToProto converts the repository list to a protobuf representation
type Run ¶
type Run struct { ID int64 `gorm:"primary_key" json:"id"` RunSettingsJSON []byte `gorm:"column:run_settings" json:"-"` Name string `json:"name"` CreatedAt time.Time `json:"created_at"` StartedAt *time.Time `json:"started_at,omitempty"` FinishedAt *time.Time `json:"finished_at,omitempty"` Status *bool `json:"status,omitempty"` Task *Task `gorm:"association_autoupdate:false" json:"task"` TaskID int64 `json:"-"` RanOn *string `json:"ran_on"` RunSettings *types.RunSettings `json:"settings"` }
Run is the individual parallel run. Runs are organized into the queue service for handing out to runners in order. Multiple runs are make up a task.
func NewRunFromProto ¶
NewRunFromProto yields a new run from a protobuf message.
func (*Run) AfterFind ¶
AfterFind validates the output from the database before releasing it to the hook chain
func (*Run) BeforeCreate ¶
BeforeCreate just calls BeforeSave.
func (*Run) BeforeSave ¶
BeforeSave is a gorm hook to marshal the token JSON before saving the record
type Session ¶
type Session struct { Key string `gorm:"primary_key" json:"key"` Values string `json:"values"` ExpiresOn time.Time `json:"expires_on"` }
Session corresponds to the `sessions` table and encapsulates a web session.
func NewSessionFromProto ¶
NewSessionFromProto returns a session from a protobuf representation.
type Submission ¶
type Submission struct { ID int64 `gorm:"priamry_key" json:"id"` User *User `gorm:"association_autoupdate:false,nullable:true" json:"user"` UserID int64 `json:"-"` HeadRef *Ref `gorm:"association_autoupdate:false,column:head_ref_id,nullable:true" json:"head_ref"` HeadRefID int64 `json:"-"` BaseRef *Ref `gorm:"association_autoupdate:false,column:base_ref_id" json:"base_ref"` BaseRefID int64 `json:"-"` TasksCount int64 `json:"tasks_count" gorm:"-"` RunsCount int64 `json:"runs_count" gorm:"-"` Status *bool `json:"status" gorm:"-"` CreatedAt time.Time `json:"created_at"` StartedAt *time.Time `json:"started_at" gorm:"-"` FinishedAt *time.Time `json:"finished_at" gorm:"-"` Canceled bool `json:"canceled" gorm:"-"` TicketID int64 `json:"ticket_id"` }
Submission is the concrete type for a test submission, unlike types/submission.go which is the ephemeral type for messages and so on. Each submission has it own ID and list of tasks so that we can further give the user the opportunity to aggregate their tasks into a single unit.
func NewSubmissionFromProto ¶
func NewSubmissionFromProto(gt *gtypes.Submission) (*Submission, error)
NewSubmissionFromProto converts the proto representation to the task type.
func (*Submission) ToProto ¶
func (s *Submission) ToProto() *gtypes.Submission
ToProto converts the submissions to the protobuf version
type Task ¶
type Task struct { ID int64 `gorm:"primary_key" json:"id"` Path string `json:"path"` TaskSettingsJSON []byte `gorm:"column:task_settings" json:"-"` Canceled bool `json:"canceled"` FinishedAt *time.Time `json:"finished_at,omitempty"` StartedAt *time.Time `json:"started_at,omitempty"` CreatedAt time.Time `json:"created_at"` Status *bool `json:"status,omitempty"` TaskSettings *types.TaskSettings `json:"settings"` Runs int64 `json:"runs" gorm:"-"` Submission *Submission `gorm:"association_autoupdate:false" json:"submission"` SubmissionID int64 `json:"-"` }
Task is the organizational unit of a single source-controlled directory. It contains many runs; it the settings are kept in a file named `task.yml` and lives in the directory it is testing.
func NewTaskFromProto ¶
NewTaskFromProto converts the proto representation to the task type.
func (*Task) AfterFind ¶
AfterFind validates the output from the database before releasing it to the hook chain
func (*Task) BeforeCreate ¶
BeforeCreate just calls BeforeSave.
func (*Task) BeforeSave ¶
BeforeSave is a gorm hook to marshal the token JSON before saving the record
type User ¶
type User struct { ID int64 `gorm:"primary_key" json:"id"` Username string `gorm:"unique" json:"username"` LastScannedRepos *time.Time `json:"last_scanned_repos,omitempty"` Errors []UserError `json:"errors,omitempty"` Subscribed []*Repository `gorm:"many2many:subscriptions;preload:false" json:"subscribed,omitempty"` LoginToken []byte `json:"-"` TokenJSON []byte `gorm:"column:token;not null" json:"-"` Token *topTypes.OAuthToken `json:"-"` }
User is a user record.
func NewUserFromProto ¶
NewUserFromProto converts a proto user to a real user.
func (*User) AfterFind ¶
AfterFind is a gorm hook to unmarshal the Token JSON after finding the record.
func (*User) BeforeCreate ¶
BeforeCreate just calls BeforeSave.
func (*User) BeforeSave ¶
BeforeSave is a gorm hook to marshal the Token JSON before saving the record
func (*User) FetchToken ¶
FetchToken retrieves the token from the db, decrypting it if necessary.
func (*User) ValidateWrite ¶
ValidateWrite is for write-only validations.
type UserError ¶
type UserError struct { ID int64 `gorm:"primary key" json:"id"` UserID int64 `json:"-"` Error string `json:"error"` }
UserError is the encapsulation of many errors that need to be presented to the user.
func NewUserErrorFromProto ¶
NewUserErrorFromProto converts a user error from proto to canonical representation