github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/pkg/model/build_status.go (about) 1 package model 2 3 import ( 4 "time" 5 ) 6 7 const BuildHistoryLimit = 2 8 9 type BuildType string 10 11 const BuildTypeImage BuildType = "image" 12 const BuildTypeLiveUpdate BuildType = "live-update" 13 const BuildTypeDockerCompose BuildType = "docker-compose" 14 const BuildTypeK8s BuildType = "k8s" 15 const BuildTypeLocal BuildType = "local" 16 17 type BuildRecord struct { 18 Edits []string 19 Error error 20 StartTime time.Time 21 FinishTime time.Time // IsZero() == true for in-progress builds 22 Reason BuildReason 23 24 BuildTypes []BuildType 25 26 // The lookup key for the logs in the logstore. 27 SpanID LogSpanID 28 29 // We count the warnings by looking up all the logs with Level=WARNING 30 // in the logstore. We store this number separately for ease of use. 31 WarningCount int 32 } 33 34 func (bs BuildRecord) Empty() bool { 35 return bs.StartTime.IsZero() 36 } 37 38 func (bs BuildRecord) Duration() time.Duration { 39 if bs.StartTime.IsZero() { 40 return time.Duration(0) 41 } 42 if bs.FinishTime.IsZero() { 43 return time.Since(bs.StartTime) 44 } 45 return bs.FinishTime.Sub(bs.StartTime) 46 } 47 48 func (r BuildRecord) HasBuildType(bt BuildType) bool { 49 for _, el := range r.BuildTypes { 50 if el == bt { 51 return true 52 } 53 } 54 return false 55 }