db

package
v41.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const FailedFetchThreshold = 3

Variables

View Source
var (
	NeverBeenFetchedError = errors.New("Repository has never been fetched")
	NoChangesError        = errors.New("Repository has never been changed")
)

Functions

func NewCommitRepository

func NewCommitRepository(db *gorm.DB) *commitRepository

func NewDSN

func NewDSN(username, password, dbName, hostname string, port int) string

func NewFetchRepository

func NewFetchRepository(db *gorm.DB) *fetchRepository

func NewRepositoryRepository

func NewRepositoryRepository(db *gorm.DB) *repositoryRepository

Types

type ActiveScan

type ActiveScan interface {
	RecordCredential(Credential)
	Finish() error
}

type Commit

type Commit struct {
	Model
	Owner      string
	Repository string
	SHA        string
}

type CommitRepository

type CommitRepository interface {
	RegisterCommit(logger lager.Logger, commit *Commit) error
	IsCommitRegistered(logger lager.Logger, sha string) (bool, error)
	IsRepoRegistered(logger lager.Logger, owner, repo string) (bool, error)
}

type Credential

type Credential struct {
	Model

	Scan   Scan
	ScanID uint

	Owner      string
	Repository string
	SHA        string
	Path       string
	LineNumber int
	MatchStart int
	MatchEnd   int
	Private    bool
}

func NewCredential

func NewCredential(
	owner string,
	repository string,
	sha string,
	path string,
	lineNumber int,
	matchStart int,
	matchEnd int,
	private bool,
) Credential

func (*Credential) Hash

func (c *Credential) Hash() string

type CredentialRepository

type CredentialRepository interface {
	ForScanWithID(int) ([]Credential, error)
	UniqueSHAsForRepoAndRulesVersion(Repository, int) ([]string, error)
}

func NewCredentialRepository

func NewCredentialRepository(db *gorm.DB) CredentialRepository

type Fetch

type Fetch struct {
	Model
	Repository   *Repository
	RepositoryID uint

	Path    string
	Changes []byte
}

type FetchRepository

type FetchRepository interface {
	RegisterFetch(lager.Logger, *Fetch) error
}

type Model

type Model struct {
	ID        uint `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

type PriorScan

type PriorScan struct {
	ID          int
	Branch      string
	StartSHA    string
	StopSHA     string
	Repository  string
	Owner       string
	Credentials []Credential
}

type PropertyMap

type PropertyMap map[string]interface{}

PropertyMap is a type to use to store JSON http://coussej.github.io/2016/02/16/Handling-JSONB-in-Go-Structs/

func (*PropertyMap) Scan

func (p *PropertyMap) Scan(src interface{}) error

func (PropertyMap) Value

func (p PropertyMap) Value() (driver.Value, error)

type Repository

type Repository struct {
	Model

	Cloned bool

	Name          string
	Owner         string
	Path          string
	SSHURL        string `gorm:"column:ssh_url"`
	Private       bool
	DefaultBranch string
	RawJSON       []byte `gorm:"column:raw_json"`

	FailedFetches int `gorm:"column:failed_fetches"`
	Disabled      bool

	CredentialCounts PropertyMap `gorm:"default:'{}'"`
}

type RepositoryRepository

type RepositoryRepository interface {
	Create(*Repository) error

	Find(owner string, name string) (Repository, error)

	All() ([]Repository, error)
	Active() ([]Repository, error)
	AllForOrganization(string) ([]Repository, error)
	NotScannedWithVersion(int) ([]Repository, error)

	MarkAsCloned(string, string, string) error
	RegisterFailedFetch(lager.Logger, *Repository) error
	UpdateCredentialCount(*Repository, map[string]uint) error
}

type Scan

type Scan struct {
	Model

	Type         string
	RulesVersion int

	ScanStart time.Time
	ScanEnd   time.Time

	Branch   string
	StartSHA string
	StopSHA  string

	Repository   *Repository
	RepositoryID *uint
	Fetch        *Fetch
	FetchID      *uint

	Credentials []Credential
}

type ScanRepository

type ScanRepository interface {
	Start(lager.Logger, string, string, string, string, *Repository, *Fetch) ActiveScan
	ScansNotYetRunWithVersion(lager.Logger, int) ([]PriorScan, error)
}

func NewScanRepository

func NewScanRepository(db *gorm.DB, clock clock.Clock) ScanRepository

type StatsRepository

type StatsRepository interface {
	RepositoryCount() (int, error)
	DisabledRepositoryCount() (int, error)
	CredentialCount() (int, error)
	FetchCount() (int, error)
}

func NewStatsRepository

func NewStatsRepository(db *gorm.DB) StatsRepository

Directories

Path Synopsis
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter

Jump to

Keyboard shortcuts

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