本文整理匯總了Golang中github.com/evergreen-ci/evergreen/db/bsonutil.MustHaveTag函數的典型用法代碼示例。如果您正苦於以下問題:Golang MustHaveTag函數的具體用法?Golang MustHaveTag怎麽用?Golang MustHaveTag使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了MustHaveTag函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetLastNotificationsEventTime
"time"
)
var EarliestDateToConsider time.Time
const (
NotifyTimesCollection = "notify_times"
)
type ProjectNotificationTime struct {
ProjectName string `bson:"_id"`
LastNotificationEventTime time.Time `bson:"last_notification_event_time"`
}
var (
PntProjectNameKey = bsonutil.MustHaveTag(ProjectNotificationTime{},
"ProjectName")
PntLastEventTime = bsonutil.MustHaveTag(ProjectNotificationTime{},
"LastNotificationEventTime")
)
// Record the last-notification time for a given project.
func SetLastNotificationsEventTime(projectName string,
timeOfEvent time.Time) error {
_, err := db.Upsert(
NotifyTimesCollection,
bson.M{
PntProjectNameKey: projectName,
},
bson.M{
"$set": bson.M{
PntLastEventTime: timeOfEvent,
示例2:
Key string `mapstructure:"key" json:"key" bson:"key"`
Ca string `mapstructure:"ca" json:"ca" bson:"ca"`
}
type Settings struct {
HostIp string `mapstructure:"host_ip" json:"host_ip" bson:"host_ip"`
BindIp string `mapstructure:"bind_ip" json:"bind_ip" bson:"bind_ip"`
ImageId string `mapstructure:"image_name" json:"image_name" bson:"image_name"`
ClientPort int `mapstructure:"client_port" json:"client_port" bson:"client_port"`
PortRange *portRange `mapstructure:"port_range" json:"port_range" bson:"port_range"`
Auth *auth `mapstructure:"auth" json:"auth" bson:"auth"`
}
var (
// bson fields for the Settings struct
HostIp = bsonutil.MustHaveTag(Settings{}, "HostIp")
BindIp = bsonutil.MustHaveTag(Settings{}, "BindIp")
ImageId = bsonutil.MustHaveTag(Settings{}, "ImageId")
ClientPort = bsonutil.MustHaveTag(Settings{}, "ClientPort")
PortRange = bsonutil.MustHaveTag(Settings{}, "PortRange")
Auth = bsonutil.MustHaveTag(Settings{}, "Auth")
// bson fields for the portRange struct
MinPort = bsonutil.MustHaveTag(portRange{}, "MinPort")
MaxPort = bsonutil.MustHaveTag(portRange{}, "MaxPort")
// bson fields for the auth struct
Cert = bsonutil.MustHaveTag(auth{}, "Cert")
Key = bsonutil.MustHaveTag(auth{}, "Key")
Ca = bsonutil.MustHaveTag(auth{}, "Ca")
示例3: NewTaskConfig
continue
}
for _, t := range bv.Tasks {
// create a unique Id for each task
taskId := util.CleanName(
fmt.Sprintf("%v_%v_%v_%v_%v",
p.Identifier, bv.Name, t.Name, v.Revision, v.CreateTime.Format(build.IdTimeLayout)))
table[TVPair{bv.Name, t.Name}] = taskId
}
}
return table
}
var (
// bson fields for the project struct
ProjectIdentifierKey = bsonutil.MustHaveTag(Project{}, "Identifier")
ProjectPreKey = bsonutil.MustHaveTag(Project{}, "Pre")
ProjectPostKey = bsonutil.MustHaveTag(Project{}, "Post")
ProjectModulesKey = bsonutil.MustHaveTag(Project{}, "Modules")
ProjectBuildVariantsKey = bsonutil.MustHaveTag(Project{}, "BuildVariants")
ProjectFunctionsKey = bsonutil.MustHaveTag(Project{}, "Functions")
ProjectStepbackKey = bsonutil.MustHaveTag(Project{}, "Stepback")
ProjectTasksKey = bsonutil.MustHaveTag(Project{}, "Tasks")
ProjectBVMatrixKey = bsonutil.MustHaveTag(Project{}, "BuildVariantMatrix")
)
func NewTaskConfig(d *distro.Distro, p *Project, t *Task, r *ProjectRef) (*TaskConfig, error) {
// do a check on if the project is empty
if p == nil {
return nil, fmt.Errorf("project for task with branch %v is empty", t.Project)
}
示例4: Validate
)
type DigitalOceanManager struct {
account *digo.Account
}
type Settings struct {
ImageId int `mapstructure:"image_id" json:"image_id" bson:"image_id"`
SizeId int `mapstructure:"size_id" json:"size_id" bson:"size_id"`
RegionId int `mapstructure:"region_id" json:"region_id" bson:"region_id"`
SSHKeyId int `mapstructure:"ssh_key_id" json:"ssh_key_id" bson:"ssh_key_id"`
}
var (
// bson fields for the Settings struct
ImageIdKey = bsonutil.MustHaveTag(Settings{}, "ImageId")
SizeIdKey = bsonutil.MustHaveTag(Settings{}, "SizeId")
RegionIdKey = bsonutil.MustHaveTag(Settings{}, "RegionId")
SSHKeyIdKey = bsonutil.MustHaveTag(Settings{}, "SSHKeyId")
)
//Validate checks that the settings from the config file are sane.
func (self *Settings) Validate() error {
if self.ImageId == 0 {
return fmt.Errorf("ImageId must not be blank")
}
if self.SizeId == 0 {
return fmt.Errorf("Size ID must not be blank")
}
示例5: Validate
const ProviderName = "static"
type StaticManager struct{}
type Settings struct {
Hosts []Host `mapstructure:"hosts" json:"hosts" bson:"hosts"`
}
type Host struct {
Name string `mapstructure:"name" json:"name" bson:"name"`
}
var (
// bson fields for the Settings struct
HostsKey = bsonutil.MustHaveTag(Settings{}, "Hosts")
// bson fields for the Host struct
NameKey = bsonutil.MustHaveTag(Host{}, "Name")
)
// Validate checks that the settings from the configuration are valid.
func (s *Settings) Validate() error {
for _, h := range s.Hosts {
if h.Name == "" {
return fmt.Errorf("host 'name' field can not be blank")
}
}
return nil
}
示例6:
package distro
import (
"github.com/evergreen-ci/evergreen/db"
"github.com/evergreen-ci/evergreen/db/bsonutil"
"gopkg.in/mgo.v2/bson"
)
var (
// bson fields for the Distro struct
IdKey = bsonutil.MustHaveTag(Distro{}, "Id")
ArchKey = bsonutil.MustHaveTag(Distro{}, "Arch")
PoolSizeKey = bsonutil.MustHaveTag(Distro{}, "PoolSize")
ProviderKey = bsonutil.MustHaveTag(Distro{}, "Provider")
ProviderSettingsKey = bsonutil.MustHaveTag(Distro{}, "ProviderSettings")
SetupAsSudoKey = bsonutil.MustHaveTag(Distro{}, "SetupAsSudo")
SetupKey = bsonutil.MustHaveTag(Distro{}, "Setup")
UserKey = bsonutil.MustHaveTag(Distro{}, "User")
SSHKeyKey = bsonutil.MustHaveTag(Distro{}, "SSHKey")
SSHOptionsKey = bsonutil.MustHaveTag(Distro{}, "SSHOptions")
WorkDirKey = bsonutil.MustHaveTag(Distro{}, "WorkDir")
UserDataKey = bsonutil.MustHaveTag(Distro{}, "UserData")
SpawnAllowedKey = bsonutil.MustHaveTag(Distro{}, "SpawnAllowed")
ExpansionsKey = bsonutil.MustHaveTag(Distro{}, "Expansions")
// bson fields for the UserData struct
UserDataFileKey = bsonutil.MustHaveTag(UserData{}, "File")
UserDataValidateKey = bsonutil.MustHaveTag(UserData{}, "Validate")
)
示例7:
import (
"github.com/evergreen-ci/evergreen/db"
"github.com/evergreen-ci/evergreen/db/bsonutil"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
const (
Collection = "patches"
GridFSPrefix = "patchfiles"
)
// BSON fields for the patches
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")
示例8:
}
type TaskQueueItem struct {
Id string `bson:"_id" json:"_id"`
DisplayName string `bson:"display_name" json:"display_name"`
BuildVariant string `bson:"build_variant" json:"build_variant"`
RevisionOrderNumber int `bson:"order" json:"order"`
Requester string `bson:"requester" json:"requester"`
Revision string `bson:"gitspec" json:"gitspec"`
Project string `bson:"project" json:"project"`
ExpectedDuration time.Duration `bson:"exp_dur" json:"exp_dur"`
}
var (
// bson fields for the task queue struct
TaskQueueIdKey = bsonutil.MustHaveTag(TaskQueue{}, "Id")
TaskQueueDistroKey = bsonutil.MustHaveTag(TaskQueue{}, "Distro")
TaskQueueQueueKey = bsonutil.MustHaveTag(TaskQueue{}, "Queue")
// bson fields for the individual task queue items
TaskQueueItemIdKey = bsonutil.MustHaveTag(TaskQueueItem{}, "Id")
TaskQueueItemDisplayNameKey = bsonutil.MustHaveTag(TaskQueueItem{},
"DisplayName")
TaskQueueItemBuildVariantKey = bsonutil.MustHaveTag(TaskQueueItem{},
"BuildVariant")
TaskQueueItemConKey = bsonutil.MustHaveTag(TaskQueueItem{},
"RevisionOrderNumber")
TaskQueueItemRequesterKey = bsonutil.MustHaveTag(TaskQueueItem{},
"Requester")
TaskQueueItemRevisionKey = bsonutil.MustHaveTag(TaskQueueItem{},
"Revision")
示例9:
"github.com/evergreen-ci/evergreen/db/bsonutil"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"time"
)
// Repository contains fields used to track projects.
type Repository struct {
Project string `bson:"_id"`
LastRevision string `bson:"last_revision"`
RevisionOrderNumber int `bson:"last_commit_number"`
}
var (
// BSON fields for the Repository struct
RepoProjectKey = bsonutil.MustHaveTag(Repository{},
"Project")
RepoLastRevisionKey = bsonutil.MustHaveTag(Repository{},
"LastRevision")
RepositoryOrderNumberKey = bsonutil.MustHaveTag(Repository{},
"RevisionOrderNumber")
)
const (
RepositoriesCollection = "repo_revisions"
)
const (
GithubRepoType = "github"
)
// valid repositories - currently only github supported
示例10: FindOne
package manifest
import (
"github.com/evergreen-ci/evergreen/db"
"github.com/evergreen-ci/evergreen/db/bsonutil"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
var (
// BSON fields for artifact file structs
IdKey = bsonutil.MustHaveTag(Manifest{}, "Id")
ManifestRevisionKey = bsonutil.MustHaveTag(Manifest{}, "Revision")
ProjectNameKey = bsonutil.MustHaveTag(Manifest{}, "ProjectName")
ModulesKey = bsonutil.MustHaveTag(Manifest{}, "Modules")
ManifestBranchKey = bsonutil.MustHaveTag(Manifest{}, "Branch")
ModuleBranchKey = bsonutil.MustHaveTag(Module{}, "Branch")
ModuleRevisionKey = bsonutil.MustHaveTag(Module{}, "Revision")
OwnerKey = bsonutil.MustHaveTag(Module{}, "Owner")
UrlKey = bsonutil.MustHaveTag(Module{}, "URL")
)
// FindOne gets one Manifest for the given query.
func FindOne(query db.Q) (*Manifest, error) {
m := &Manifest{}
err := db.FindOneQ(Collection, query, m)
if err == mgo.ErrNotFound {
return nil, nil
}
return m, err
}
示例11: FindAllProcessRuntimes
RuntimesCollection = "process_runtimes"
)
// ProcessRuntime tracks the most recent success ping by
// a given MCI process by storing it in mongodb.
// Id is a package name (see globals.go), FinishedAt is a time
// representing the most recent completion of that process,
// and Runtime is the duration of time the process took to run
type ProcessRuntime struct {
Id string `bson:"_id" json:"id"`
FinishedAt time.Time `bson:"finished_at" json:"finished_at"`
Runtime time.Duration `bson:"runtime" json:"runtime"`
}
var (
ProcRuntimeIdKey = bsonutil.MustHaveTag(ProcessRuntime{}, "Id")
ProcRuntimeFinishedAtKey = bsonutil.MustHaveTag(ProcessRuntime{},
"FinishedAt")
ProcRuntimeRuntimeKey = bsonutil.MustHaveTag(ProcessRuntime{}, "Runtime")
)
/******************************************************
Find
******************************************************/
func FindAllProcessRuntimes(query interface{},
projection interface{}) ([]ProcessRuntime, error) {
runtimes := []ProcessRuntime{}
err := db.FindAll(
RuntimesCollection,
query,
示例12:
ProjectId string `bson:"project_id" json:"project_id"`
TaskId string `bson:"task_id" json:"task_id"`
BuildId string `bson:"build_id" json:"build_id"`
Variant string `bson:"variant" json:"variant"`
VersionId string `bson:"version_id" json:"version_id"`
CreateTime time.Time `bson:"create_time" json:"create_time"`
IsPatch bool `bson:"is_patch" json:"is_patch"`
RevisionOrderNumber int `bson:"order" json:"order"`
Revision string `bson:"revision" json:"revision"`
Data map[string]interface{} `bson:"data" json:"data"`
Tag string `bson:"tag" json:"tag"`
}
var (
// BSON fields for the TaskJSON struct
NameKey = bsonutil.MustHaveTag(TaskJSON{}, "Name")
TaskNameKey = bsonutil.MustHaveTag(TaskJSON{}, "TaskName")
ProjectIdKey = bsonutil.MustHaveTag(TaskJSON{}, "ProjectId")
TaskIdKey = bsonutil.MustHaveTag(TaskJSON{}, "TaskId")
BuildIdKey = bsonutil.MustHaveTag(TaskJSON{}, "BuildId")
VariantKey = bsonutil.MustHaveTag(TaskJSON{}, "Variant")
VersionIdKey = bsonutil.MustHaveTag(TaskJSON{}, "VersionId")
CreateTimeKey = bsonutil.MustHaveTag(TaskJSON{}, "CreateTime")
IsPatchKey = bsonutil.MustHaveTag(TaskJSON{}, "IsPatch")
RevisionOrderNumberKey = bsonutil.MustHaveTag(TaskJSON{}, "RevisionOrderNumber")
RevisionKey = bsonutil.MustHaveTag(TaskJSON{}, "Revision")
DataKey = bsonutil.MustHaveTag(TaskJSON{}, "Data")
TagKey = bsonutil.MustHaveTag(TaskJSON{}, "Tag")
)
// GetRoutes returns an API route for serving patch data.
示例13:
package model
import (
"github.com/evergreen-ci/evergreen/db"
"github.com/evergreen-ci/evergreen/db/bsonutil"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
var (
ProjectVarIdKey = bsonutil.MustHaveTag(ProjectVars{}, "Id")
ProjectVarsMapKey = bsonutil.MustHaveTag(ProjectVars{}, "Vars")
)
const (
ProjectVarsCollection = "project_vars"
)
//ProjectVars holds a map of variables specific to a given project.
//They can be fetched at run time by the agent, so that settings which are
//sensitive or subject to frequent change don't need to be hard-coded into
//yml files.
type ProjectVars struct {
//Should match the _id in the project it refers to
Id string `bson:"_id" json:"_id"`
//The actual mapping of variables for this project
Vars map[string]string `bson:"vars" json:"vars"`
}
示例14:
)
type NotificationHistory struct {
Id bson.ObjectId `bson:"_id,omitempty"`
PrevNotificationId string `bson:"p_nid"`
CurrNotificationId string `bson:"c_nid"`
NotificationName string `bson:"n_name"`
NotificationType string `bson:"n_type"`
NotificationTime time.Time `bson:"n_time"`
NotificationProject string `bson:"n_branch"`
NotificationRequester string `bson:"n_requester"`
}
var (
// bson fields for the notification history struct
NHIdKey = bsonutil.MustHaveTag(NotificationHistory{}, "Id")
NHPrevIdKey = bsonutil.MustHaveTag(NotificationHistory{},
"PrevNotificationId")
NHCurrIdKey = bsonutil.MustHaveTag(NotificationHistory{},
"CurrNotificationId")
NHNameKey = bsonutil.MustHaveTag(NotificationHistory{},
"NotificationName")
NHTypeKey = bsonutil.MustHaveTag(NotificationHistory{},
"NotificationType")
NHTimeKey = bsonutil.MustHaveTag(NotificationHistory{},
"NotificationTime")
NHProjectKey = bsonutil.MustHaveTag(NotificationHistory{},
"NotificationProject")
NHRequesterKey = bsonutil.MustHaveTag(NotificationHistory{},
"NotificationRequester")
)
示例15:
OnDemandProviderName = "ec2"
SpotProviderName = "ec2-spot"
NameTimeFormat = "20060102150405"
SpawnHostExpireDays = 90
MciHostExpireDays = 30
)
type MountPoint struct {
VirtualName string `mapstructure:"virtual_name" json:"virtual_name,omitempty" bson:"virtual_name,omitempty"`
DeviceName string `mapstructure:"device_name" json:"device_name,omitempty" bson:"device_name,omitempty"`
Size int `mapstructure:"size" json:"size,omitempty" bson:"size,omitempty"`
}
var (
// bson fields for the EC2ProviderSettings struct
AMIKey = bsonutil.MustHaveTag(EC2ProviderSettings{}, "AMI")
InstanceTypeKey = bsonutil.MustHaveTag(EC2ProviderSettings{}, "InstanceType")
SecurityGroupKey = bsonutil.MustHaveTag(EC2ProviderSettings{}, "SecurityGroup")
KeyNameKey = bsonutil.MustHaveTag(EC2ProviderSettings{}, "KeyName")
MountPointsKey = bsonutil.MustHaveTag(EC2ProviderSettings{}, "MountPoints")
)
var (
// bson fields for the EC2SpotSettings struct
BidPriceKey = bsonutil.MustHaveTag(EC2SpotSettings{}, "BidPrice")
)
var (
// bson fields for the MountPoint struct
VirtualNameKey = bsonutil.MustHaveTag(MountPoint{}, "VirtualName")
DeviceNameKey = bsonutil.MustHaveTag(MountPoint{}, "DeviceName")