boatyard 0.9.8.dev268__tar.gz → 0.9.9.dev270__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/PKG-INFO +1 -1
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/pyproject.toml +1 -1
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/markers.py +65 -7
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score.py +7 -29
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score_compose.py +6 -6
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score_k8s.py +4 -4
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_score_generate.py +180 -100
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/.gitattributes +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/.github/workflows/cleanup-pr-releases.yml +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/.github/workflows/integrate.yml +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/.github/workflows/merge-gate.yml +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/.github/workflows/release.yml +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/.gitignore +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/.python-version +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/AGENTS.md +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/CLAUDE.md +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/LICENSE +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/NOTICE +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/README.md +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/design/AGENTS.md +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/design/CLAUDE.md +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/design/apt-hermeticity.md +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/design/mirror-digest-retention.md +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/design/precision-attribution.md +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/design/semver-image-bundle-lines.md +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/publish.yml +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/ruff.base.toml +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/ruff.toml +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/scripts/preflight.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/__init__.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/build.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/cli.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/crane.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/lock.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/models/__init__.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/models/config_file.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/models/image.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/models/k8s_pins.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/models/lock_file.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/models/pyproject.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/models/values_file.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/models/workload.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/paths.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/publish.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/py.typed +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/resolve.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score_generate.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score_patch_templates/gpu-cuda.tpl +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score_patch_templates/gpu-pod.tpl +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score_patch_templates/gpu-rocm.tpl +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score_patch_templates/probe-adapter-healthchecks.tpl +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score_patch_templates/restart.tpl +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score_patch_templates/scale-to-zero.tpl +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/temp.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/verbs/__init__.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/verbs/build.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/verbs/bump.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/verbs/down.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/verbs/lock.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/verbs/matrix.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/verbs/mirror.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/verbs/publish.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/verbs/score.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/verbs/tree_tags.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/verbs/up.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/yaml.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/conftest.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_assembly.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_build_docker.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_bump.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_compose.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_config.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_daemon_gc.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_image_builds.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_lock.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_markers.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_matrix.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_mirror.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_provisioners.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_publish_compose.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_tree_tags.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/tests/test_values.py +0 -0
- {boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/uv.lock +0 -0
|
@@ -8,6 +8,7 @@ import yaml
|
|
|
8
8
|
from pydantic import BaseModel, ConfigDict
|
|
9
9
|
|
|
10
10
|
from boatyard.models.image import Image, dockerfile_stem, require_dockerfile_spelling
|
|
11
|
+
from boatyard.models.workload import LoadedWorkload
|
|
11
12
|
from boatyard.yaml import Yaml, is_list, is_mapping, parse_yaml_text
|
|
12
13
|
|
|
13
14
|
TEXT_MARKER = "include"
|
|
@@ -16,6 +17,9 @@ LOCK_MARKER = "lock"
|
|
|
16
17
|
LOCK_IMAGE_MARKER = "lock-image"
|
|
17
18
|
LOCK_MARKERS = (LOCK_MARKER, LOCK_IMAGE_MARKER)
|
|
18
19
|
DOCKERFILE_MARKER = "dockerfile"
|
|
20
|
+
LISTENER_MARKER = "listener"
|
|
21
|
+
ROUTE_MARKER = "route"
|
|
22
|
+
WORKLOAD_FACT_MARKERS = (LISTENER_MARKER, ROUTE_MARKER)
|
|
19
23
|
IMAGE_FIELD = "image"
|
|
20
24
|
IMAGE_SLOT_PATTERN = re.compile(r"\$\{|{{")
|
|
21
25
|
|
|
@@ -34,6 +38,8 @@ class MarkerContext(NamedTuple):
|
|
|
34
38
|
ancestors: tuple[Path, ...] = ()
|
|
35
39
|
repository: str | None = None
|
|
36
40
|
builds: Mapping[str, Image] | None = None
|
|
41
|
+
# The rendering's workload documents keyed by file stem
|
|
42
|
+
workloads: Mapping[str, LoadedWorkload] | None = None
|
|
37
43
|
|
|
38
44
|
|
|
39
45
|
class ImageReference(NamedTuple):
|
|
@@ -52,6 +58,16 @@ def env_slot(name: str) -> str:
|
|
|
52
58
|
return f'{{{{ env "{name}" }}}}'
|
|
53
59
|
|
|
54
60
|
|
|
61
|
+
def workload_documents(workloads: list[LoadedWorkload]) -> dict[str, LoadedWorkload]:
|
|
62
|
+
documents: dict[str, LoadedWorkload] = {}
|
|
63
|
+
for workload in workloads:
|
|
64
|
+
stem = Path(workload.file_name).stem
|
|
65
|
+
if stem in documents:
|
|
66
|
+
raise ValueError(f"the workloads {documents[stem].file_name} and {workload.file_name} share one file stem")
|
|
67
|
+
documents[stem] = workload
|
|
68
|
+
return documents
|
|
69
|
+
|
|
70
|
+
|
|
55
71
|
def resolve_markers(node: Yaml, context: MarkerContext) -> Yaml:
|
|
56
72
|
# Expand includes before locks because spliced content may carry lock markers
|
|
57
73
|
return resolve_locks(expand_includes(node, context), context)
|
|
@@ -70,11 +86,11 @@ def expand_includes(node: Yaml, context: MarkerContext) -> Yaml:
|
|
|
70
86
|
# Splice in the included structure
|
|
71
87
|
case [(marker, value)] if marker == YAML_MARKER:
|
|
72
88
|
expanded = include_yaml(value, context)
|
|
73
|
-
# Leave markers whole for the lock pass to consume or refuse
|
|
74
|
-
# takes a mapping value, non-string
|
|
75
|
-
case [(marker, value)] if (
|
|
76
|
-
|
|
77
|
-
):
|
|
89
|
+
# Leave markers whole for the lock pass to consume or refuse. Only lock-image
|
|
90
|
+
# takes a mapping value, and a non-string route value spells a service claim
|
|
91
|
+
case [(marker, value)] if (
|
|
92
|
+
marker in LOCK_MARKERS or marker == DOCKERFILE_MARKER or marker in WORKLOAD_FACT_MARKERS
|
|
93
|
+
) and (isinstance(value, str) or marker == LOCK_IMAGE_MARKER):
|
|
78
94
|
expanded = node
|
|
79
95
|
# Resolve plain mappings child by child
|
|
80
96
|
case entries:
|
|
@@ -145,8 +161,14 @@ def resolve_locks(node: Yaml, context: MarkerContext) -> Yaml:
|
|
|
145
161
|
# Compose the built-image reference from the declared dockerfile
|
|
146
162
|
case [(marker, value)] if marker == DOCKERFILE_MARKER and isinstance(value, str):
|
|
147
163
|
resolved = dockerfile_reference(value, context)
|
|
148
|
-
#
|
|
149
|
-
|
|
164
|
+
# Spell the referenced listener as its workload's port
|
|
165
|
+
case [(marker, value)] if marker == LISTENER_MARKER and isinstance(value, str):
|
|
166
|
+
resolved = listener_port(value, context)
|
|
167
|
+
# Spell the referenced workload's route claim as its concrete path
|
|
168
|
+
case [(marker, value)] if marker == ROUTE_MARKER and isinstance(value, str):
|
|
169
|
+
resolved = route_path(value, context)
|
|
170
|
+
# Refuse literal images and resolve plain mappings child by child. A non-string
|
|
171
|
+
# value here is workload grammar or a service claim, never a marker
|
|
150
172
|
case entries:
|
|
151
173
|
_check_literal_image(node, context.source)
|
|
152
174
|
resolved = {key: resolve_locks(child, context) for key, child in entries}
|
|
@@ -178,6 +200,42 @@ def dockerfile_reference(value: str, context: MarkerContext) -> str:
|
|
|
178
200
|
return compose_image_reference(context.repository, image, env_slot(image.sha_env), variant)
|
|
179
201
|
|
|
180
202
|
|
|
203
|
+
def listener_port(value: str, context: MarkerContext) -> str:
|
|
204
|
+
# Split at the first dot because listener names may carry dots and file stems never do
|
|
205
|
+
workload_name, separator, listener_name = value.partition(".")
|
|
206
|
+
if not separator:
|
|
207
|
+
raise ValueError(f"{context.source}: listener {value!r} must spell <workload>.<listener-name>")
|
|
208
|
+
workload = referenced_workload(workload_name, LISTENER_MARKER, value, context)
|
|
209
|
+
listeners = workload.document.listeners
|
|
210
|
+
if listener_name not in listeners:
|
|
211
|
+
raise ValueError(
|
|
212
|
+
f"{context.source}: listener {value!r} names no declared listener ({', '.join(sorted(listeners))})"
|
|
213
|
+
)
|
|
214
|
+
spec = listeners[listener_name]
|
|
215
|
+
if not isinstance(spec, int) and spec.internal:
|
|
216
|
+
raise ValueError(f"{context.source}: listener {value!r} is internal and never rides the service surface")
|
|
217
|
+
port = spec if isinstance(spec, int) else spec.port
|
|
218
|
+
return str(port)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def route_path(value: str, context: MarkerContext) -> str:
|
|
222
|
+
workload = referenced_workload(value, ROUTE_MARKER, value, context)
|
|
223
|
+
resolved = workload.document.resolved_route
|
|
224
|
+
if resolved is None:
|
|
225
|
+
raise ValueError(f"{context.source}: route {value!r} names a workload that declares no route claim")
|
|
226
|
+
# Drop the wildcard tail so the value spells the concrete path the route path exports carry
|
|
227
|
+
return resolved.path.removesuffix("/*")
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def referenced_workload(name: str, marker: str, reference: str, context: MarkerContext) -> LoadedWorkload:
|
|
231
|
+
if context.workloads is None:
|
|
232
|
+
raise ValueError(f"{context.source}: {marker} markers resolve against the rendering's workload documents")
|
|
233
|
+
workload = context.workloads.get(name)
|
|
234
|
+
if workload is None:
|
|
235
|
+
raise ValueError(f"{context.source}: {marker} {reference!r} names no workload document")
|
|
236
|
+
return workload
|
|
237
|
+
|
|
238
|
+
|
|
181
239
|
def declared_dockerfile_paths(node: Yaml) -> list[str]:
|
|
182
240
|
if is_list(node):
|
|
183
241
|
return [path for item in node for path in declared_dockerfile_paths(item)]
|
|
@@ -110,8 +110,8 @@ def render_score(
|
|
|
110
110
|
config: ConfigFile,
|
|
111
111
|
substrate: Substrate,
|
|
112
112
|
workloads: list[LoadedWorkload],
|
|
113
|
+
documents: dict[str, LoadedWorkload],
|
|
113
114
|
route_exports: dict[str, str],
|
|
114
|
-
listener_exports: dict[str, str],
|
|
115
115
|
variable_values: dict[str, str],
|
|
116
116
|
images: dict[str, str],
|
|
117
117
|
templates: list[str],
|
|
@@ -126,16 +126,11 @@ def render_score(
|
|
|
126
126
|
project_name = None if substrate == "k8s" else config.project_name
|
|
127
127
|
output.parent.mkdir(parents=True, exist_ok=True)
|
|
128
128
|
|
|
129
|
-
# The lock images join as bindings underneath the caller's values
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
raise ValueError(f"the {family} export {collisions[0]} collides with an authored rendering value")
|
|
135
|
-
crossed = sorted(set(route_exports) & set(listener_exports))
|
|
136
|
-
if crossed:
|
|
137
|
-
raise ValueError(f"the route path export {crossed[0]} collides with the listener port export {crossed[0]}")
|
|
138
|
-
variable_values = {**images, **variable_values, **route_exports, **listener_exports}
|
|
129
|
+
# The lock images join as bindings underneath the caller's values
|
|
130
|
+
collisions = sorted(set(route_exports) & ({*images, *variable_values}))
|
|
131
|
+
if collisions:
|
|
132
|
+
raise ValueError(f"the route path export {collisions[0]} collides with an authored rendering value")
|
|
133
|
+
variable_values = {**images, **variable_values, **route_exports}
|
|
139
134
|
|
|
140
135
|
with (
|
|
141
136
|
as_file(files("boatyard") / PATCH_TEMPLATES_DIR) as builtin_templates,
|
|
@@ -154,6 +149,7 @@ def render_score(
|
|
|
154
149
|
source=name,
|
|
155
150
|
repository=config.repository,
|
|
156
151
|
builds=config.images,
|
|
152
|
+
workloads=documents,
|
|
157
153
|
)
|
|
158
154
|
compiled_entries: list[Yaml] = []
|
|
159
155
|
for entry in entries:
|
|
@@ -240,24 +236,6 @@ def route_path_exports(workloads: list[LoadedWorkload]) -> dict[str, str]:
|
|
|
240
236
|
return exports
|
|
241
237
|
|
|
242
238
|
|
|
243
|
-
def listener_port_exports(workloads: list[LoadedWorkload]) -> dict[str, str]:
|
|
244
|
-
# One <WORKLOAD>_LISTENER_<NAME> export per non-internal listener, riding the same tool
|
|
245
|
-
# env the route path exports ride; internal listeners never ride the service surface
|
|
246
|
-
exports: dict[str, str] = {}
|
|
247
|
-
owners: dict[str, str] = {}
|
|
248
|
-
for workload in workloads:
|
|
249
|
-
prefix = Path(workload.file_name).stem.upper().replace("-", "_") + "_LISTENER_"
|
|
250
|
-
for listener_name, port in workload.document.routable_listener_ports.items():
|
|
251
|
-
name = prefix + listener_name.upper().replace("-", "_")
|
|
252
|
-
if name in exports:
|
|
253
|
-
raise ValueError(
|
|
254
|
-
f"the workloads {owners[name]} and {workload.file_name} spell one listener port export {name}"
|
|
255
|
-
)
|
|
256
|
-
exports[name] = str(port)
|
|
257
|
-
owners[name] = workload.file_name
|
|
258
|
-
return exports
|
|
259
|
-
|
|
260
|
-
|
|
261
239
|
def translate_service_claims(entry: Yaml, source: str) -> Yaml:
|
|
262
240
|
# A provisioner service stanza authors route:/port: keys; score-compose silently drops
|
|
263
241
|
# unknown service keys, so the compile pass pops them and spells the same claim and port
|
|
@@ -13,6 +13,7 @@ from pydantic import (
|
|
|
13
13
|
model_validator,
|
|
14
14
|
)
|
|
15
15
|
|
|
16
|
+
from boatyard.markers import workload_documents
|
|
16
17
|
from boatyard.models.config_file import (
|
|
17
18
|
BARRIER_IMAGE_SLOT,
|
|
18
19
|
BARRIER_SERVICE,
|
|
@@ -31,7 +32,6 @@ from boatyard.paths import VALUES_FILE
|
|
|
31
32
|
from boatyard.yaml import Yaml, load_yaml_model
|
|
32
33
|
from boatyard.score import (
|
|
33
34
|
dump_yaml,
|
|
34
|
-
listener_port_exports,
|
|
35
35
|
render_score,
|
|
36
36
|
route_path_exports,
|
|
37
37
|
write_file,
|
|
@@ -162,11 +162,11 @@ def generate_compose(config: ConfigFile, lock: LockFile) -> list[Path]:
|
|
|
162
162
|
f"{workload.file_name}: a {probe} httpGet requires {PROBE_ADAPTER_ANNOTATION} "
|
|
163
163
|
"(the compose rendering)"
|
|
164
164
|
)
|
|
165
|
-
# Route path
|
|
166
|
-
#
|
|
167
|
-
#
|
|
165
|
+
# Route path exports are assembly-wide facts, not per-entry: a provisioner in
|
|
166
|
+
# one bundle templates a claim authored in another (grafana's OAuth URLs spell
|
|
167
|
+
# keycloak's claim path), so every rendering's env carries every claim.
|
|
168
168
|
route_exports = route_path_exports(list(config.workloads.values()))
|
|
169
|
-
|
|
169
|
+
documents = workload_documents(list(config.workloads.values()))
|
|
170
170
|
outputs: list[Path] = []
|
|
171
171
|
for name, entry in config.local_service_entries():
|
|
172
172
|
workloads = [config.workloads[workload_name] for workload_name in entry.workloads]
|
|
@@ -181,8 +181,8 @@ def generate_compose(config: ConfigFile, lock: LockFile) -> list[Path]:
|
|
|
181
181
|
config,
|
|
182
182
|
substrate="compose",
|
|
183
183
|
workloads=workloads,
|
|
184
|
+
documents=documents,
|
|
184
185
|
route_exports=route_exports,
|
|
185
|
-
listener_exports=listener_exports,
|
|
186
186
|
variable_values={**sentinels, **entry.vars},
|
|
187
187
|
templates=[
|
|
188
188
|
HEALTHCHECK_TEMPLATE,
|
|
@@ -22,12 +22,11 @@ from boatyard.models.image import dockerfile_stem
|
|
|
22
22
|
from boatyard.models.k8s_pins import load_pins
|
|
23
23
|
from boatyard.models.lock_file import LockFile
|
|
24
24
|
from boatyard.models.workload import select_provisioner_files
|
|
25
|
-
from boatyard.markers import MarkerContext, resolve_markers, declared_dockerfile_paths
|
|
25
|
+
from boatyard.markers import MarkerContext, resolve_markers, declared_dockerfile_paths, workload_documents
|
|
26
26
|
from boatyard.paths import K8S_PINS_PATH
|
|
27
27
|
from boatyard.yaml import Yaml, is_list, is_mapping, parse_yaml_text
|
|
28
28
|
from boatyard.score import (
|
|
29
29
|
dump_yaml,
|
|
30
|
-
listener_port_exports,
|
|
31
30
|
render_score,
|
|
32
31
|
route_path_exports,
|
|
33
32
|
split_documents,
|
|
@@ -81,13 +80,14 @@ def generate_k8s(
|
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
output_path = config.root / (config.k8s_local_output if local else config.k8s_output)
|
|
83
|
+
documents = workload_documents(list(config.workloads.values()))
|
|
84
84
|
|
|
85
85
|
render_score(
|
|
86
86
|
config,
|
|
87
87
|
substrate="k8s",
|
|
88
88
|
workloads=workloads,
|
|
89
|
+
documents=documents,
|
|
89
90
|
route_exports=route_path_exports(list(config.workloads.values())),
|
|
90
|
-
listener_exports=listener_port_exports(list(config.workloads.values())),
|
|
91
91
|
variable_values={
|
|
92
92
|
STORAGE_CLASS_VAR: LOCAL_STORAGE_CLASS if local else CLOUD_STORAGE_CLASS,
|
|
93
93
|
**k8s.vars,
|
|
@@ -116,7 +116,7 @@ def generate_k8s(
|
|
|
116
116
|
dump_yaml(
|
|
117
117
|
resolve_markers(
|
|
118
118
|
parse_yaml_text(path.read_text(encoding="utf-8"), path.as_posix()),
|
|
119
|
-
MarkerContext(config.root, index_images, path.as_posix()),
|
|
119
|
+
MarkerContext(config.root, index_images, path.as_posix(), workloads=documents),
|
|
120
120
|
)
|
|
121
121
|
),
|
|
122
122
|
)
|
|
@@ -303,6 +303,31 @@ def test_values_lock_markers_resolve_after_includes(tmp_path: Path, monkeypatch:
|
|
|
303
303
|
assert resolved["image"]["digest"] == DIGEST
|
|
304
304
|
|
|
305
305
|
|
|
306
|
+
def test_values_with_workload_fact_markers_resolve_into_the_tempdir(
|
|
307
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
308
|
+
) -> None:
|
|
309
|
+
(tmp_path / "stack" / "score").mkdir(parents=True)
|
|
310
|
+
(tmp_path / "stack" / "score" / "api.yaml").write_text(
|
|
311
|
+
"metadata:\n"
|
|
312
|
+
" name: api\n"
|
|
313
|
+
"boatyard:\n"
|
|
314
|
+
" route:\n"
|
|
315
|
+
" path: /auth/*\n"
|
|
316
|
+
" port: web\n"
|
|
317
|
+
"listeners:\n"
|
|
318
|
+
" web: 8081\n"
|
|
319
|
+
"containers: {}\n",
|
|
320
|
+
encoding="utf-8",
|
|
321
|
+
)
|
|
322
|
+
_write_values(tmp_path, "auth:\n port: {listener: api.web}\n path: {route: api}\n")
|
|
323
|
+
config = _generated_config(tmp_path, ["api.yaml"], k8s={"workloads": ["api.yaml"], "charts": {"loki": CHART_REF}})
|
|
324
|
+
|
|
325
|
+
helm = _generate_with_chart(monkeypatch, tmp_path, config, LOCK_IMAGES)
|
|
326
|
+
|
|
327
|
+
resolved = yaml.safe_load(helm.values_contents[0])
|
|
328
|
+
assert resolved["auth"] == {"port": "8081", "path": "/auth"}
|
|
329
|
+
|
|
330
|
+
|
|
306
331
|
def _offline_tool_ensure(monkeypatch: pytest.MonkeyPatch, on_path: str | None, version_output: str = "") -> list[str]:
|
|
307
332
|
commands: list[str] = []
|
|
308
333
|
|
|
@@ -1282,104 +1307,6 @@ def test_the_expanded_workload_copy_derives_service_ports_from_the_listeners(
|
|
|
1282
1307
|
assert "boatyard" not in document
|
|
1283
1308
|
|
|
1284
1309
|
|
|
1285
|
-
LISTENER_INVENTORY_WORKLOAD = (
|
|
1286
|
-
"metadata:\n"
|
|
1287
|
-
" name: api\n"
|
|
1288
|
-
"boatyard:\n"
|
|
1289
|
-
" lock:\n"
|
|
1290
|
-
" api: API_IMAGE\n"
|
|
1291
|
-
"listeners:\n"
|
|
1292
|
-
" web: 8081\n"
|
|
1293
|
-
" sidecar-admin: 9090\n"
|
|
1294
|
-
" debug:\n"
|
|
1295
|
-
" port: 8082\n"
|
|
1296
|
-
" internal: true\n"
|
|
1297
|
-
"containers:\n"
|
|
1298
|
-
" api: {}\n"
|
|
1299
|
-
)
|
|
1300
|
-
|
|
1301
|
-
LISTENER_INVENTORY_GENERATED = "services:\n api-api:\n image: ghcr.io/org/api:1\n"
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
def _generate_listening_workload(
|
|
1305
|
-
monkeypatch: pytest.MonkeyPatch,
|
|
1306
|
-
tmp_path: Path,
|
|
1307
|
-
entry_vars: dict[str, str] | None = None,
|
|
1308
|
-
) -> WorkloadContentsRecorder:
|
|
1309
|
-
(tmp_path / "stack" / "score").mkdir(parents=True, exist_ok=True)
|
|
1310
|
-
(tmp_path / "stack" / "score" / "api.yaml").write_text(LISTENER_INVENTORY_WORKLOAD, encoding="utf-8")
|
|
1311
|
-
recorder = WorkloadContentsRecorder(LISTENER_INVENTORY_GENERATED)
|
|
1312
|
-
monkeypatch.setattr(score_module, "bash", recorder.run)
|
|
1313
|
-
entry: dict[str, object] = {"workloads": ["api.yaml"]}
|
|
1314
|
-
if entry_vars is not None:
|
|
1315
|
-
entry["vars"] = entry_vars
|
|
1316
|
-
config = _generated_config(
|
|
1317
|
-
tmp_path,
|
|
1318
|
-
["api.yaml"],
|
|
1319
|
-
repository="ghcr.io/org/repo",
|
|
1320
|
-
project_name="example",
|
|
1321
|
-
platforms=["linux/amd64"],
|
|
1322
|
-
services={"core": {"options": {"main": entry}}},
|
|
1323
|
-
)
|
|
1324
|
-
score_compose_module.generate_compose(
|
|
1325
|
-
config,
|
|
1326
|
-
_lock_for_images({"API_IMAGE": "ghcr.io/org/api:1@" + DIGEST, **ALPINE_LOCK}),
|
|
1327
|
-
)
|
|
1328
|
-
return recorder
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
def test_the_listener_port_exports_ride_the_tool_environment(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
1332
|
-
recorder = _generate_listening_workload(monkeypatch, tmp_path)
|
|
1333
|
-
|
|
1334
|
-
generate_env = recorder.command_envs["score-compose generate"]
|
|
1335
|
-
assert generate_env is not None
|
|
1336
|
-
assert generate_env["API_LISTENER_WEB"] == "8081"
|
|
1337
|
-
assert generate_env["API_LISTENER_SIDECAR_ADMIN"] == "9090"
|
|
1338
|
-
assert recorder.command_envs["score-compose init"] == generate_env
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
def test_an_internal_listener_spells_no_export(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
1342
|
-
recorder = _generate_listening_workload(monkeypatch, tmp_path)
|
|
1343
|
-
|
|
1344
|
-
generate_env = recorder.command_envs["score-compose generate"]
|
|
1345
|
-
assert generate_env is not None
|
|
1346
|
-
assert "API_LISTENER_DEBUG" not in generate_env
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
def test_two_listening_workloads_spelling_one_export_refuse(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
1350
|
-
(tmp_path / "stack" / "score").mkdir(parents=True)
|
|
1351
|
-
for name in ("api", "API"):
|
|
1352
|
-
(tmp_path / "stack" / "score" / f"{name}.yaml").write_text(
|
|
1353
|
-
LISTENER_INVENTORY_WORKLOAD.replace(" name: api\n", f" name: {name}\n"),
|
|
1354
|
-
encoding="utf-8",
|
|
1355
|
-
)
|
|
1356
|
-
recorder = WorkloadContentsRecorder("services: {}\n")
|
|
1357
|
-
monkeypatch.setattr(score_module, "bash", recorder.run)
|
|
1358
|
-
config = _generated_config(
|
|
1359
|
-
tmp_path,
|
|
1360
|
-
["API.yaml", "api.yaml"],
|
|
1361
|
-
repository="ghcr.io/org/repo",
|
|
1362
|
-
project_name="example",
|
|
1363
|
-
platforms=["linux/amd64"],
|
|
1364
|
-
services={"core": {"options": {"main": {"workloads": ["API.yaml", "api.yaml"]}}}},
|
|
1365
|
-
)
|
|
1366
|
-
|
|
1367
|
-
with pytest.raises(ValueError, match=r"API\.yaml and api\.yaml spell one listener port export API_LISTENER_WEB"):
|
|
1368
|
-
score_compose_module.generate_compose(
|
|
1369
|
-
config,
|
|
1370
|
-
_lock_for_images({"API_IMAGE": "ghcr.io/org/api:1@" + DIGEST, **ALPINE_LOCK}),
|
|
1371
|
-
)
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
def test_a_listener_port_export_colliding_with_an_authored_value_refuses(
|
|
1375
|
-
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
1376
|
-
) -> None:
|
|
1377
|
-
with pytest.raises(
|
|
1378
|
-
ValueError, match=r"the listener port export API_LISTENER_WEB collides with an authored rendering value"
|
|
1379
|
-
):
|
|
1380
|
-
_generate_listening_workload(monkeypatch, tmp_path, entry_vars={"API_LISTENER_WEB": "7000"})
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
1310
|
RICH_SEAM_WORKLOAD = """\
|
|
1384
1311
|
apiVersion: score.dev/v1b1
|
|
1385
1312
|
metadata:
|
|
@@ -1526,10 +1453,10 @@ def test_provisioner_claims_translate_into_labels_under_the_string_form(
|
|
|
1526
1453
|
|
|
1527
1454
|
|
|
1528
1455
|
def _invoke_claiming_provisioner(
|
|
1529
|
-
monkeypatch: pytest.MonkeyPatch, tmp_path: Path, provisioner: str
|
|
1456
|
+
monkeypatch: pytest.MonkeyPatch, tmp_path: Path, provisioner: str, workload: str | None = None
|
|
1530
1457
|
) -> CompiledProvisionersRecorder:
|
|
1531
1458
|
sources = {
|
|
1532
|
-
"stack/score/api.yaml": _workload_referencing("config", "api"),
|
|
1459
|
+
"stack/score/api.yaml": _workload_referencing("config", "api") if workload is None else workload,
|
|
1533
1460
|
"stack/score/compose/config.yaml": provisioner,
|
|
1534
1461
|
}
|
|
1535
1462
|
for relative, text in sources.items():
|
|
@@ -1758,6 +1685,159 @@ def test_a_templated_provisioner_route_port_refuses_a_missing_state_key(
|
|
|
1758
1685
|
)
|
|
1759
1686
|
|
|
1760
1687
|
|
|
1688
|
+
FACT_BEARING_WORKLOAD = (
|
|
1689
|
+
"metadata:\n"
|
|
1690
|
+
" name: api\n"
|
|
1691
|
+
"resources:\n"
|
|
1692
|
+
" config:\n"
|
|
1693
|
+
" type: example-config\n"
|
|
1694
|
+
"boatyard:\n"
|
|
1695
|
+
" route:\n"
|
|
1696
|
+
" path: /auth/*\n"
|
|
1697
|
+
" port: web\n"
|
|
1698
|
+
"listeners:\n"
|
|
1699
|
+
" web: 8081\n"
|
|
1700
|
+
" sidecar.admin: 9090\n"
|
|
1701
|
+
" debug:\n"
|
|
1702
|
+
" port: 8082\n"
|
|
1703
|
+
" internal: true\n"
|
|
1704
|
+
"containers: {}\n"
|
|
1705
|
+
)
|
|
1706
|
+
|
|
1707
|
+
PROVISIONER_WITH_FACT_MARKERS = """
|
|
1708
|
+
- uri: template://example/config
|
|
1709
|
+
type: example-config
|
|
1710
|
+
services:
|
|
1711
|
+
grafana:
|
|
1712
|
+
image: ${EXAMPLE_IMAGE:?err}
|
|
1713
|
+
route:
|
|
1714
|
+
path: /grafana/*
|
|
1715
|
+
port: 3000
|
|
1716
|
+
variables:
|
|
1717
|
+
PORT: {listener: api.sidecar.admin}
|
|
1718
|
+
AUTH_PATH: {route: api}
|
|
1719
|
+
"""
|
|
1720
|
+
|
|
1721
|
+
|
|
1722
|
+
def test_workload_fact_markers_resolve_into_the_compiled_services(
|
|
1723
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
1724
|
+
) -> None:
|
|
1725
|
+
recorder = _invoke_claiming_provisioner(monkeypatch, tmp_path, PROVISIONER_WITH_FACT_MARKERS, FACT_BEARING_WORKLOAD)
|
|
1726
|
+
|
|
1727
|
+
[document] = recorder.compiled
|
|
1728
|
+
[entry] = document
|
|
1729
|
+
assert isinstance(entry, dict)
|
|
1730
|
+
services_text = entry["services"]
|
|
1731
|
+
assert isinstance(services_text, str)
|
|
1732
|
+
grafana = yaml.safe_load(services_text)["grafana"]
|
|
1733
|
+
assert grafana["variables"] == {"PORT": "9090", "AUTH_PATH": "/auth"}
|
|
1734
|
+
assert grafana["annotations"] == {"boatyard/route-path": "/grafana/*", "boatyard/route-port": "3000"}
|
|
1735
|
+
|
|
1736
|
+
|
|
1737
|
+
def test_a_listener_marker_without_a_workload_separator_refuses(
|
|
1738
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
1739
|
+
) -> None:
|
|
1740
|
+
with pytest.raises(
|
|
1741
|
+
ValueError, match=r"compose/config\.yaml: listener 'api' must spell <workload>\.<listener-name>"
|
|
1742
|
+
):
|
|
1743
|
+
_invoke_claiming_provisioner(
|
|
1744
|
+
monkeypatch,
|
|
1745
|
+
tmp_path,
|
|
1746
|
+
"""
|
|
1747
|
+
- uri: template://example/config
|
|
1748
|
+
type: example-config
|
|
1749
|
+
outputs:
|
|
1750
|
+
port: {listener: api}
|
|
1751
|
+
""",
|
|
1752
|
+
FACT_BEARING_WORKLOAD,
|
|
1753
|
+
)
|
|
1754
|
+
|
|
1755
|
+
|
|
1756
|
+
def test_a_listener_marker_naming_an_unknown_workload_refuses(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
1757
|
+
with pytest.raises(ValueError, match=r"compose/config\.yaml: listener 'ghost\.web' names no workload document"):
|
|
1758
|
+
_invoke_claiming_provisioner(
|
|
1759
|
+
monkeypatch,
|
|
1760
|
+
tmp_path,
|
|
1761
|
+
"""
|
|
1762
|
+
- uri: template://example/config
|
|
1763
|
+
type: example-config
|
|
1764
|
+
outputs:
|
|
1765
|
+
port: {listener: ghost.web}
|
|
1766
|
+
""",
|
|
1767
|
+
FACT_BEARING_WORKLOAD,
|
|
1768
|
+
)
|
|
1769
|
+
|
|
1770
|
+
|
|
1771
|
+
def test_a_listener_marker_naming_an_undeclared_listener_refuses(
|
|
1772
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
1773
|
+
) -> None:
|
|
1774
|
+
with pytest.raises(
|
|
1775
|
+
ValueError,
|
|
1776
|
+
match=r"compose/config\.yaml: listener 'api\.admin' names no declared listener.*debug, sidecar\.admin, web",
|
|
1777
|
+
):
|
|
1778
|
+
_invoke_claiming_provisioner(
|
|
1779
|
+
monkeypatch,
|
|
1780
|
+
tmp_path,
|
|
1781
|
+
"""
|
|
1782
|
+
- uri: template://example/config
|
|
1783
|
+
type: example-config
|
|
1784
|
+
outputs:
|
|
1785
|
+
port: {listener: api.admin}
|
|
1786
|
+
""",
|
|
1787
|
+
FACT_BEARING_WORKLOAD,
|
|
1788
|
+
)
|
|
1789
|
+
|
|
1790
|
+
|
|
1791
|
+
def test_a_listener_marker_naming_an_internal_listener_refuses(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
1792
|
+
with pytest.raises(
|
|
1793
|
+
ValueError, match=r"compose/config\.yaml: listener 'api\.debug' is internal and never rides the service surface"
|
|
1794
|
+
):
|
|
1795
|
+
_invoke_claiming_provisioner(
|
|
1796
|
+
monkeypatch,
|
|
1797
|
+
tmp_path,
|
|
1798
|
+
"""
|
|
1799
|
+
- uri: template://example/config
|
|
1800
|
+
type: example-config
|
|
1801
|
+
outputs:
|
|
1802
|
+
port: {listener: api.debug}
|
|
1803
|
+
""",
|
|
1804
|
+
FACT_BEARING_WORKLOAD,
|
|
1805
|
+
)
|
|
1806
|
+
|
|
1807
|
+
|
|
1808
|
+
def test_a_route_marker_naming_an_unknown_workload_refuses(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
1809
|
+
with pytest.raises(ValueError, match=r"compose/config\.yaml: route 'ghost' names no workload document"):
|
|
1810
|
+
_invoke_claiming_provisioner(
|
|
1811
|
+
monkeypatch,
|
|
1812
|
+
tmp_path,
|
|
1813
|
+
"""
|
|
1814
|
+
- uri: template://example/config
|
|
1815
|
+
type: example-config
|
|
1816
|
+
outputs:
|
|
1817
|
+
path: {route: ghost}
|
|
1818
|
+
""",
|
|
1819
|
+
FACT_BEARING_WORKLOAD,
|
|
1820
|
+
)
|
|
1821
|
+
|
|
1822
|
+
|
|
1823
|
+
def test_a_route_marker_on_a_workload_without_a_route_claim_refuses(
|
|
1824
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
1825
|
+
) -> None:
|
|
1826
|
+
with pytest.raises(
|
|
1827
|
+
ValueError, match=r"compose/config\.yaml: route 'api' names a workload that declares no route claim"
|
|
1828
|
+
):
|
|
1829
|
+
_invoke_claiming_provisioner(
|
|
1830
|
+
monkeypatch,
|
|
1831
|
+
tmp_path,
|
|
1832
|
+
"""
|
|
1833
|
+
- uri: template://example/config
|
|
1834
|
+
type: example-config
|
|
1835
|
+
outputs:
|
|
1836
|
+
path: {route: api}
|
|
1837
|
+
""",
|
|
1838
|
+
)
|
|
1839
|
+
|
|
1840
|
+
|
|
1761
1841
|
WORKLOAD_WITH_LIVENESS = """
|
|
1762
1842
|
metadata:
|
|
1763
1843
|
name: api
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score_patch_templates/gpu-cuda.tpl
RENAMED
|
File without changes
|
{boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score_patch_templates/gpu-pod.tpl
RENAMED
|
File without changes
|
{boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score_patch_templates/gpu-rocm.tpl
RENAMED
|
File without changes
|
|
File without changes
|
{boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score_patch_templates/restart.tpl
RENAMED
|
File without changes
|
{boatyard-0.9.8.dev268 → boatyard-0.9.9.dev270}/src/boatyard/score_patch_templates/scale-to-zero.tpl
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|