github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/engine/buildcontrol/hold_set.go (about) 1 package buildcontrol 2 3 import ( 4 "github.com/tilt-dev/tilt/internal/store" 5 "github.com/tilt-dev/tilt/pkg/model" 6 ) 7 8 type HoldSet map[model.ManifestName]store.Hold 9 10 func (s HoldSet) IsEligible(target *store.ManifestTarget) bool { 11 mn := target.Manifest.Name 12 if s[mn].Reason != store.HoldReasonNone { 13 return false 14 } 15 16 if target.State.IsBuilding() { 17 return false 18 } 19 20 if target.NextBuildReason() == 0 { 21 return false 22 } 23 24 return true 25 } 26 27 func (s HoldSet) RemoveIneligibleTargets(targets []*store.ManifestTarget) []*store.ManifestTarget { 28 result := make([]*store.ManifestTarget, 0, len(targets)) 29 for _, target := range targets { 30 if s.IsEligible(target) { 31 result = append(result, target) 32 } 33 } 34 return result 35 } 36 37 func (s HoldSet) AddHold(target *store.ManifestTarget, hold store.Hold) { 38 mn := target.Manifest.Name 39 if s[mn].Reason != store.HoldReasonNone { 40 return 41 } 42 43 if target.State.IsBuilding() { 44 return 45 } 46 47 if target.NextBuildReason() == 0 { 48 return 49 } 50 51 s[mn] = hold 52 } 53 54 // For all the targets that should have built and don't have a prior Hold, add the given Hold. 55 func (s HoldSet) Fill(targets []*store.ManifestTarget, hold store.Hold) { 56 for _, target := range targets { 57 s.AddHold(target, hold) 58 } 59 }