harness-drone/model/event.go

39 lines
807 B
Go
Raw Normal View History

2016-09-28 01:30:28 +00:00
package model
2016-04-13 00:27:24 +00:00
// EventType defines the possible types of build events.
type EventType string
const (
Enqueued EventType = "enqueued"
Started EventType = "started"
Finished EventType = "finished"
Cancelled EventType = "cancelled"
)
// Event represents a build event.
type Event struct {
2016-09-28 01:30:28 +00:00
Type EventType `json:"type"`
Repo Repo `json:"repo"`
Build Build `json:"build"`
Job Job `json:"job"`
2016-04-13 00:27:24 +00:00
}
// NewEvent creates a new Event for the build, using copies of
// the build data to avoid possible mutation or race conditions.
2016-09-28 01:30:28 +00:00
func NewEvent(t EventType, r *Repo, b *Build, j *Job) *Event {
2016-04-13 00:27:24 +00:00
return &Event{
Type: t,
Repo: *r,
Build: *b,
Job: *j,
}
}
2016-09-28 01:30:28 +00:00
func NewBuildEvent(t EventType, r *Repo, b *Build) *Event {
return &Event{
Type: t,
Repo: *r,
Build: *b,
}
}