models

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrNotSupportedSCM

func IsErrNotSupportedSCM(err error) bool

IsErrNotSupportedSCM check

func NewDatabaseService

func NewDatabaseService(db *gorm.DB) core.DatabaseService

NewDatabaseService with GORM

Types

type Coverage added in v0.1.0

type Coverage struct {
	gorm.Model
	Data     []byte
	Type     string
	ReportID uint
}

Coverage defines test coverage report

func (*Coverage) ToCoreCoverage added in v0.1.0

func (c *Coverage) ToCoreCoverage() (*core.CoverageReport, error)

ToCoreCoverage unmarshal Coverage Data

type OAuthStore added in v0.1.8

type OAuthStore struct {
	DB core.DatabaseService
}

OAuthStore tokens

func (*OAuthStore) Create added in v0.1.8

func (store *OAuthStore) Create(token *core.OAuthToken) error

Create token

func (*OAuthStore) Delete added in v0.1.8

func (store *OAuthStore) Delete(token *core.OAuthToken) error

Delete token with seed

func (*OAuthStore) Find added in v0.1.8

func (store *OAuthStore) Find(token *core.OAuthToken) (*core.OAuthToken, error)

Find token with seed

func (*OAuthStore) List added in v0.1.8

func (store *OAuthStore) List(user *core.User) ([]*core.OAuthToken, error)

List user's oauth tokens

type OAuthToken added in v0.1.8

type OAuthToken struct {
	gorm.Model
	Name    string `gorm:"index"`
	Code    string `gorm:"index"`
	Access  string `gorm:"index"`
	Refresh string `gorm:"index"`
	Expires time.Time
	OwnerID uint
	Owner   *User `gorm:"foreignKey:OwnerID"`
	Data    []byte
}

OAuthToken information

func (OAuthToken) TableName added in v0.1.8

func (OAuthToken) TableName() string

TableName for GORM

type Reference added in v0.1.0

type Reference struct {
	gorm.Model
	ReportID string    `gorm:"size:256;uniqueIndex:reference_record"`
	Name     string    `gorm:"size:256;uniqueIndex:reference_record"`
	Reports  []*Report `gorm:"many2many:report_reference"`
}

Reference of Report, such as branch or tag name

type Repo

type Repo struct {
	gorm.Model
	URL       string `gorm:"size:256;uniqueIndex;not null"`
	ReportID  string
	NameSpace string `gorm:"index;not null"`
	Name      string `gorm:"index;not null"`
	Branch    string
	SCM       string `gorm:"index;not null"`
	Creator   string
	Private   bool
}

Repo defines a repository

func (*Repo) ToCoreRepo

func (repo *Repo) ToCoreRepo() *core.Repo

ToCoreRepo object

type RepoHook

type RepoHook struct {
	gorm.Model
	RepoID uint `gorm:"index"`
	Hook   string
}

RepoHook defines created hooks in a repository

type RepoSetting

type RepoSetting struct {
	gorm.Model
	RepoID uint `gorm:"uniqueIndex"`
	Config []byte
}

RepoSetting defines user customization

func (*RepoSetting) Update

func (setting *RepoSetting) Update(newSetting *core.RepoSetting) error

Update with a new setting

type RepoStore

type RepoStore struct {
	DB core.DatabaseService
}

RepoStore repositories in storage

func (*RepoStore) BatchUpdateOrCreate added in v0.1.9

func (store *RepoStore) BatchUpdateOrCreate(repos []*core.Repo) error

BatchUpdateOrCreate repositories

func (*RepoStore) Create

func (store *RepoStore) Create(repo *core.Repo) error

Create a new repository

func (*RepoStore) Creator

func (store *RepoStore) Creator(repo *core.Repo) (*core.User, error)

Creator user who activated the repository

func (*RepoStore) Find

func (store *RepoStore) Find(repo *core.Repo) (*core.Repo, error)

Find Repo with seed. The non-empty filed of input will use as where condition

func (*RepoStore) FindHook

func (store *RepoStore) FindHook(repo *core.Repo) (*core.Hook, error)

FindHook for the repository

func (*RepoStore) Finds

func (store *RepoStore) Finds(urls ...string) ([]*core.Repo, error)

Finds all repositories with URLs

func (*RepoStore) Setting

func (store *RepoStore) Setting(repo *core.Repo) (*core.RepoSetting, error)

Setting of the repository

func (*RepoStore) Update

func (store *RepoStore) Update(repo *core.Repo) error

Update repository information

func (*RepoStore) UpdateCreator added in v0.1.9

func (store *RepoStore) UpdateCreator(repo *core.Repo, user *core.User) error

UpdateCreator of the repository

func (*RepoStore) UpdateHook

func (store *RepoStore) UpdateHook(repo *core.Repo, hook *core.Hook) error

UpdateHook of the repository

func (*RepoStore) UpdateOrCreate added in v0.1.9

func (store *RepoStore) UpdateOrCreate(repo *core.Repo) error

UpdateOrCreate repository, notice that only below fields will be affected: Name, NameSpace, URL, SCM, Branch, Private

func (*RepoStore) UpdateSetting

func (store *RepoStore) UpdateSetting(repo *core.Repo, setting *core.RepoSetting) error

UpdateSetting for the repository

type Report

type Report struct {
	gorm.Model
	FileData   []byte
	ReportID   string `gorm:"size:256;uniqueIndex:report_record"`
	Coverages  []*Coverage
	References []*Reference `gorm:"many2many:report_reference"`
	Commit     string       `gorm:"size:256;uniqueIndex:report_record"`
}

Report holds the report

func (*Report) Files

func (r *Report) Files() ([]string, error)

Files of the report

func (*Report) ToCoreReport

func (r *Report) ToCoreReport() *core.Report

ToCoreReport object

type ReportComment

type ReportComment struct {
	gorm.Model
	ReportID string `gorm:"size:256;uniqueIndex:report_comment_number"`
	// Number is the PR number
	Number  int `gorm:"uniqueIndex:report_comment_number"`
	Comment int
}

ReportComment defines summary report comment in the pull request

type ReportStore

type ReportStore struct {
	DB core.DatabaseService
}

ReportStore reports in storage

func (*ReportStore) CreateComment

func (store *ReportStore) CreateComment(r *core.Report, comment *core.ReportComment) error

CreateComment of the report summary

func (*ReportStore) Find

func (store *ReportStore) Find(r *core.Report) (*core.Report, error)

Find report with the input seed. No-empty filed will use as where condition

func (*ReportStore) FindComment

func (store *ReportStore) FindComment(r *core.Report, number int) (*core.ReportComment, error)

FindComment summary of given PR number

func (*ReportStore) Finds

func (store *ReportStore) Finds(r *core.Report) ([]*core.Report, error)

Finds all report with given seed

func (*ReportStore) List added in v0.1.0

func (store *ReportStore) List(reportID, ref string) ([]*core.Report, error)

List reports with reference

reference (ref) could be commit SHA, branch or tag name. The files and data field will be remove from result to reduce memory usage.

func (*ReportStore) Upload

func (store *ReportStore) Upload(r *core.Report) error

Upload create a report to database If the report id and commit is already existed in the table, the report will be updated instead.

type User

type User struct {
	gorm.Model
	Login  string `gorm:"size:256;uniqueIndex;not null"`
	Name   string
	Email  string `gorm:"index"`
	Active bool
	Avater string
	// Gitea
	GiteaLogin   string `gorm:"index"`
	GiteaEmail   string `gorm:"index"`
	GiteaToken   string
	GiteaRefresh string
	GiteaExpire  int64
	// GitLab
	GitLabLogin   string `gorm:"index"`
	GitLabEmail   string `gorm:"index"`
	GitLabToken   string
	GitLabRefresh string
	GitLabExpire  int64
	// Github
	GithubLogin   string `gorm:"index"`
	GithubEmail   string `gorm:"index"`
	GithubToken   string
	GithubRefresh string
	GithubExpire  int64
	Repositories  []*Repo `gorm:"many2many:user_repositories"`
}

User data

type UserStore

type UserStore struct {
	DB core.DatabaseService
}

UserStore user in storage

func (*UserStore) Bind

func (store *UserStore) Bind(
	scm core.SCMProvider,
	user *core.User,
	scmUser *scm.User,
	token *core.Token,
) (*core.User, error)

Bind a new user from another SCM to registered user

func (*UserStore) Create

func (store *UserStore) Create(scm core.SCMProvider, user *scm.User, token *core.Token) error

Create a new user

func (*UserStore) Find

func (store *UserStore) Find(scm core.SCMProvider, user *scm.User) (*core.User, error)

Find user with SCM information

func (*UserStore) FindByLogin added in v0.1.8

func (store *UserStore) FindByLogin(login string) (*core.User, error)

FindByLogin name

func (*UserStore) ListRepositories added in v0.1.9

func (store *UserStore) ListRepositories(user *core.User) ([]*core.Repo, error)

ListRepositories for the user

func (*UserStore) Update added in v0.1.0

func (store *UserStore) Update(scm core.SCMProvider, user *scm.User, token *core.Token) error

Update user with new token

func (*UserStore) UpdateRepositories added in v0.1.9

func (store *UserStore) UpdateRepositories(user *core.User, repositories []*core.Repo) error

UpdateRepositories for the user

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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