buildstore

package
v0.0.0-...-1643519 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Overview

Package buildstore implements storage of //milo/api/buildbot/* types.

Index

Constants

View Source
const MasterExpiry = 4 * time.Hour

MasterExpiry is how long a master entity can be stale before we consider it to be expired.

Variables

View Source
var ErrNoBuildNumber = errors.BoolTag{Key: errors.NewTagKey("no buildnumber")}

ErrNoBuildNumber is an error tag indicating that a build does not have a build number.

View Source
var ImportRejectedTag = errors.BoolTag{
	Key: errors.NewTagKey("import rejected"),
}

ImportRejectedTag is tagged to an error when an entity cannot be mutated anymore.

View Source
var TooBigTag = errors.BoolTag{
	Key: errors.NewTagKey("entity was not saved because it was too large to store"),
}

TooBigTag indicates that entity was not saved because it was too large to store.

Functions

func BucketOf

func BucketOf(c context.Context, master string) (string, error)

BucketOf returns LUCI bucket that the given buildbot master is migrating to. Returns "" if it is unknown.

func CanAccessMaster

func CanAccessMaster(c context.Context, name string) error

CanAccessMaster returns nil if the currently logged in user can see the masters, or if the given master is a known public master, otherwise an error.

func EmulationEnabled

func EmulationEnabled(c context.Context) bool

EmulationEnabled returns true if emulation is enabled in c.

func EmulationOf

func EmulationOf(c context.Context, id buildbot.BuildID) (*buildbucket.Build, error)

EmulationOf returns the Buildbucket build that the given Buildbot build is emulating. Returns (nil, nil) if build is not found.

func GetBuild

func GetBuild(c context.Context, id buildbot.BuildID) (*buildbot.Build, error)

GetBuild fetches a buildbot build from the storage. Returns (nil, nil) if build is not found. Does not check access.

func GetPendingCounts

func GetPendingCounts(c context.Context, builders []string) ([]int, error)

GetPendingCounts returns numbers of pending builds in builders. builders must be a list of slash-separated master, builder names.

func PutPendingCount

func PutPendingCount(c context.Context, master, builder string, count int) error

PutPendingCount persists number of pending builds to a builder. Useful for testing.

func SaveBuild

func SaveBuild(c context.Context, b *buildbot.Build) (replaced bool, err error)

SaveBuild persists the build in the storage.

This will also update the model.BuildSummary and model.BuilderSummary.

func SaveMaster

func SaveMaster(c context.Context, master *buildbot.Master,
	internal bool, expireCallback ExpireCallback) error

SaveMaster persists the master in the storage.

Expires all incomplete builds in the datastore associated with this master and

  • associated with builders not declared in master.Builders
  • OR or not "current" from this master's perspective and >=20min stale.

func WithEmulation

func WithEmulation(c context.Context, enabled bool) context.Context

WithEmulation enables or disables emulation.

Types

type ExpireCallback

type ExpireCallback func(b *buildbot.Build, reason string)

ExpireCallback is called when a build is marked as expired.

type Master

type Master struct {
	buildbot.Master
	Internal bool
	Modified time.Time
}

Master is buildbot.Master plus extra storage-level information.

func AllMasters

func AllMasters(c context.Context, checkAccess bool) ([]*Master, error)

AllMasters returns all buildbot masters.

func GetMaster

func GetMaster(c context.Context, name string, refreshState bool) (*Master, error)

GetMaster fetches a master.

If refreshState is true, refreshes individual builds from the datastore and the list of Cached builds.

If any of the master's builders is emulated, the returned Master does not have any slave information or pending build states.

Does not check access.

type Query

type Query struct {
	Master   string
	Builder  string
	Limit    int
	Finished Ternary
	Cursor   string

	// KeyOnly, if true, makes the datastore query keys-only.
	// Loaded Buildbot builds will have only master, builder and number.
	KeyOnly bool // make the data

	// NoAnnotationFetch, if true, will not fetch annotation proto from LogDog.
	// Loaded LUCI builds will not have properties, steps, logs or text.
	NoAnnotationFetch bool

	// NoChangeFetch, if true, will not load change history from Gitiles.
	// Loaded LUCI builds will not have Blame or SourceStamp.Changes.
	NoChangeFetch bool
}

Query is a build query.

type QueryResult

type QueryResult struct {
	Builds     []*buildbot.Build // ordered from greater-number to lower-number
	NextCursor string
	PrevCursor string
}

QueryResult is a result of running a Query.

func GetBuilds

func GetBuilds(c context.Context, q Query) (*QueryResult, error)

GetBuilds executes a build query and returns results. Does not check access.

type Ternary

type Ternary int

Ternary has 3 defined values: either (zero), yes and no.

const (
	Either Ternary = iota
	Yes
	No
)

Jump to

Keyboard shortcuts

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