Documentation ¶
Index ¶
- Constants
- Variables
- func ById(id bson.ObjectId) db.Q
- func ByProject(project string) db.Q
- func ByUser(user string) 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 IsValidId(id string) bool
- func NewId(id string) bson.ObjectId
- func Remove(query db.Q) error
- 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 *mgo.ChangeInfo, err error)
- func UpdateOne(query interface{}, update interface{}) error
- type ModulePatch
- type Patch
- func (p *Patch) AddBuildVariants(bvs []string) error
- func (p *Patch) AddTasks(tasks []string) error
- func (p *Patch) ClearPatchData()
- func (p *Patch) ConfigChanged(remotePath string) bool
- func (p *Patch) FetchPatchFiles() error
- func (p *Patch) Insert() error
- func (p *Patch) RemoveModulePatch(moduleName string) error
- func (p *Patch) SetActivated(versionId string) error
- func (p *Patch) SetDescription(desc string) error
- func (p *Patch) SetVariantsTasks(variantsTasks []VariantTasks) error
- func (p *Patch) SyncVariantsTasks(variantsTasks []VariantTasks)
- func (p *Patch) UpdateModulePatch(modulePatch ModulePatch) error
- type PatchSet
- type Summary
- type VariantTasks
Constants ¶
const ( Collection = "patches" GridFSPrefix = "patchfiles" )
const SizeLimit = 1024 * 1024 * 100
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") PatchesKey = bsonutil.MustHaveTag(Patch{}, "Patches") ActivatedKey = bsonutil.MustHaveTag(Patch{}, "Activated") PatchedConfigKey = bsonutil.MustHaveTag(Patch{}, "PatchedConfig") // 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
var ExcludePatchDiff = bson.D{ {PatchesKey + "." + ModulePatchSetKey + "." + PatchSetPatchKey, 0}, }
ExcludePatchDiff is a projection that excludes diff data, helping load times.
Functions ¶
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 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
Types ¶
type ModulePatch ¶
type ModulePatch struct { ModuleName string `bson:"name"` Githash string `bson:"githash"` PatchSet PatchSet `bson:"patch_set"` }
this stores request details for a patch
type Patch ¶
type Patch struct { Id bson.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"` Patches []ModulePatch `bson:"patches"` Activated bool `bson:"activated"` PatchedConfig string `bson:"patched_config"` }
Stores all details related to a patch request
func (*Patch) AddBuildVariants ¶
AddBuildVariants adds more buildvarints to a patch document. This is meant to be used after initial patch creation.
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) RemoveModulePatch ¶
RemoveModulePatch removes a module that's part of a patch request
func (*Patch) SetActivated ¶
SetActivated sets the patch to activated in the db
func (*Patch) SetDescription ¶
func (*Patch) SetVariantsTasks ¶
func (p *Patch) SetVariantsTasks(variantsTasks []VariantTasks) error
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) SyncVariantsTasks ¶
func (p *Patch) SyncVariantsTasks(variantsTasks []VariantTasks)
SyncVariantsTasks 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.
func (*Patch) UpdateModulePatch ¶
func (p *Patch) UpdateModulePatch(modulePatch ModulePatch) error
Add or update a module within a patch.
type PatchSet ¶
type PatchSet struct { Patch string `bson:"patch,omitempty"` PatchFileId string `bson:"patch_file_id,omitempty"` Summary []Summary `bson:"summary"` }
this stores information about the actual patch
type Summary ¶
type Summary struct { Name string `bson:"filename"` Additions int `bson:"additions"` Deletions int `bson:"deletions"` }
this stores summary patch information
type VariantTasks ¶
VariantTasks contains the variant ID and the set of tasks to be scheduled for that variant