/
manifest_target.go
56 lines (46 loc) · 1.45 KB
/
manifest_target.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
package store
import (
"github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1"
"github.com/tilt-dev/tilt/pkg/model"
)
type ManifestTarget struct {
Manifest model.Manifest
State *ManifestState
}
func NewManifestTarget(m model.Manifest) *ManifestTarget {
return &ManifestTarget{
Manifest: m,
State: newManifestState(m),
}
}
func (t ManifestTarget) Spec() model.TargetSpec {
return t.Manifest
}
func (t ManifestTarget) Status() model.TargetStatus {
return t.State
}
func (mt *ManifestTarget) UpdateStatus() v1alpha1.UpdateStatus {
m := mt.Manifest
us := mt.State.UpdateStatus(m.TriggerMode)
if us == v1alpha1.UpdateStatusPending {
// A resource with no update command can still be in pending mode.
return us
}
if m.IsLocal() && m.LocalTarget().UpdateCmd.Empty() {
// NOTE(nick): We currently model a local_resource(serve_cmd) as a Manifest
// with a no-op Update. BuildController treats it like any other
// resource. When the build completes, the server controller starts the
// server.
//
// We want to make sure that the UpdateStatus is still "Pending" until we
// have a completed build record. Otherwise the server controller will try
// to start the server twice (once while the update is in-progress, and once
// when the update completes).
if us == v1alpha1.UpdateStatusInProgress {
return v1alpha1.UpdateStatusPending
}
return v1alpha1.UpdateStatusNotApplicable
}
return us
}
var _ model.Target = &ManifestTarget{}