Documentation
¶
Index ¶
- Constants
- Variables
- func ByGithubPRAndCreatedBefore(t time.Time, owner, repo string, prNumber int) db.Q
- func ById(id mgobson.ObjectId) db.Q
- func ByIds(ids []mgobson.ObjectId) db.Q
- func ByProjectAndCommitQueue(project string, filterCommitQueue bool) db.Q
- func ByUserAndCommitQueue(user string, filterCommitQueue bool) db.Q
- func ByUserPaginated(user string, ts time.Time, limit int) db.Q
- func ByUserPatchNameStatusesCommitQueuePaginated(user, patchName string, statuses []string, includeCommitQueue bool, page int, ...) db.Q
- func ByUserProjectAndGitspec(user string, project string, gitspec string) db.Q
- func ByVersion(version string) db.Q
- func ByVersions(versions []string) db.Q
- func Count(query db.Q) (int, error)
- func FindProjectForPatch(patchID mgobson.ObjectId) (string, error)
- func FindUnprocessedGithubIntents() ([]*githubIntent, error)
- func GetPatchDiffsForMailbox(reader io.Reader) (string, error)
- func IsMailbox(patchFile string) (bool, error)
- func IsMailboxDiff(patchDiff string) bool
- func IsValidId(id string) bool
- func NewId(id string) mgobson.ObjectId
- func PatchesByProject(projectId string, ts time.Time, limit int) db.Q
- func Remove(query db.Q) error
- func ResolveVariantTasks(vts []VariantTasks) (bvs []string, tasks []string)
- func TryMarkFinished(versionId string, finishTime time.Time, status string) error
- func TryMarkStarted(versionId string, startTime time.Time) error
- func UpdateAll(query interface{}, update interface{}) (info *adb.ChangeInfo, err error)
- func UpdateOne(query interface{}, update interface{}) error
- type DisplayTask
- type GithubPatch
- type Intent
- type ModulePatch
- type Patch
- func (p *Patch) AddBuildVariants(bvs []string) error
- func (p *Patch) AddSyncVariantsTasks(vts []VariantTasks) error
- func (p *Patch) AddTasks(tasks []string) error
- func (p *Patch) ClearPatchData()
- func (p *Patch) ConfigChanged(remotePath string) bool
- func (p *Patch) FetchPatchFiles(useRaw bool) error
- func (p *Patch) FindModule(moduleName string) *ModulePatch
- func (p *Patch) GetRequester() string
- func (p *Patch) GetURL(uiHost string) string
- func (p *Patch) Insert() error
- func (p *Patch) IsGithubPRPatch() bool
- func (p *Patch) IsPRMergePatch() bool
- func (p *Patch) MarshalBSON() ([]byte, error)
- func (p *Patch) RemoveModulePatch(moduleName string) error
- func (p *Patch) ResolveSyncVariantTasks(vts []VariantTasks) []VariantTasks
- func (p *Patch) SetActivated(versionId string) error
- func (p *Patch) SetActivation(activated bool) error
- func (p *Patch) SetDescription(desc string) error
- func (p *Patch) SetVariantsTasks(variantsTasks []VariantTasks) error
- func (p *Patch) UnmarshalBSON(in []byte) error
- func (p *Patch) UpdateGithashProjectAndTasks() error
- func (p *Patch) UpdateModulePatch(modulePatch ModulePatch) error
- func (p *Patch) UpdateVariantsTasks(variantsTasks []VariantTasks)
- type PatchSet
- type PatchesByCreateTime
- type Summary
- type SyncAtEndOptions
- type VariantTasks
Constants ¶
const ( Collection = "patches" GridFSPrefix = "patchfiles" )
const ( // IntentCollection is the database collection that stores patch intents. IntentCollection = "patch_intents" // GithubIntentType represents patch intents created for GitHub. GithubIntentType = "github" )
const CliIntentType = "cli"
const SizeLimit = 1024 * 1024 * 100
SizeLimit is a hard limit on patch size.
Variables ¶
var ( IdKey = bsonutil.MustHaveTag(Patch{}, "Id") DescriptionKey = bsonutil.MustHaveTag(Patch{}, "Description") ProjectKey = bsonutil.MustHaveTag(Patch{}, "Project") GithashKey = bsonutil.MustHaveTag(Patch{}, "Githash") AuthorKey = bsonutil.MustHaveTag(Patch{}, "Author") NumberKey = bsonutil.MustHaveTag(Patch{}, "PatchNumber") VersionKey = bsonutil.MustHaveTag(Patch{}, "Version") StatusKey = bsonutil.MustHaveTag(Patch{}, "Status") CreateTimeKey = bsonutil.MustHaveTag(Patch{}, "CreateTime") StartTimeKey = bsonutil.MustHaveTag(Patch{}, "StartTime") FinishTimeKey = bsonutil.MustHaveTag(Patch{}, "FinishTime") BuildVariantsKey = bsonutil.MustHaveTag(Patch{}, "BuildVariants") TasksKey = bsonutil.MustHaveTag(Patch{}, "Tasks") VariantsTasksKey = bsonutil.MustHaveTag(Patch{}, "VariantsTasks") SyncAtEndOptionsKey = bsonutil.MustHaveTag(Patch{}, "SyncAtEndOpts") PatchesKey = bsonutil.MustHaveTag(Patch{}, "Patches") ActivatedKey = bsonutil.MustHaveTag(Patch{}, "Activated") PatchedConfigKey = bsonutil.MustHaveTag(Patch{}, "PatchedConfig") AliasKey = bsonutil.MustHaveTag(Patch{}, "Alias") // BSON fields for sync at end struct SyncAtEndOptionsBuildVariantsKey = bsonutil.MustHaveTag(SyncAtEndOptions{}, "BuildVariants") SyncAtEndOptionsTasksKey = bsonutil.MustHaveTag(SyncAtEndOptions{}, "Tasks") SyncAtEndOptionsVariantsTasksKey = bsonutil.MustHaveTag(SyncAtEndOptions{}, "VariantsTasks") SyncAtEndOptionsStatusesKey = bsonutil.MustHaveTag(SyncAtEndOptions{}, "Statuses") SyncAtEndOptionsTimeoutKey = bsonutil.MustHaveTag(SyncAtEndOptions{}, "Timeout") // BSON fields for the module patch struct ModulePatchNameKey = bsonutil.MustHaveTag(ModulePatch{}, "ModuleName") ModulePatchGithashKey = bsonutil.MustHaveTag(ModulePatch{}, "Githash") ModulePatchSetKey = bsonutil.MustHaveTag(ModulePatch{}, "PatchSet") // BSON fields for the patch set struct PatchSetPatchKey = bsonutil.MustHaveTag(PatchSet{}, "Patch") PatchSetSummaryKey = bsonutil.MustHaveTag(PatchSet{}, "Summary") // BSON fields for the git patch summary struct GitSummaryNameKey = bsonutil.MustHaveTag(Summary{}, "Name") GitSummaryAdditionsKey = bsonutil.MustHaveTag(Summary{}, "Additions") GitSummaryDeletionsKey = bsonutil.MustHaveTag(Summary{}, "Deletions") )
BSON fields for the patches nolint: deadcode, megacheck, unused
var ExcludePatchDiff = bson.M{ bsonutil.GetDottedKeyName(PatchesKey, ModulePatchSetKey, PatchSetPatchKey): 0, }
ExcludePatchDiff is a projection that excludes diff data, helping load times.
Functions ¶
func ByProjectAndCommitQueue ¶
ByProject produces a query that returns projects with the given identifier.
func ByUserAndCommitQueue ¶
ByUser produces a query that returns patches by the given user.
func ByUserPaginated ¶
ByUserPaginated produces a query that returns patches by the given user before/after the input time, sorted by creation time and limited
func ByUserProjectAndGitspec ¶
ByUserProjectAndGitspec produces a query that returns patches by the given patch author, project, and gitspec.
func ByVersions ¶
ByVersion produces a query that returns the patch for a given version.
func FindUnprocessedGithubIntents ¶
func FindUnprocessedGithubIntents() ([]*githubIntent, error)
FindUnprocessedGithubIntents finds all patch intents that have not yet been processed.
func IsMailbox ¶
IsMailbox checks if the first line of a patch file has "From ". If so, it's assumed to be a mailbox-style patch, otherwise it's a diff
func IsMailboxDiff ¶
func PatchesByProject ¶
PatchesByProject builds a query for patches that match the given project's id.
func ResolveVariantTasks ¶
func ResolveVariantTasks(vts []VariantTasks) (bvs []string, tasks []string)
ResolveVariantTasks returns a set of all build variants and a set of all tasks that will run based on the given VariantTasks.
func TryMarkFinished ¶
TryMarkFinished attempts to mark a patch of a given version as finished.
func TryMarkStarted ¶
TryMarkStarted attempts to mark a patch as started if it isn't already marked as such
func UpdateAll ¶
func UpdateAll(query interface{}, update interface{}) (info *adb.ChangeInfo, err error)
UpdateAll runs an update on all patch documents.
Types ¶
type DisplayTask ¶
type GithubPatch ¶
type GithubPatch struct {
PRNumber int `bson:"pr_number"`
BaseOwner string `bson:"base_owner"`
BaseRepo string `bson:"base_repo"`
BaseBranch string `bson:"base_branch"`
HeadOwner string `bson:"head_owner"`
HeadRepo string `bson:"head_repo"`
HeadHash string `bson:"head_hash"`
Author string `bson:"author"`
AuthorUID int `bson:"author_uid"`
MergeCommitSHA string `bson:"merge_commit_sha"`
}
GithubPatch stores patch data for patches create from GitHub pull requests
type Intent ¶
type Intent interface {
// ID returns a unique identifier for the patch. Should
// correspond to the _id for the patch in database.
ID() string
// Insert inserts a patch intent in the database.
Insert() error
// SetProcessed should be called by an amboy queue after creating a patch from an intent.
SetProcessed() error
// IsProcessed returns whether a patch exists for this intent.
IsProcessed() bool
// GetType returns the patch intent, e.g., GithubIntentType.
GetType() string
// NewPatch creates a patch from the intent
NewPatch() *Patch
// Finalize indicates whether or not the patch created from this
// intent should be finalized
ShouldFinalizePatch() bool
// GetAlias defines the variants and tasks this intent should run on.
GetAlias() string
// RequesterIdentity supplies a valid requester type, that is recorded
// in patches, versions, builds, and tasks to denote the origin of the
// patch
RequesterIdentity() string
}
Intent represents an intent to create a patch build and is processed by an amboy queue.
func FindIntent ¶
FindIntent returns an intent of the specified type from the database
func NewCliIntent ¶
func NewGithubIntent ¶
func NewGithubIntent(msgDeliveryID string, pr *github.PullRequest) (Intent, error)
NewGithubIntent creates an Intent from a google/go-github PullRequestEvent, or returns an error if the some part of the struct is invalid
type ModulePatch ¶
type ModulePatch struct {
ModuleName string `bson:"name"`
Githash string `bson:"githash"`
PatchSet PatchSet `bson:"patch_set"`
Message string `bson:"message"`
}
ModulePatch stores request details for a patch
type Patch ¶
type Patch struct {
Id mgobson.ObjectId `bson:"_id,omitempty"`
Description string `bson:"desc"`
Project string `bson:"branch"`
Githash string `bson:"githash"`
PatchNumber int `bson:"patch_number"`
Author string `bson:"author"`
Version string `bson:"version"`
Status string `bson:"status"`
CreateTime time.Time `bson:"create_time"`
StartTime time.Time `bson:"start_time"`
FinishTime time.Time `bson:"finish_time"`
BuildVariants []string `bson:"build_variants"`
Tasks []string `bson:"tasks"`
VariantsTasks []VariantTasks `bson:"variants_tasks"`
SyncAtEndOpts SyncAtEndOptions `bson:"sync_at_end_opts,omitempty"`
Patches []ModulePatch `bson:"patches"`
Activated bool `bson:"activated"`
PatchedConfig string `bson:"patched_config"`
Alias string `bson:"alias"`
GithubPatchData GithubPatch `bson:"github_patch_data,omitempty"`
// DisplayNewUI is only used when roundtripping the patch via the CLI
DisplayNewUI bool `bson:"display_new_ui,omitempty"`
}
Patch stores all details related to a patch request
func FindFailedCommitQueuePatchesinTimeRange ¶
func FindFailedCommitQueuePatchesinTimeRange(projectID string, startTime, endTime time.Time) ([]Patch, error)
FindFailedCommitQueuePatchesInTimeRange returns failed patches if they started within range, or if they were never started but finished within time range. (i.e. timed out)
func MakeMergePatch ¶
func MakeMergePatch(pr *github.PullRequest, projectID, alias string) (*Patch, error)
func (*Patch) AddBuildVariants ¶
AddBuildVariants adds more buildvarints to a patch document. This is meant to be used after initial patch creation.
func (*Patch) AddSyncVariantsTasks ¶
func (p *Patch) AddSyncVariantsTasks(vts []VariantTasks) error
AddSyncVariantsTasks adds new tasks for variants filtered from the given sequence of VariantsTasks to the existing synced VariantTasks.
func (*Patch) AddTasks ¶
AddTasks adds more tasks to a patch document. This is meant to be used after initial patch creation, to reconfigure the patch.
func (*Patch) ClearPatchData ¶
func (p *Patch) ClearPatchData()
ClearPatchData removes any inline patch data stored in this patch object for patches that have an associated id in gridfs, so that it can be stored properly.
func (*Patch) ConfigChanged ¶
ConfigChanged looks through the parts of the patch and returns true if the passed in remotePath is in the the name of the changed files that are part of the patch
func (*Patch) FetchPatchFiles ¶
FetchPatchFiles dereferences externally-stored patch diffs by fetching them from gridfs and placing their contents into the patch object.
func (*Patch) FindModule ¶
func (p *Patch) FindModule(moduleName string) *ModulePatch
func (*Patch) GetRequester ¶
func (*Patch) IsGithubPRPatch ¶
func (*Patch) IsPRMergePatch ¶
func (*Patch) MarshalBSON ¶
func (*Patch) RemoveModulePatch ¶
RemoveModulePatch removes a module that's part of a patch request
func (*Patch) ResolveSyncVariantTasks ¶
func (p *Patch) ResolveSyncVariantTasks(vts []VariantTasks) []VariantTasks
ResolveSyncVariantTasks filters the given tasks by variant to find only those that match the build variant and task filters.
func (*Patch) SetActivated ¶
SetActivated sets the patch to activated in the db
func (*Patch) SetActivation ¶
SetActivation sets the patch to the desired activation state without modifying the activation status of the possibly corresponding version.
func (*Patch) SetDescription ¶
SetDescription sets a patch's description in the database
func (*Patch) SetVariantsTasks ¶
func (p *Patch) SetVariantsTasks(variantsTasks []VariantTasks) error
SetVariantsTasks updates the variant/tasks pairs in the database. Also updates the Tasks and Variants fields to maintain backwards compatibility between the old and new fields.
func (*Patch) UnmarshalBSON ¶
func (*Patch) UpdateGithashProjectAndTasks ¶
func (*Patch) UpdateModulePatch ¶
func (p *Patch) UpdateModulePatch(modulePatch ModulePatch) error
UpdateModulePatch adds or updates a module within a patch.
func (*Patch) UpdateVariantsTasks ¶
func (p *Patch) UpdateVariantsTasks(variantsTasks []VariantTasks)
UpdateVariantsTasks updates the patch's Tasks and BuildVariants fields to match with the set in the given list of VariantTasks. This is to ensure schema backwards compatibility for T shaped patches. This mutates the patch in memory but does not update it in the database; for that, use SetVariantsTasks.
type PatchSet ¶
type PatchSet struct {
Patch string `bson:"patch,omitempty"`
PatchFileId string `bson:"patch_file_id,omitempty"`
Summary []Summary `bson:"summary"`
}
PatchSet stores information about the actual patch
type PatchesByCreateTime ¶
type PatchesByCreateTime []Patch
func (PatchesByCreateTime) Len ¶
func (p PatchesByCreateTime) Len() int
func (PatchesByCreateTime) Less ¶
func (p PatchesByCreateTime) Less(i, j int) bool
func (PatchesByCreateTime) Swap ¶
func (p PatchesByCreateTime) Swap(i, j int)
type Summary ¶
type Summary struct {
Name string `bson:"filename"`
Additions int `bson:"additions"`
Deletions int `bson:"deletions"`
Description string `bson:"description,omitempty"`
}
Summary stores summary patch information
type SyncAtEndOptions ¶
type SyncAtEndOptions struct {
// BuildVariants filters which variants will sync.
BuildVariants []string `bson:"build_variants,omitempty"`
// Tasks filters which tasks will sync.
Tasks []string `bson:"tasks,omitempty"`
// VariantsTasks are the resolved pairs of build variants and tasks that
// this patch can actually run task sync for.
VariantsTasks []VariantTasks `bson:"variants_tasks,omitempty"`
Statuses []string `bson:"statuses,omitempty"`
Timeout time.Duration `bson:"timeout,omitempty"`
}
SyncAtEndOptions describes when and how tasks perform sync at the end of a task.
type VariantTasks ¶
type VariantTasks struct {
Variant string
Tasks []string
DisplayTasks []DisplayTask
}
VariantTasks contains the variant ID and the set of tasks to be scheduled for that variant
func MergeVariantsTasks ¶
func MergeVariantsTasks(vts1, vts2 []VariantTasks) []VariantTasks
MergeVariantsTasks merges two slices of VariantsTasks into a single set.