1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-12 08:23:48 +02:00
woodpecker/model/event.go

39 lines
807 B
Go
Raw Normal View History

2016-09-28 03:30:28 +02:00
package model
2016-04-13 02:27:24 +02: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 03:30:28 +02:00
Type EventType `json:"type"`
Repo Repo `json:"repo"`
Build Build `json:"build"`
Job Job `json:"job"`
2016-04-13 02:27:24 +02: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 03:30:28 +02:00
func NewEvent(t EventType, r *Repo, b *Build, j *Job) *Event {
2016-04-13 02:27:24 +02:00
return &Event{
Type: t,
Repo: *r,
Build: *b,
Job: *j,
}
}
2016-09-28 03:30:28 +02:00
func NewBuildEvent(t EventType, r *Repo, b *Build) *Event {
return &Event{
Type: t,
Repo: *r,
Build: *b,
}
}