1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-06-30 22:13:45 +02:00
Files
woodpecker/model/event.go

39 lines
807 B
Go
Raw Normal View History

2016-09-27 20:30:28 -05:00
package model
2016-04-12 17:27:24 -07: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-27 20:30:28 -05:00
Type EventType `json:"type"`
Repo Repo `json:"repo"`
Build Build `json:"build"`
Job Job `json:"job"`
2016-04-12 17:27:24 -07:00
}
// NewEvent creates a new Event for the build, using copies of
// the build data to avoid possible mutation or race conditions.
2016-09-27 20:30:28 -05:00
func NewEvent(t EventType, r *Repo, b *Build, j *Job) *Event {
2016-04-12 17:27:24 -07:00
return &Event{
Type: t,
Repo: *r,
Build: *b,
Job: *j,
}
}
2016-09-27 20:30:28 -05:00
func NewBuildEvent(t EventType, r *Repo, b *Build) *Event {
return &Event{
Type: t,
Repo: *r,
Build: *b,
}
}