db

package
v0.0.0-...-9d4f14f Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BuildFailed string = "build_failed"
	//	BuiltNotTested  string = "built"
	//	BuildTestFailed string = "tests_failed"
	BuildSuccess string = "success"
)

Variables

View Source
var ErrFindingExists = errors.New("the finding already exists")
View Source
var ErrSeriesExists = errors.New("the series already exists")

Functions

func CreateSpannerDB

func CreateSpannerDB(ctx context.Context, uri ParsedURI) error

func CreateSpannerInstance

func CreateSpannerInstance(ctx context.Context, uri ParsedURI) error

func NewTransientDB

func NewTransientDB(t *testing.T) (*spanner.Client, context.Context)

func RunMigrations

func RunMigrations(ctx context.Context, uri string) error

Types

type Build

type Build struct {
	ID         string             `spanner:"ID"`
	TreeName   string             `spanner:"TreeName"`
	CommitHash string             `spanner:"CommitHash"`
	CommitDate time.Time          `spanner:"CommitDate"`
	SeriesID   spanner.NullString `spanner:"SeriesID"`
	Arch       string             `spanner:"Arch"`
	ConfigName string             `spanner:"ConfigName"`
	ConfigURI  string             `spanner:"ConfigURI"`
	Status     string             `spanner:"Status"`
}

func (*Build) SetSeriesID

func (b *Build) SetSeriesID(val string)

type BuildRepository

type BuildRepository struct {
	// contains filtered or unexported fields
}

func NewBuildRepository

func NewBuildRepository(client *spanner.Client) *BuildRepository

func (BuildRepository) GetByID

func (g BuildRepository) GetByID(ctx context.Context, key KeyType) (*EntityType, error)

func (*BuildRepository) Insert

func (repo *BuildRepository) Insert(ctx context.Context, build *Build) error

func (*BuildRepository) LastBuiltTree

func (repo *BuildRepository) LastBuiltTree(ctx context.Context, arch, tree, config string) (*Build, error)

func (BuildRepository) Update

func (g BuildRepository) Update(ctx context.Context, key KeyType,
	cb func(*EntityType) error) error

type Finding

type Finding struct {
	SessionID string `spanner:"SessionID"`
	TestName  string `spanner:"TestName"`
	Title     string `spanner:"Title"`
	ReportURI string `spanner:"ReportURI"`
	LogURI    string `spanner:"LogURI"`
}

type FindingRepository

type FindingRepository struct {
	// contains filtered or unexported fields
}

func NewFindingRepository

func NewFindingRepository(client *spanner.Client) *FindingRepository

func (*FindingRepository) ListForSession

func (repo *FindingRepository) ListForSession(ctx context.Context, session *Session) ([]*Finding, error)

nolint: dupl

func (*FindingRepository) Save

func (repo *FindingRepository) Save(ctx context.Context, finding *Finding) error

Save either adds the finding to the database or returns ErrFindingExists.

type FullSessionTest

type FullSessionTest struct {
	*SessionTest
	BaseBuild    *Build
	PatchedBuild *Build
}

type ParsedURI

type ParsedURI struct {
	ProjectPrefix  string // projects/<project>
	InstancePrefix string // projects/<project>/instances/<instance>
	Instance       string
	Database       string
	Full           string
}

func ParseURI

func ParseURI(uri string) (ParsedURI, error)

type Patch

type Patch struct {
	ID       string `spanner:"ID"`
	Seq      int64  `spanner:"Seq"`
	SeriesID string `spanner:"SeriesID"`
	Title    string `spanner:"Title"`
	Link     string `spanner:"Link"`
	BodyURI  string `spanner:"BodyURI"`
}

type Series

type Series struct {
	ID              string             `spanner:"ID"`
	ExtID           string             `spanner:"ExtID"`
	AuthorName      string             `spanner:"AuthorName"`
	AuthorEmail     string             `spanner:"AuthorEmail"`
	Title           string             `spanner:"Title"`
	Link            string             `spanner:"Link"`
	Version         int64              `spanner:"Version"`
	PublishedAt     time.Time          `spanner:"PublishedAt"`
	LatestSessionID spanner.NullString `spanner:"LatestSessionID"`
	Cc              []string           `spanner:"Cc"`
}

func (*Series) SetLatestSession

func (s *Series) SetLatestSession(session *Session)

type SeriesRepository

type SeriesRepository struct {
	// contains filtered or unexported fields
}

func NewSeriesRepository

func NewSeriesRepository(client *spanner.Client) *SeriesRepository

func (*SeriesRepository) Count

func (repo *SeriesRepository) Count(ctx context.Context) (int, error)

func (SeriesRepository) GetByID

func (g SeriesRepository) GetByID(ctx context.Context, key KeyType) (*EntityType, error)

func (*SeriesRepository) Insert

func (repo *SeriesRepository) Insert(ctx context.Context, series *Series,
	queryPatches func() ([]*Patch, error)) error

Insert() checks whether there already exists a series with the same ExtID. Since Patch content is stored elsewhere, we do not demand it be filled out before calling Insert(). Instead, Insert() obtains this data via a callback.

func (*SeriesRepository) ListLatest

func (repo *SeriesRepository) ListLatest(ctx context.Context,
	maxPublishedAt time.Time, limit int) ([]*SeriesWithSession, error)

ListLatest() returns the list of series ordered by the decreasing PublishedAt value.

func (*SeriesRepository) ListPatches

func (repo *SeriesRepository) ListPatches(ctx context.Context, series *Series) ([]*Patch, error)

golint sees too much similarity with SessionRepository's ListForSeries, but in reality there's not. nolint:dupl

func (*SeriesRepository) ListWithoutSession

func (repo *SeriesRepository) ListWithoutSession(ctx context.Context, limit int) ([]*Series, error)

func (*SeriesRepository) PatchByID

func (repo *SeriesRepository) PatchByID(ctx context.Context, id string) (*Patch, error)

TODO: move to SeriesPatchesRepository?

func (SeriesRepository) Update

func (g SeriesRepository) Update(ctx context.Context, key KeyType,
	cb func(*EntityType) error) error

type SeriesWithSession

type SeriesWithSession struct {
	Series  *Series
	Session *Session
}

type Session

type Session struct {
	ID         string           `spanner:"ID"`
	SeriesID   string           `spanner:"SeriesID"`
	CreatedAt  time.Time        `spanner:"CreatedAt"`
	FinishedAt spanner.NullTime `spanner:"FinishedAt"`
	LogURI     string           `spanner:"LogURI"`
}

func (*Session) SetFinishedAt

func (s *Session) SetFinishedAt(t time.Time)

type SessionRepository

type SessionRepository struct {
	// contains filtered or unexported fields
}

func NewSessionRepository

func NewSessionRepository(client *spanner.Client) *SessionRepository

func (SessionRepository) GetByID

func (g SessionRepository) GetByID(ctx context.Context, key KeyType) (*EntityType, error)

func (*SessionRepository) Insert

func (repo *SessionRepository) Insert(ctx context.Context, series *Series, session *Session) error

func (*SessionRepository) ListForSeries

func (repo *SessionRepository) ListForSeries(ctx context.Context, series *Series) ([]*Session, error)

golint sees too much similarity with SeriesRepository's ListPatches, but in reality there's not. nolint:dupl

func (*SessionRepository) ListRunning

func (repo *SessionRepository) ListRunning(ctx context.Context) ([]*Session, error)

func (SessionRepository) Update

func (g SessionRepository) Update(ctx context.Context, key KeyType,
	cb func(*EntityType) error) error

type SessionTest

type SessionTest struct {
	SessionID      string             `spanner:"SessionID"`
	BaseBuildID    spanner.NullString `spanner:"BaseBuildID"`
	PatchedBuildID spanner.NullString `spanner:"PatchedBuildID"`
	TestName       string             `spanner:"TestName"`
	Result         string             `spanner:"Result"`
}

type SessionTestRepository

type SessionTestRepository struct {
	// contains filtered or unexported fields
}

func NewSessionTestRepository

func NewSessionTestRepository(client *spanner.Client) *SessionTestRepository

func (*SessionTestRepository) BySession

func (repo *SessionTestRepository) BySession(ctx context.Context, sessionID string) ([]*FullSessionTest, error)

func (*SessionTestRepository) InsertOrUpdate

func (repo *SessionTestRepository) InsertOrUpdate(ctx context.Context, test *SessionTest) error

Jump to

Keyboard shortcuts

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