コード例 #1
0
ファイル: notify_times.go プロジェクト: himanshugpt/evergreen
	"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
0
ファイル: docker.go プロジェクト: tychoish/evergreen
	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
0
ファイル: project.go プロジェクト: bjori/evergreen
			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
0
ファイル: digitalocean.go プロジェクト: sr527/evergreen
)

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
0
ファイル: static.go プロジェクト: tychoish/evergreen
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
0
ファイル: db.go プロジェクト: himanshugpt/evergreen
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
0
ファイル: db.go プロジェクト: tychoish/evergreen
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
0
ファイル: task_queue.go プロジェクト: himanshugpt/evergreen
}

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
0
ファイル: repository.go プロジェクト: himanshugpt/evergreen
	"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
0
ファイル: db.go プロジェクト: himanshugpt/evergreen
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
0
	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
0
ファイル: json.go プロジェクト: 10gen/evg-json
	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
0
ファイル: project_vars.go プロジェクト: himanshugpt/evergreen
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
0
)

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
0
ファイル: ec2_util.go プロジェクト: sr527/evergreen
	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")
コード例 #16
0
ファイル: push.go プロジェクト: himanshugpt/evergreen
	Location string `bson:"location"`

	//the task id of the push stage
	TaskId string `bson:"task_id"`

	CreateTime time.Time `bson:"create_time"`
	Revision   string    `bson:"githash"`
	Status     string    `bson:"status"`

	//copied from version for the task
	RevisionOrderNumber int `bson:"order"`
}

var (
	// bson fields for the push log struct
	PushLogIdKey         = bsonutil.MustHaveTag(PushLog{}, "Id")
	PushLogLocationKey   = bsonutil.MustHaveTag(PushLog{}, "Location")
	PushLogTaskIdKey     = bsonutil.MustHaveTag(PushLog{}, "TaskId")
	PushLogCreateTimeKey = bsonutil.MustHaveTag(PushLog{}, "CreateTime")
	PushLogRevisionKey   = bsonutil.MustHaveTag(PushLog{}, "Revision")
	PushLogStatusKey     = bsonutil.MustHaveTag(PushLog{}, "Status")
	PushLogRonKey        = bsonutil.MustHaveTag(PushLog{}, "RevisionOrderNumber")
)

func NewPushLog(v *version.Version, task *Task, location string) *PushLog {
	return &PushLog{
		Id:                  bson.NewObjectId(),
		Location:            location,
		TaskId:              task.Id,
		CreateTime:          time.Now(),
		Revision:            v.Revision,
コード例 #17
0
ファイル: db.go プロジェクト: himanshugpt/evergreen
package artifact

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
	TaskIdKey   = bsonutil.MustHaveTag(Entry{}, "TaskId")
	TaskNameKey = bsonutil.MustHaveTag(Entry{}, "TaskDisplayName")
	BuildIdKey  = bsonutil.MustHaveTag(Entry{}, "BuildId")
	FilesKey    = bsonutil.MustHaveTag(Entry{}, "Files")
	NameKey     = bsonutil.MustHaveTag(File{}, "Name")
	LinkKey     = bsonutil.MustHaveTag(File{}, "Link")
)

// === Queries ===

// ByTaskId returns a query for entries with the given Task Id
func ByTaskId(id string) db.Q {
	return db.Query(bson.D{{TaskIdKey, id}})
}

// ByBuildId returns all entries with the given Build Id, sorted by Task name
func ByBuildId(id string) db.Q {
	return db.Query(bson.D{{BuildIdKey, id}}).Sort([]string{TaskNameKey})
}
コード例 #18
0
ファイル: db.go プロジェクト: MauroJr/evergreen
import (
	"github.com/evergreen-ci/evergreen"
	"github.com/evergreen-ci/evergreen/db"
	"github.com/evergreen-ci/evergreen/db/bsonutil"
	"gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
)

const (
	Collection = "versions"
)

var (
	// bson fields for the version struct
	IdKey                  = bsonutil.MustHaveTag(Version{}, "Id")
	CreateTimeKey          = bsonutil.MustHaveTag(Version{}, "CreateTime")
	StartTimeKey           = bsonutil.MustHaveTag(Version{}, "StartTime")
	FinishTimeKey          = bsonutil.MustHaveTag(Version{}, "FinishTime")
	ProjectKey             = bsonutil.MustHaveTag(Version{}, "Project")
	RevisionKey            = bsonutil.MustHaveTag(Version{}, "Revision")
	AuthorKey              = bsonutil.MustHaveTag(Version{}, "Author")
	AuthorEmailKey         = bsonutil.MustHaveTag(Version{}, "AuthorEmail")
	MessageKey             = bsonutil.MustHaveTag(Version{}, "Message")
	StatusKey              = bsonutil.MustHaveTag(Version{}, "Status")
	BuildIdsKey            = bsonutil.MustHaveTag(Version{}, "BuildIds")
	BuildVariantsKey       = bsonutil.MustHaveTag(Version{}, "BuildVariants")
	RevisionOrderNumberKey = bsonutil.MustHaveTag(Version{}, "RevisionOrderNumber")
	RequesterKey           = bsonutil.MustHaveTag(Version{}, "Requester")
	ConfigKey              = bsonutil.MustHaveTag(Version{}, "Config")
	OwnerNameKey           = bsonutil.MustHaveTag(Version{}, "Owner")
コード例 #19
0
ファイル: db.go プロジェクト: himanshugpt/evergreen
package user

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 = "users"
)

var (
	IdKey           = bsonutil.MustHaveTag(DBUser{}, "Id")
	FirstNameKey    = bsonutil.MustHaveTag(DBUser{}, "FirstName")
	LastNameKey     = bsonutil.MustHaveTag(DBUser{}, "LastName")
	DispNameKey     = bsonutil.MustHaveTag(DBUser{}, "DispName")
	EmailAddressKey = bsonutil.MustHaveTag(DBUser{}, "EmailAddress")
	PatchNumberKey  = bsonutil.MustHaveTag(DBUser{}, "PatchNumber")
	CreatedAtKey    = bsonutil.MustHaveTag(DBUser{}, "CreatedAt")
	SettingsKey     = bsonutil.MustHaveTag(DBUser{}, "Settings")
	APIKeyKey       = bsonutil.MustHaveTag(DBUser{}, "APIKey")
	PubKeysKey      = bsonutil.MustHaveTag(DBUser{}, "PubKeys")
)

var (
	PubKeyNameKey       = bsonutil.MustHaveTag(PubKey{}, "Name")
	PubKeyKey           = bsonutil.MustHaveTag(PubKey{}, "Key")
	PubKeyNCreatedAtKey = bsonutil.MustHaveTag(PubKey{}, "CreatedAt")
)
コード例 #20
0
ファイル: project_ref.go プロジェクト: tychoish/evergreen
type AlertConfig struct {
	Provider string `bson:"provider" json:"provider"` //e.g. e-mail, flowdock, SMS

	// Data contains provider-specific on how a notification should be delivered.
	// Typed as bson.M so that the appropriate provider can parse out necessary details
	Settings bson.M `bson:"settings" json:"settings"`
}

type EmailAlertData struct {
	Recipients []string `bson:"recipients"`
}

var (
	// bson fields for the ProjectRef struct
	ProjectRefOwnerKey              = bsonutil.MustHaveTag(ProjectRef{}, "Owner")
	ProjectRefRepoKey               = bsonutil.MustHaveTag(ProjectRef{}, "Repo")
	ProjectRefBranchKey             = bsonutil.MustHaveTag(ProjectRef{}, "Branch")
	ProjectRefRepoKindKey           = bsonutil.MustHaveTag(ProjectRef{}, "RepoKind")
	ProjectRefEnabledKey            = bsonutil.MustHaveTag(ProjectRef{}, "Enabled")
	ProjectRefPrivateKey            = bsonutil.MustHaveTag(ProjectRef{}, "Private")
	ProjectRefBatchTimeKey          = bsonutil.MustHaveTag(ProjectRef{}, "BatchTime")
	ProjectRefIdentifierKey         = bsonutil.MustHaveTag(ProjectRef{}, "Identifier")
	ProjectRefDisplayNameKey        = bsonutil.MustHaveTag(ProjectRef{}, "DisplayName")
	ProjectRefDeactivatePreviousKey = bsonutil.MustHaveTag(ProjectRef{}, "DeactivatePrevious")
	ProjectRefRemotePathKey         = bsonutil.MustHaveTag(ProjectRef{}, "RemotePath")
	ProjectRefTrackedKey            = bsonutil.MustHaveTag(ProjectRef{}, "Tracked")
	ProjectRefLocalConfig           = bsonutil.MustHaveTag(ProjectRef{}, "LocalConfig")
	ProjectRefAlertsKey             = bsonutil.MustHaveTag(ProjectRef{}, "Alerts")
	ProjectRefRepotrackerError      = bsonutil.MustHaveTag(ProjectRef{}, "RepotrackerError")
	ProjectRefAdminsKey             = bsonutil.MustHaveTag(ProjectRef{}, "Admins")
コード例 #21
0
ファイル: event.go プロジェクト: tychoish/evergreen
const (
	// db constants
	Collection = "event_log"
)

type Event struct {
	Timestamp  time.Time   `bson:"ts" json:"timestamp"`
	ResourceId string      `bson:"r_id" json:"resource_id"`
	EventType  string      `bson:"e_type" json:"event_type"`
	Data       DataWrapper `bson:"data" json:"data"`
}

var (
	// bson fields for the event struct
	TimestampKey  = bsonutil.MustHaveTag(Event{}, "Timestamp")
	ResourceIdKey = bsonutil.MustHaveTag(Event{}, "ResourceId")
	TypeKey       = bsonutil.MustHaveTag(Event{}, "EventType")
	DataKey       = bsonutil.MustHaveTag(Event{}, "Data")

	// resource type key.  this doesn't exist a part of the event struct,
	// but has to be the same for all of the event types
	ResourceTypeKey = bsonutil.MustHaveTag(HostEventData{}, "ResourceType")
)

type DataWrapper struct {
	Data
}

type Data interface {
	IsValid() bool
コード例 #22
0
ファイル: version.go プロジェクト: sr527/evergreen
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")
)
コード例 #23
0
ファイル: test_log.go プロジェクト: tychoish/evergreen
	"gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
)

const TestLogCollection = "test_logs"

type TestLog struct {
	Id            string   `bson:"_id" json:"_id"`
	Name          string   `json:"name" bson:"name"`
	Task          string   `json:"task" bson:"task"`
	TaskExecution int      `json:"execution" bson:"execution"`
	Lines         []string `json:"lines" bson:"lines"`
}

var (
	TestLogIdKey            = bsonutil.MustHaveTag(TestLog{}, "Id")
	TestLogNameKey          = bsonutil.MustHaveTag(TestLog{}, "Name")
	TestLogTaskKey          = bsonutil.MustHaveTag(TestLog{}, "Task")
	TestLogTaskExecutionKey = bsonutil.MustHaveTag(TestLog{}, "TaskExecution")
	TestLogLinesKey         = bsonutil.MustHaveTag(TestLog{}, "Lines")
)

func FindOneTestLogById(id string) (*TestLog, error) {
	tl := &TestLog{}
	err := db.FindOne(
		TestLogCollection,
		bson.M{
			TestLogIdKey: id,
		},
		db.NoProjection,
		db.NoSort,
コード例 #24
0
ファイル: task_log.go プロジェクト: tychoish/evergreen
	Version   int       `bson:"v" json:"v"`
}

// a single chunk of a task log
type TaskLog struct {
	Id           bson.ObjectId `bson:"_id,omitempty" json:"_id,omitempty"`
	TaskId       string        `bson:"t_id" json:"t_id"`
	Execution    int           `bson:"e" json:"e"`
	Timestamp    time.Time     `bson:"ts" json:"ts"`
	MessageCount int           `bson:"c" json:"c"`
	Messages     []LogMessage  `bson:"m" json:"m"`
}

var (
	// bson fields for the task log struct
	TaskLogIdKey           = bsonutil.MustHaveTag(TaskLog{}, "Id")
	TaskLogTaskIdKey       = bsonutil.MustHaveTag(TaskLog{}, "TaskId")
	TaskLogExecutionKey    = bsonutil.MustHaveTag(TaskLog{}, "Execution")
	TaskLogTimestampKey    = bsonutil.MustHaveTag(TaskLog{}, "Timestamp")
	TaskLogMessageCountKey = bsonutil.MustHaveTag(TaskLog{}, "MessageCount")
	TaskLogMessagesKey     = bsonutil.MustHaveTag(TaskLog{}, "Messages")

	// bson fields for the log message struct
	LogMessageTypeKey      = bsonutil.MustHaveTag(LogMessage{}, "Type")
	LogMessageSeverityKey  = bsonutil.MustHaveTag(LogMessage{}, "Severity")
	LogMessageMessageKey   = bsonutil.MustHaveTag(LogMessage{}, "Message")
	LogMessageTimestampKey = bsonutil.MustHaveTag(LogMessage{}, "Timestamp")
)

// helper for getting the correct db
func getSessionAndDB() (*mgo.Session, *mgo.Database, error) {
コード例 #25
0
		jqlClause = fmt.Sprintf("text~\"%v\"", task.DisplayName)
	}

	return fmt.Sprintf(JQLBFQuery, jqlClause)
}

// Note contains arbitrary information entered by an Evergreen user, scope to a task.
type Note struct {
	TaskId       string `bson:"_id" json:"-"`
	UnixNanoTime int64  `bson:"time" json:"time"`
	Content      string `bson:"content" json:"content"`
}

// Note DB Logic

var TaskIdKey = bsonutil.MustHaveTag(Note{}, "TaskId")

// Upsert overwrites an existing note.
func (n *Note) Upsert() error {
	_, err := db.Upsert(
		NotesCollection,
		bson.D{{TaskIdKey, n.TaskId}},
		n,
	)
	return err
}

// NoteForTask returns the note for the given task Id, if it exists.
func NoteForTask(taskId string) (*Note, error) {
	n := &Note{}
	err := db.FindOneQ(
コード例 #26
0
)

type AlertRecord struct {
	Id                  bson.ObjectId `bson:"_id"`
	Type                string        `bson:"type"`
	HostId              string        `bson:"host_id,omitempty"`
	TaskId              string        `bson:"task_id,omitempty"`
	ProjectId           string        `bson:"project_id,omitempty"`
	VersionId           string        `bson:"version_id,omitempty"`
	TaskName            string        `bson:"task_name,omitempty"`
	Variant             string        `bson:"variant,omitempty"`
	RevisionOrderNumber int           `bson:"order,omitempty"`
}

var (
	IdKey                  = bsonutil.MustHaveTag(AlertRecord{}, "Id")
	TypeKey                = bsonutil.MustHaveTag(AlertRecord{}, "Type")
	TaskIdKey              = bsonutil.MustHaveTag(AlertRecord{}, "TaskId")
	HostIdKey              = bsonutil.MustHaveTag(AlertRecord{}, "HostId")
	TaskNameKey            = bsonutil.MustHaveTag(AlertRecord{}, "TaskName")
	VariantKey             = bsonutil.MustHaveTag(AlertRecord{}, "Variant")
	ProjectIdKey           = bsonutil.MustHaveTag(AlertRecord{}, "ProjectId")
	VersionIdKey           = bsonutil.MustHaveTag(AlertRecord{}, "VersionId")
	RevisionOrderNumberKey = bsonutil.MustHaveTag(AlertRecord{}, "RevisionOrderNumber")
)

// FindOne gets one AlertRecord for the given query.
func FindOne(query db.Q) (*AlertRecord, error) {
	alertRec := &AlertRecord{}
	err := db.FindOneQ(Collection, query, alertRec)
	if err == mgo.ErrNotFound {
コード例 #27
0
ファイル: db.go プロジェクト: sr527/evergreen
	"github.com/evergreen-ci/evergreen/db/bsonutil"
	"github.com/evergreen-ci/evergreen/util"
	"gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
	"time"
)

const (
	Collection    = "tasks"
	OldCollection = "old_tasks"
	TestLogPath   = "/test_log/"
)

var (
	// BSON fields for the task struct
	IdKey                  = bsonutil.MustHaveTag(Task{}, "Id")
	SecretKey              = bsonutil.MustHaveTag(Task{}, "Secret")
	CreateTimeKey          = bsonutil.MustHaveTag(Task{}, "CreateTime")
	DispatchTimeKey        = bsonutil.MustHaveTag(Task{}, "DispatchTime")
	PushTimeKey            = bsonutil.MustHaveTag(Task{}, "PushTime")
	ScheduledTimeKey       = bsonutil.MustHaveTag(Task{}, "ScheduledTime")
	StartTimeKey           = bsonutil.MustHaveTag(Task{}, "StartTime")
	FinishTimeKey          = bsonutil.MustHaveTag(Task{}, "FinishTime")
	VersionKey             = bsonutil.MustHaveTag(Task{}, "Version")
	ProjectKey             = bsonutil.MustHaveTag(Task{}, "Project")
	RevisionKey            = bsonutil.MustHaveTag(Task{}, "Revision")
	LastHeartbeatKey       = bsonutil.MustHaveTag(Task{}, "LastHeartbeat")
	ActivatedKey           = bsonutil.MustHaveTag(Task{}, "Activated")
	BuildIdKey             = bsonutil.MustHaveTag(Task{}, "BuildId")
	DistroIdKey            = bsonutil.MustHaveTag(Task{}, "DistroId")
	BuildVariantKey        = bsonutil.MustHaveTag(Task{}, "BuildVariant")
コード例 #28
0
ファイル: db.go プロジェクト: himanshugpt/evergreen
import (
	"github.com/evergreen-ci/evergreen"
	"github.com/evergreen-ci/evergreen/db"
	"github.com/evergreen-ci/evergreen/db/bsonutil"
	"gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
	"time"
)

// The MongoDB collection for build documents.
const Collection = "builds"

var (
	// bson fields for the build struct
	IdKey                  = bsonutil.MustHaveTag(Build{}, "Id")
	CreateTimeKey          = bsonutil.MustHaveTag(Build{}, "CreateTime")
	StartTimeKey           = bsonutil.MustHaveTag(Build{}, "StartTime")
	FinishTimeKey          = bsonutil.MustHaveTag(Build{}, "FinishTime")
	PushTimeKey            = bsonutil.MustHaveTag(Build{}, "PushTime")
	VersionKey             = bsonutil.MustHaveTag(Build{}, "Version")
	ProjectKey             = bsonutil.MustHaveTag(Build{}, "Project")
	RevisionKey            = bsonutil.MustHaveTag(Build{}, "Revision")
	BuildVariantKey        = bsonutil.MustHaveTag(Build{}, "BuildVariant")
	BuildNumberKey         = bsonutil.MustHaveTag(Build{}, "BuildNumber")
	StatusKey              = bsonutil.MustHaveTag(Build{}, "Status")
	ActivatedKey           = bsonutil.MustHaveTag(Build{}, "Activated")
	ActivatedByKey         = bsonutil.MustHaveTag(Build{}, "ActivatedBy")
	ActivatedTimeKey       = bsonutil.MustHaveTag(Build{}, "ActivatedTime")
	RevisionOrderNumberKey = bsonutil.MustHaveTag(Build{}, "RevisionOrderNumber")
	TasksKey               = bsonutil.MustHaveTag(Build{}, "Tasks")
コード例 #29
0
ファイル: db.go プロジェクト: sr527/evergreen
	"gopkg.in/mgo.v2/bson"
	"time"
)

const (
	// Collection is the name of the MongoDB collection that stores hosts.
	Collection = "hosts"
)

var noRunningTask = []bson.D{
	bson.D{{"running_task", ""}},
	bson.D{{"running_task", bson.D{{"$exists", false}}}},
}

var (
	IdKey                    = bsonutil.MustHaveTag(Host{}, "Id")
	DNSKey                   = bsonutil.MustHaveTag(Host{}, "Host")
	UserKey                  = bsonutil.MustHaveTag(Host{}, "User")
	TagKey                   = bsonutil.MustHaveTag(Host{}, "Tag")
	DistroKey                = bsonutil.MustHaveTag(Host{}, "Distro")
	ProviderKey              = bsonutil.MustHaveTag(Host{}, "Provider")
	ProvisionedKey           = bsonutil.MustHaveTag(Host{}, "Provisioned")
	RunningTaskKey           = bsonutil.MustHaveTag(Host{}, "RunningTask")
	PidKey                   = bsonutil.MustHaveTag(Host{}, "Pid")
	TaskDispatchTimeKey      = bsonutil.MustHaveTag(Host{}, "TaskDispatchTime")
	CreateTimeKey            = bsonutil.MustHaveTag(Host{}, "CreationTime")
	ExpirationTimeKey        = bsonutil.MustHaveTag(Host{}, "ExpirationTime")
	TerminationTimeKey       = bsonutil.MustHaveTag(Host{}, "TerminationTime")
	LTCTimeKey               = bsonutil.MustHaveTag(Host{}, "LastTaskCompletedTime")
	LTCKey                   = bsonutil.MustHaveTag(Host{}, "LastTaskCompleted")
	StatusKey                = bsonutil.MustHaveTag(Host{}, "Status")
コード例 #30
0
ファイル: db.go プロジェクト: himanshugpt/evergreen
package alert

import (
	"github.com/evergreen-ci/evergreen/db/bsonutil"
)

const (
	// Collection is the name of the collection in MongoDB that stores alerts.
	Collection = "alerts"
)

var (
	IdKey          = bsonutil.MustHaveTag(AlertRequest{}, "Id")
	HostIdKey      = bsonutil.MustHaveTag(AlertRequest{}, "HostId")
	TriggerKey     = bsonutil.MustHaveTag(AlertRequest{}, "Trigger")
	QueueStatusKey = bsonutil.MustHaveTag(AlertRequest{}, "QueueStatus")
	TaskIdKey      = bsonutil.MustHaveTag(AlertRequest{}, "TaskId")
	BuildIdKey     = bsonutil.MustHaveTag(AlertRequest{}, "BuildId")
	VersionIdKey   = bsonutil.MustHaveTag(AlertRequest{}, "VersionId")
	ProjectIdKey   = bsonutil.MustHaveTag(AlertRequest{}, "ProjectId")
	DisplayKey     = bsonutil.MustHaveTag(AlertRequest{}, "Display")
	CreatedAtKey   = bsonutil.MustHaveTag(AlertRequest{}, "CreatedAt")
)