Documentation
¶
Index ¶
- Variables
- func CustomizeJobs(phaseType PhaseType, jobs []string)
- func DoesCommitNeedTicket(commit *Commit, commitsOnTickets map[string]struct{}) bool
- func JobsForPhase(phaseType PhaseType) []string
- func ShortSHA(sha string) string
- type Auth
- type Clock
- type Commit
- type CommitsByID
- type Config
- type Interval
- type Intervals
- type Job
- type JobResult
- type Jobs
- type JobsByID
- type Metadata
- type Mode
- type Moment
- type Options
- func (o Options) CloseTimeOverlap(start time.Time, end time.Time) time.Duration
- func (o Options) FieldType() int
- func (o *Options) FromString(optionsString string) error
- func (o Options) InCloseTime() bool
- func (o Options) RawValue() interface{}
- func (o *Options) SetRaw(raw interface{}) error
- func (o Options) String() string
- type Phase
- type PhaseGroup
- type PhaseType
- type RepeatingTimeInterval
- type RepeatingTimeIntervals
- type Search
- type Ticket
- type TicketsByID
- type Time
- type TimeInterval
- type Train
- func (train *Train) CommitsBetween(headSHA string, tailSHA string) []*Commit
- func (train *Train) CommitsSince(headSHA string) []*Commit
- func (train *Train) DatadogTags() []string
- func (train *Train) GetNotDeployableReason() *string
- func (train *Train) GitReference() string
- func (train *Train) IsCancelled() bool
- func (train *Train) IsDeployable() bool
- func (train *Train) IsDeployed() bool
- func (train *Train) IsDeploying() bool
- func (train *Train) IsDone() bool
- func (train *Train) NewCommitsNeedingTickets(headSHA string) []*Commit
- func (train *Train) Phase(phaseType PhaseType) *Phase
- func (train *Train) SendCommitCountMetrics()
- func (train *Train) SetActivePhase()
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultConfig = &Config{ID: 1, Mode: Schedule, Options: DefaultOptions}
View Source
var DefaultOptions = Options{CloseTime: defaultCloseTime}
Functions ¶
func CustomizeJobs ¶
Should only be used for tests or fake implementation.
func DoesCommitNeedTicket ¶
func JobsForPhase ¶
Types ¶
type Auth ¶
type Auth struct {
Token string `orm:"pk;size(36)" json:"token"` // Internal token token.
CreatedAt Time `orm:"auto_now_add" json:"created_at"`
User *User `orm:"rel(fk)" json:"user"`
CodeToken string `orm:"null;size(40)" json:"code_token"` // API Token for Code Service. Can be null if auth doesn't support it.
}
type Commit ¶
type Commit struct {
ID uint64 `orm:"pk;auto;column(id)" json:"id,string"`
CreatedAt Time `orm:"auto_now_add;null" json:"created_at"`
SHA string `orm:"unique;column(sha)" json:"sha"`
Message string `json:"message"`
Branch string `json:"branch" orm:"-"`
AuthorName string `json:"author_name"`
AuthorEmail string `json:"author_email"`
URL string `orm:"column(url)" json:"url"`
}
func (*Commit) DoesCommitNeedStagingNotification ¶
Should this commit trigger slack notifications to its author regarding staging.
func (*Commit) IsNeedsStaging ¶
func (*Commit) IsNoStagingVerification ¶
func (*Commit) IsNoVerify ¶
type CommitsByID ¶
type CommitsByID []*Commit
func (CommitsByID) Len ¶
func (s CommitsByID) Len() int
func (CommitsByID) Less ¶
func (s CommitsByID) Less(i, j int) bool
func (CommitsByID) Swap ¶
func (s CommitsByID) Swap(i, j int)
type Config ¶
type Config struct {
ID uint64 `orm:"pk;auto;column(id)" json:"-"`
// Current mode
Mode Mode `json:"mode"`
// JSON string for configuration, like the CloseTime config.
// See: shared/types/options.go.
Options Options `json:"options"`
}
Special settings table which should only have one row.
type Job ¶
type Job struct {
ID uint64 `orm:"pk;auto;column(id)" json:"id,string"`
StartedAt Time `orm:"null" json:"started_at"`
CompletedAt Time `orm:"null" json:"completed_at"`
URL *string `orm:"column(url);null" json:"url"` // Link to this job
Name string `json:"name"` // e.g. Delivery, Test, Build
Result JobResult `json:"result"` // Exit status
Metadata string `orm:"null" json:"metadata"` // JSON data
Phase *Phase `orm:"rel(fk)" json:"-"`
}
func (*Job) DatadogTags ¶
type Mode ¶
type Mode int
func ModeFromString ¶
func (Mode) IsManualMode ¶
func (Mode) IsScheduleMode ¶
type Options ¶
type Options struct {
// CloseTime is when trains should be automatically closed.
// This is defined as an array of TimeIntervals.
// Example: M-F 9-5.
// []TimeInterval{
// TimeInterval{
// Every: []time.Weekday{
// time.Monday, time.Tuesday, time.Wednesday, time.Thursday, time.Friday},
// StartTime: Clock{Hour: 9, Minute: 0},
// EndTime: Clock{Hour: 17, Minute: 0},
// },
// }
CloseTime RepeatingTimeIntervals `json:"close_time"`
ValidationError error `orm:"-" json:"-"`
InvalidOptionsString string `orm:"-" json:"-"`
}
func (Options) CloseTimeOverlap ¶
func (*Options) FromString ¶
func (Options) InCloseTime ¶
type Phase ¶
type Phase struct {
ID uint64 `orm:"pk;auto;column(id)" json:"id,string"`
StartedAt Time `orm:"null" json:"started_at"`
CompletedAt Time `orm:"null" json:"completed_at"`
Type PhaseType `json:"type"` // delivery|verification|deploy
Error string `orm:"null" json:"error"`
Jobs Jobs `orm:"reverse(many)" json:"jobs"`
// Computed fields
PhaseGroup *PhaseGroup `orm:"-" json:"-"`
Train *Train `orm:"-" json:"-"`
}
func (*Phase) DatadogTags ¶
func (*Phase) EarlierPhasesComplete ¶
func (*Phase) IsComplete ¶
func (*Phase) IsInActivePhaseGroup ¶
type PhaseGroup ¶
type PhaseGroup struct {
ID uint64 `orm:"pk;auto;column(id)" json:"id,string"`
HeadSHA string `orm:"column(head_sha)" json:"head_sha"`
Delivery *Phase `orm:"rel(fk)" json:"delivery"`
Verification *Phase `orm:"rel(fk)" json:"verification"`
Deploy *Phase `orm:"rel(fk)" json:"deploy"`
Train *Train `orm:"rel(fk);null" json:"-"`
}
func (*PhaseGroup) AddNewPhase ¶
func (phaseGroup *PhaseGroup) AddNewPhase(phaseType PhaseType, train *Train) *Phase
func (*PhaseGroup) GitReference ¶
func (phaseGroup *PhaseGroup) GitReference() string
func (*PhaseGroup) IsActivePhaseGroup ¶
func (phaseGroup *PhaseGroup) IsActivePhaseGroup() bool
func (*PhaseGroup) Phases ¶
func (phaseGroup *PhaseGroup) Phases() []*Phase
func (*PhaseGroup) SetReferences ¶
func (phaseGroup *PhaseGroup) SetReferences(train *Train)
type RepeatingTimeInterval ¶
type RepeatingTimeInterval struct {
Every []time.Weekday `json:"every"`
StartTime Clock `json:"start_time"`
EndTime Clock `json:"end_time"`
}
func (RepeatingTimeInterval) Includes ¶
func (interval RepeatingTimeInterval) Includes(testTime Moment) bool
Includes checks if the given time is in this RepeatingTimeInterval.
type RepeatingTimeIntervals ¶
type RepeatingTimeIntervals []RepeatingTimeInterval
func (RepeatingTimeIntervals) TotalOverlap ¶
func (repeatingTimeIntervals RepeatingTimeIntervals) TotalOverlap(start time.Time, end time.Time) time.Duration
TotalOverlap calculates the total overlap duration between the specified start and end times.
type Ticket ¶
type Ticket struct {
ID uint64 `orm:"pk;auto;column(id)" json:"id,string"`
Key string `json:"key"`
Summary string `json:"summary"`
AssigneeEmail string `json:"assignee_email"`
AssigneeName string `json:"assignee_name"`
URL string `orm:"column(url)" json:"url"`
CreatedAt Time `orm:"auto_now_add" json:"created_at"`
ClosedAt Time `orm:"null" json:"closed_at"`
DeletedAt Time `orm:"null" json:"deleted_at"`
Commits []*Commit `orm:"rel(m2m)" json:"commits"`
Train *Train `orm:"rel(fk)" json:"-"`
}
func (*Ticket) IsComplete ¶
func (*Ticket) TableUnique ¶
type TicketsByID ¶
type TicketsByID []*Ticket
func (TicketsByID) Len ¶
func (s TicketsByID) Len() int
func (TicketsByID) Less ¶
func (s TicketsByID) Less(i, j int) bool
func (TicketsByID) Swap ¶
func (s TicketsByID) Swap(i, j int)
type Time ¶
Custom type for JSON formatting. Implements beego 'fielder' interface.
func (Time) MarshalJSON ¶
func (*Time) UnmarshalJSON ¶
type TimeInterval ¶
type Train ¶
type Train struct {
ID uint64 `orm:"pk;auto;column(id)" json:"id,string"`
Engineer *User `orm:"rel(fk);null" json:"engineer"`
CreatedAt Time `orm:"auto_now_add" json:"created_at"`
DeployedAt Time `orm:"null" json:"deployed_at"`
CancelledAt Time `orm:"null" json:"cancelled_at"`
Closed bool `json:"closed"`
ScheduleOverride bool `json:"schedule_override"`
Blocked bool `json:"blocked"`
BlockedReason *string `orm:"null" json:"blocked_reason"`
Branch string `json:"branch"`
HeadSHA string `orm:"column(head_sha)" json:"head_sha"`
TailSHA string `orm:"column(tail_sha)" json:"tail_sha"`
Commits []*Commit `orm:"rel(m2m)" json:"commits"` // Commits on this train.
Tickets []*Ticket `orm:"reverse(many)" json:"tickets"` // Who's got a ticket to ride?
ActivePhases *PhaseGroup `orm:"rel(fk)" json:"active_phases"`
AllPhaseGroups []*PhaseGroup `orm:"reverse(many)" json:"all_phase_groups"`
// Computed fields
ActivePhase PhaseType `orm:"-" json:"active_phase"`
LastDeliveredSHA *string `orm:"-" json:"last_delivered_sha"` // SHA for last successful delivery.
PreviousID *uint64 `orm:"-" json:"previous_id,string"`
NextID *uint64 `orm:"-" json:"next_id,string"`
NotDeployableReason *string `orm:"-" json:"not_deployable_reason"`
Done bool `orm:"-" json:"done"`
PreviousTrainDone bool `orm:"-" json:"previous_train_done"`
CanRollback bool `orm:"-" json:"can_rollback"`
}
func (*Train) CommitsBetween ¶
Return includes head but not tail.
func (*Train) CommitsSince ¶
Return includes head.
func (*Train) DatadogTags ¶
func (*Train) GetNotDeployableReason ¶
func (*Train) GitReference ¶
func (*Train) IsCancelled ¶
func (*Train) IsDeployable ¶
func (*Train) IsDeployed ¶
func (*Train) IsDeploying ¶
func (*Train) NewCommitsNeedingTickets ¶
func (*Train) SendCommitCountMetrics ¶
func (train *Train) SendCommitCountMetrics()
func (*Train) SetActivePhase ¶
func (train *Train) SetActivePhase()
type User ¶
type User struct {
ID uint64 `orm:"pk;auto;column(id)" json:"id,string"`
CreatedAt Time `orm:"auto_now_add" json:"created_at"`
Name string `json:"name"`
Email string `orm:"unique" json:"email"`
AvatarURL string `orm:"column(avatar_url)" json:"avatar_url"`
Token string `orm:"-" json:"-"`
IsAdmin bool `orm:"-" json:"is_admin"`
}
Click to show internal directories.
Click to hide internal directories.