-
Notifications
You must be signed in to change notification settings - Fork 303
/
local_target.go
81 lines (65 loc) · 1.72 KB
/
local_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package model
import (
"fmt"
"github.com/tilt-dev/tilt/internal/sliceutils"
)
type LocalTarget struct {
Name TargetName
UpdateCmd Cmd // e.g. `make proto`
ServeCmd Cmd // e.g. `python main.py`
Workdir string // directory from which the commands should be run
deps []string // a list of ABSOLUTE file paths that are dependencies of this target
ignores []Dockerignore
repos []LocalGitRepo
}
var _ TargetSpec = LocalTarget{}
func NewLocalTarget(name TargetName, updateCmd Cmd, serveCmd Cmd, deps []string, workdir string) LocalTarget {
return LocalTarget{
Name: name,
UpdateCmd: updateCmd,
Workdir: workdir,
deps: deps,
ServeCmd: serveCmd,
}
}
func (lt LocalTarget) Empty() bool {
return lt.UpdateCmd.Empty() && lt.ServeCmd.Empty()
}
func (lt LocalTarget) WithRepos(repos []LocalGitRepo) LocalTarget {
lt.repos = append(append([]LocalGitRepo{}, lt.repos...), repos...)
return lt
}
func (lt LocalTarget) WithIgnores(ignores []Dockerignore) LocalTarget {
lt.ignores = ignores
return lt
}
func (lt LocalTarget) ID() TargetID {
return TargetID{
Name: lt.Name,
Type: TargetTypeLocal,
}
}
func (lt LocalTarget) DependencyIDs() []TargetID {
return nil
}
func (lt LocalTarget) Validate() error {
if !lt.UpdateCmd.Empty() {
if lt.Workdir == "" {
return fmt.Errorf("[Validate] LocalTarget missing workdir")
}
}
return nil
}
// Implements: engine.WatchableManifest
func (lt LocalTarget) Dependencies() []string {
return sliceutils.DedupedAndSorted(lt.deps)
}
func (lt LocalTarget) LocalRepos() []LocalGitRepo {
return lt.repos
}
func (lt LocalTarget) Dockerignores() []Dockerignore {
return lt.ignores
}
func (lt LocalTarget) IgnoredLocalDirectories() []string {
return nil
}