forked from evergreen-ci/evergreen
/
version.go
77 lines (68 loc) · 3.39 KB
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package version
import (
"time"
"github.com/evergreen-ci/evergreen/db"
"github.com/evergreen-ci/evergreen/db/bsonutil"
"gopkg.in/mgo.v2/bson"
)
type Version struct {
Id string `bson:"_id" json:"id,omitempty"`
CreateTime time.Time `bson:"create_time" json:"create_time,omitempty"`
StartTime time.Time `bson:"start_time" json:"start_time,omitempty"`
FinishTime time.Time `bson:"finish_time" json:"finish_time,omitempty"`
Revision string `bson:"gitspec" json:"revision,omitempty"`
Author string `bson:"author" json:"author,omitempty"`
AuthorEmail string `bson:"author_email" json:"author_email,omitempty"`
Message string `bson:"message" json:"message,omitempty"`
Status string `bson:"status" json:"status,omitempty"`
RevisionOrderNumber int `bson:"order,omitempty" json:"order,omitempty"`
Config string `bson:"config" json:"config,omitempty"`
Ignored bool `bson:"ignored" json:"ignored"`
Owner string `bson:"owner_name" json:"owner_name,omitempty"`
Repo string `bson:"repo_name" json:"repo_name,omitempty"`
Branch string `bson:"branch_name" json:"branch_name, omitempty"`
RepoKind string `bson:"repo_kind" json:"repo_kind,omitempty"`
BuildVariants []BuildStatus `bson:"build_variants_status,omitempty" json:"build_variants_status,omitempty"`
// This is technically redundant, but a lot of code relies on it, so I'm going to leave it
BuildIds []string `bson:"builds" json:"builds,omitempty"`
Identifier string `bson:"identifier" json:"identifier,omitempty"`
Remote bool `bson:"remote" json:"remote,omitempty"`
RemotePath string `bson:"remote_path" json:"remote_path,omitempty"`
// version requester - this is used to help tell the
// reason this version was created. e.g. it could be
// because the repotracker requested it (via tracking the
// repository) or it was triggered by a developer
// patch request
Requester string `bson:"r" json:"requester,omitempty"`
// version errors - this is used to keep track of any errors that were
// encountered in the process of creating a version. If there are no errors
// this field is omitted in the database
Errors []string `bson:"errors,omitempty" json:"errors,omitempty"`
Warnings []string `bson:"warnings,omitempty" json:"warnings,omitempty"`
}
func (self *Version) UpdateBuildVariants() error {
return UpdateOne(
bson.M{IdKey: self.Id},
bson.M{
"$set": bson.M{
BuildVariantsKey: self.BuildVariants,
},
},
)
}
func (self *Version) Insert() error {
return db.Insert(Collection, self)
}
// BuildStatus stores metadata relating to each build
type BuildStatus struct {
BuildVariant string `bson:"build_variant" json:"id"`
Activated bool `bson:"activated" json:"activated"`
ActivateAt time.Time `bson:"activate_at,omitempty" json:"activate_at,omitempty"`
BuildId string `bson:"build_id,omitempty" json:"build_id,omitempty"`
}
var (
BuildStatusVariantKey = bsonutil.MustHaveTag(BuildStatus{}, "BuildVariant")
BuildStatusActivatedKey = bsonutil.MustHaveTag(BuildStatus{}, "Activated")
BuildStatusActivateAtKey = bsonutil.MustHaveTag(BuildStatus{}, "ActivateAt")
BuildStatusBuildIdKey = bsonutil.MustHaveTag(BuildStatus{}, "BuildId")
)