-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTiltfile
More file actions
78 lines (65 loc) · 2.78 KB
/
Copy pathTiltfile
File metadata and controls
78 lines (65 loc) · 2.78 KB
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
# RDK Development Orchestration
#
# Usage:
# tilt up - Start all services
# tilt down - Stop all services
load("ext://git_resource", "git_checkout")
load("ext://dotenv", "dotenv")
load("ext://color", "color")
# Load environment
if os.path.exists(".env.local"):
dotenv(fn=".env.local")
# Read service configuration
config_path = "services.yaml"
if not os.path.exists(config_path):
fail("Missing services.yaml - copy from services.yaml.template")
services = read_yaml(config_path).get("services", [])
# ------------------------------------
# Bootstrap services
# ------------------------------------
for service in services:
name = service.keys()[0]
values = service.values()[0]
# Handle metarepos - auto-discover services in {path}/services/*/Tiltfile
if values.get("metarepo", False):
base_path = values.get("path", "services/%s" % name)
repo = values.get("repo")
# Expand ~ to home directory
if base_path.startswith("~"):
base_path = base_path.replace("~", os.environ["HOME"])
# Clone if repo specified and path doesn't exist
if repo and not os.path.exists(base_path):
print(color.yellow("%s does not exist, cloning..." % base_path))
git_checkout(repo, base_path)
elif os.path.exists(base_path):
print(color.green("%s already exists" % base_path))
# Auto-discover services using shell
services_dir = "%s/services" % base_path
if os.path.exists(services_dir):
sub_services = str(local("ls %s" % services_dir, quiet=True)).strip().split("\n")
for sub_service in sub_services:
if sub_service:
sub_path = "%s/%s" % (services_dir, sub_service)
tiltfile_path = "%s/Tiltfile" % sub_path
if os.path.exists(tiltfile_path):
print(color.green(" Loading Tiltfile for %s..." % sub_service))
include(tiltfile_path)
continue
repo = values.get("repo", "")
path = values.get("path", "services/%s" % name)
# Expand ~ to home directory
if path.startswith("~"):
path = path.replace("~", os.environ["HOME"])
# Clone if repo specified and path doesn't exist
if repo and not os.path.exists(path):
print(color.yellow("%s does not exist, cloning..." % path))
git_checkout(repo, path)
elif os.path.exists(path):
print(color.green("%s already exists" % path))
# Include service Tiltfile if it exists
tiltfile_path = "%s/Tiltfile" % path
if os.path.exists(tiltfile_path):
print(color.green(" Loading Tiltfile for %s..." % name))
include(tiltfile_path)
else:
print(color.yellow("No Tiltfile found for %s at %s" % (name, tiltfile_path)))