-
Notifications
You must be signed in to change notification settings - Fork 288
/
assemble.go
57 lines (52 loc) · 1.79 KB
/
assemble.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
54
55
56
57
package manifestbuilder
import "github.com/windmilleng/tilt/pkg/model"
// Assemble these targets into a manifest, that deploys to k8s,
// wiring up all the dependency ids so that the K8sTarget depends on all
// the deployed image targets
func assembleK8s(m model.Manifest, k model.K8sTarget, iTargets ...model.ImageTarget) model.Manifest {
// images on which another image depends -- we assume they are base
// images, i.e. not deployed directly, and so the deploy target
// should not depend on them.
baseImages := make(map[model.TargetID]bool)
for _, iTarget := range iTargets {
for _, id := range iTarget.DependencyIDs() {
baseImages[id] = true
}
}
ids := make([]model.TargetID, 0, len(iTargets))
for _, iTarget := range iTargets {
if baseImages[iTarget.ID()] {
continue
}
ids = append(ids, iTarget.ID())
}
k = k.WithDependencyIDs(ids)
return m.
WithImageTargets(iTargets).
WithDeployTarget(k)
}
// Assemble these targets into a manifest, that deploys to docker compose,
// wiring up all the dependency ids so that the DockerComposeTarget depends on all
// the deployed image targets
func assembleDC(m model.Manifest, dcTarg model.DockerComposeTarget, iTargets ...model.ImageTarget) model.Manifest {
// images on which another image depends -- we assume they are base
// images, i.e. not deployed directly, and so the deploy target
// should not depend on them.
baseImages := make(map[model.TargetID]bool)
for _, iTarget := range iTargets {
for _, id := range iTarget.DependencyIDs() {
baseImages[id] = true
}
}
ids := make([]model.TargetID, 0, len(iTargets))
for _, iTarget := range iTargets {
if baseImages[iTarget.ID()] {
continue
}
ids = append(ids, iTarget.ID())
}
dc := dcTarg.WithDependencyIDs(ids)
return m.
WithImageTargets(iTargets).
WithDeployTarget(dc)
}