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