boatyard 0.9.3.dev256__tar.gz → 0.9.4__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.
Files changed (83) hide show
  1. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/PKG-INFO +1 -1
  2. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/pyproject.toml +1 -1
  3. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/models/workload.py +68 -0
  4. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/score.py +23 -1
  5. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_score_generate.py +194 -3
  6. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/.gitattributes +0 -0
  7. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/.github/workflows/cleanup-pr-releases.yml +0 -0
  8. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/.github/workflows/integrate.yml +0 -0
  9. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/.github/workflows/merge-gate.yml +0 -0
  10. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/.github/workflows/release.yml +0 -0
  11. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/.gitignore +0 -0
  12. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/.python-version +0 -0
  13. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/AGENTS.md +0 -0
  14. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/CLAUDE.md +0 -0
  15. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/LICENSE +0 -0
  16. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/NOTICE +0 -0
  17. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/README.md +0 -0
  18. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/design/AGENTS.md +0 -0
  19. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/design/CLAUDE.md +0 -0
  20. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/design/apt-hermeticity.md +0 -0
  21. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/design/mirror-digest-retention.md +0 -0
  22. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/design/precision-attribution.md +0 -0
  23. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/design/semver-image-bundle-lines.md +0 -0
  24. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/publish.yml +0 -0
  25. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/ruff.base.toml +0 -0
  26. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/ruff.toml +0 -0
  27. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/scripts/preflight.py +0 -0
  28. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/__init__.py +0 -0
  29. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/build.py +0 -0
  30. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/cli.py +0 -0
  31. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/crane.py +0 -0
  32. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/lock.py +0 -0
  33. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/markers.py +0 -0
  34. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/models/__init__.py +0 -0
  35. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/models/config_file.py +0 -0
  36. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/models/image.py +0 -0
  37. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/models/k8s_pins.py +0 -0
  38. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/models/lock_file.py +0 -0
  39. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/models/pyproject.py +0 -0
  40. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/models/values_file.py +0 -0
  41. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/paths.py +0 -0
  42. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/publish.py +0 -0
  43. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/py.typed +0 -0
  44. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/resolve.py +0 -0
  45. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/score_compose.py +0 -0
  46. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/score_generate.py +0 -0
  47. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/score_k8s.py +0 -0
  48. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/score_patch_templates/gpu-cuda.tpl +0 -0
  49. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/score_patch_templates/gpu-pod.tpl +0 -0
  50. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/score_patch_templates/gpu-rocm.tpl +0 -0
  51. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/score_patch_templates/probe-adapter-healthchecks.tpl +0 -0
  52. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/score_patch_templates/restart.tpl +0 -0
  53. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/score_patch_templates/scale-to-zero.tpl +0 -0
  54. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/temp.py +0 -0
  55. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/verbs/__init__.py +0 -0
  56. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/verbs/build.py +0 -0
  57. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/verbs/bump.py +0 -0
  58. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/verbs/down.py +0 -0
  59. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/verbs/lock.py +0 -0
  60. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/verbs/matrix.py +0 -0
  61. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/verbs/mirror.py +0 -0
  62. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/verbs/publish.py +0 -0
  63. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/verbs/score.py +0 -0
  64. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/verbs/tree_tags.py +0 -0
  65. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/verbs/up.py +0 -0
  66. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/src/boatyard/yaml.py +0 -0
  67. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/conftest.py +0 -0
  68. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_assembly.py +0 -0
  69. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_build_docker.py +0 -0
  70. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_bump.py +0 -0
  71. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_compose.py +0 -0
  72. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_config.py +0 -0
  73. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_daemon_gc.py +0 -0
  74. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_image_builds.py +0 -0
  75. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_lock.py +0 -0
  76. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_markers.py +0 -0
  77. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_matrix.py +0 -0
  78. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_mirror.py +0 -0
  79. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_provisioners.py +0 -0
  80. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_publish_compose.py +0 -0
  81. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_tree_tags.py +0 -0
  82. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/tests/test_values.py +0 -0
  83. {boatyard-0.9.3.dev256 → boatyard-0.9.4}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: boatyard
3
- Version: 0.9.3.dev256
3
+ Version: 0.9.4
4
4
  Summary: Deploy-files definition language and compiler, plus a runtime for the compose target
5
5
  License-File: LICENSE
6
6
  License-File: NOTICE
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "boatyard"
3
- version = "0.9.3.dev256"
3
+ version = "0.9.4"
4
4
  description = "Deploy-files definition language and compiler, plus a runtime for the compose target"
5
5
  requires-python = ">=3.13"
6
6
  dependencies = [
@@ -22,6 +22,7 @@ LOCK_ANNOTATION = "boatyard/lock"
22
22
  ROUTE_ANNOTATION = "boatyard/route"
23
23
  ROUTE_PORT_ANNOTATION = "boatyard/port"
24
24
  PUBLISH_PORT_ANNOTATION = "boatyard/publish-port"
25
+ CONTAINER_PORTS_ANNOTATION = "boatyard/container-ports"
25
26
 
26
27
  ROUTE_PATH_PATTERN = re.compile(r"(?:/\*|/(?:[^/\s*]+(?:/[^/\s*]+)*)?(?:/\*)?)")
27
28
 
@@ -69,6 +70,37 @@ class WorkloadDocument(BaseModel):
69
70
  if route is not None:
70
71
  resolve_route_port(parse_route_annotation(route), self.service_ports)
71
72
 
73
+ listeners = self.listener_ports
74
+ for name, container in self.containers.items():
75
+ for probe, block in (
76
+ ("readinessProbe", container.readiness_probe),
77
+ ("livenessProbe", container.liveness_probe),
78
+ ):
79
+ if block is None or block.http_get is None:
80
+ continue
81
+ http_get = block.http_get
82
+ if not is_mapping(http_get):
83
+ raise ValueError(f"the container {name!r} {probe} httpGet must be a mapping")
84
+ if "port" not in http_get:
85
+ raise ValueError(
86
+ f"the container {name!r} {probe} httpGet declares no port; name a service.ports "
87
+ f"entry or a {CONTAINER_PORTS_ANNOTATION} listener"
88
+ )
89
+ port = http_get["port"]
90
+ match port:
91
+ case str():
92
+ if port not in listeners:
93
+ raise ValueError(
94
+ f"the container {name!r} {probe} httpGet port {port!r} names no declared "
95
+ f"listener ({', '.join(sorted(listeners))})"
96
+ )
97
+ case _:
98
+ raise ValueError(
99
+ f"the container {name!r} {probe} httpGet port {port!r}: the literal-port grammar "
100
+ f"is removed; probe ports are listener names, so name a service.ports entry or "
101
+ f"a {CONTAINER_PORTS_ANNOTATION} listener"
102
+ )
103
+
72
104
  publish_port = annotations.get(PUBLISH_PORT_ANNOTATION)
73
105
  if publish_port is not None:
74
106
  parse_publish_port_annotation(publish_port)
@@ -128,6 +160,23 @@ class WorkloadDocument(BaseModel):
128
160
  def service_ports(self) -> dict[str, int | WorkloadPortSpec]:
129
161
  return self.service.ports if self.service is not None else {}
130
162
 
163
+ @property
164
+ def listener_ports(self) -> dict[str, int]:
165
+ # The names a probe port may reference: the service.ports listen ports plus the
166
+ # deliberately-not-service listeners the container-ports annotation declares
167
+ listeners = {name: listen_port(spec) for name, spec in self.service_ports.items()}
168
+ annotation = self.metadata.annotations.get(CONTAINER_PORTS_ANNOTATION)
169
+ if annotation is None:
170
+ return listeners
171
+ declared = parse_container_ports_annotation(annotation)
172
+ collisions = sorted(listeners.keys() & declared.keys())
173
+ if collisions:
174
+ raise ValueError(
175
+ f"{CONTAINER_PORTS_ANNOTATION} names the listener {collisions[0]!r} that service.ports already declares"
176
+ )
177
+ listeners.update(declared)
178
+ return listeners
179
+
131
180
  @property
132
181
  def resolved_route(self) -> ResolvedRoute | None:
133
182
  annotation = self.metadata.annotations.get(ROUTE_ANNOTATION)
@@ -381,6 +430,25 @@ def parse_route_port_annotation(value: str) -> int:
381
430
  raise ValueError(f"{ROUTE_PORT_ANNOTATION} {value!r} must be a literal port in the range 1-65535")
382
431
 
383
432
 
433
+ def parse_container_ports_annotation(value: str) -> dict[str, int]:
434
+ if not value.strip():
435
+ raise ValueError(f"{CONTAINER_PORTS_ANNOTATION} must be a non-empty comma-separated list of name=port pairs")
436
+ ports: dict[str, int] = {}
437
+ for entry in value.split(","):
438
+ name, separator, port = entry.partition("=")
439
+ padded = name != name.strip() or port != port.strip()
440
+ if not separator or padded or not name or not port:
441
+ raise ValueError(f"{CONTAINER_PORTS_ANNOTATION} entry {entry!r} must be an unpadded name=port pair")
442
+ if not port.isdigit() or not 1 <= int(port) <= 65535:
443
+ raise ValueError(
444
+ f"{CONTAINER_PORTS_ANNOTATION} entry {entry!r} must carry a literal port in the range 1-65535"
445
+ )
446
+ if name in ports:
447
+ raise ValueError(f"{CONTAINER_PORTS_ANNOTATION} names the listener {name!r} twice")
448
+ ports[name] = int(port)
449
+ return ports
450
+
451
+
384
452
  def route_path_export_name(workload_name: str) -> str:
385
453
  return workload_name.upper().replace("-", "_") + "_" + ROUTE_PATH_EXPORT_SUFFIX
386
454
 
@@ -268,7 +268,9 @@ def claimed_service_stanza(name: str, stanza: Yaml, source: str) -> Yaml:
268
268
 
269
269
  def injected_workload(config: ConfigFile, workload: LoadedWorkload, variable_values: dict[str, str]) -> Yaml:
270
270
  # The image reference is composed from the container's declared source and injected
271
- # before score sees the document; it is never authored in the workload file.
271
+ # before score sees the document; it is never authored in the workload file. Probe
272
+ # ports ride the same pass: authored as listener names, rewritten to the resolved
273
+ # port so both renderings hand the score tools the integer.
272
274
  sources = workload.document.container_sources()
273
275
  if not sources:
274
276
  return workload.raw
@@ -310,9 +312,29 @@ def injected_workload(config: ConfigFile, workload: LoadedWorkload, variable_val
310
312
  if not is_mapping(entry):
311
313
  raise ValueError(f"{workload.file_name}: containers.{container} must be a mapping")
312
314
  entry["image"] = reference
315
+ rewrite_probe_ports(containers, workload)
313
316
  return document
314
317
 
315
318
 
319
+ def rewrite_probe_ports(containers: dict[str, Yaml], workload: LoadedWorkload) -> None:
320
+ # The lens already refused every probe port that is not a declared listener name, so
321
+ # the rewrite is a plain substitution over the validated documents
322
+ listeners = workload.document.listener_ports
323
+ for entry in containers.values():
324
+ if not is_mapping(entry):
325
+ continue
326
+ for probe in ("readinessProbe", "livenessProbe"):
327
+ block = entry.get(probe)
328
+ if not is_mapping(block):
329
+ continue
330
+ http_get = block.get("httpGet")
331
+ if not is_mapping(http_get):
332
+ continue
333
+ port = http_get.get("port")
334
+ if isinstance(port, str):
335
+ http_get["port"] = listeners[port]
336
+
337
+
316
338
  def dump_yaml(value: Yaml) -> str:
317
339
  return yaml.dump(
318
340
  value,
@@ -1387,13 +1387,14 @@ WORKLOAD_WITH_LIVENESS = """
1387
1387
  metadata:
1388
1388
  name: api
1389
1389
  annotations:
1390
+ boatyard/container-ports: health=5678
1390
1391
  boatyard/lock: api=API_IMAGE
1391
1392
  containers:
1392
1393
  api:
1393
1394
  livenessProbe:
1394
1395
  httpGet:
1395
1396
  path: /health
1396
- port: 5678
1397
+ port: health
1397
1398
  """
1398
1399
 
1399
1400
  WORKLOAD_WITH_READINESS = """
@@ -1401,26 +1402,28 @@ metadata:
1401
1402
  name: api
1402
1403
  annotations:
1403
1404
  boatyard/probe-adapter: python-urllib
1405
+ boatyard/container-ports: health=5678
1404
1406
  boatyard/lock: api=API_IMAGE
1405
1407
  containers:
1406
1408
  api:
1407
1409
  readinessProbe:
1408
1410
  httpGet:
1409
1411
  path: /ready
1410
- port: 5678
1412
+ port: health
1411
1413
  """
1412
1414
 
1413
1415
  WORKLOAD_WITH_UNADAPTED_READINESS = """
1414
1416
  metadata:
1415
1417
  name: api
1416
1418
  annotations:
1419
+ boatyard/container-ports: health=5678
1417
1420
  boatyard/lock: api=API_IMAGE
1418
1421
  containers:
1419
1422
  api:
1420
1423
  readinessProbe:
1421
1424
  httpGet:
1422
1425
  path: /ready
1423
- port: 5678
1426
+ port: health
1424
1427
  """
1425
1428
 
1426
1429
 
@@ -1460,6 +1463,194 @@ def test_unknown_probe_adapter_values_refuse(tmp_path: Path, monkeypatch: pytest
1460
1463
  _bundle_config(tmp_path)
1461
1464
 
1462
1465
 
1466
+ WORKLOAD_PROBE_BARE_SERVICE_PORT = """
1467
+ metadata:
1468
+ name: api
1469
+ annotations:
1470
+ boatyard/lock: api=API_IMAGE
1471
+ service:
1472
+ ports:
1473
+ web: 5678
1474
+ containers:
1475
+ api:
1476
+ readinessProbe:
1477
+ httpGet:
1478
+ path: /ready
1479
+ port: web
1480
+ """
1481
+
1482
+ WORKLOAD_PROBE_TARGET_SERVICE_PORT = """
1483
+ metadata:
1484
+ name: api
1485
+ annotations:
1486
+ boatyard/probe-adapter: python-urllib
1487
+ boatyard/lock: api=API_IMAGE
1488
+ service:
1489
+ ports:
1490
+ web:
1491
+ port: 80
1492
+ targetPort: 9090
1493
+ containers:
1494
+ api:
1495
+ readinessProbe:
1496
+ httpGet:
1497
+ path: /ready
1498
+ port: web
1499
+ """
1500
+
1501
+ WORKLOAD_PROBE_CONTAINER_PORT = """
1502
+ metadata:
1503
+ name: api
1504
+ annotations:
1505
+ boatyard/container-ports: mgmt=9000
1506
+ boatyard/lock: api=API_IMAGE
1507
+ containers:
1508
+ api:
1509
+ livenessProbe:
1510
+ httpGet:
1511
+ path: /health
1512
+ port: mgmt
1513
+ """
1514
+
1515
+
1516
+ def test_probe_listener_names_resolve_over_both_service_port_shapes() -> None:
1517
+ for fixture, resolved in ((WORKLOAD_PROBE_BARE_SERVICE_PORT, 5678), (WORKLOAD_PROBE_TARGET_SERVICE_PORT, 9090)):
1518
+ document = WorkloadDocument.parse(yaml.safe_load(fixture), "api.yaml")
1519
+
1520
+ assert document.listener_ports == {"web": resolved}
1521
+
1522
+
1523
+ def test_probe_listener_names_resolve_the_container_ports_annotation() -> None:
1524
+ document = WorkloadDocument.parse(yaml.safe_load(WORKLOAD_PROBE_CONTAINER_PORT), "api.yaml")
1525
+
1526
+ assert document.listener_ports == {"mgmt": 9000}
1527
+
1528
+
1529
+ def test_literal_probe_ports_refuse() -> None:
1530
+ with pytest.raises(ValidationError, match=r"probe ports are listener names"):
1531
+ WorkloadDocument.parse(
1532
+ {
1533
+ "metadata": {"name": "api", "annotations": {"boatyard/lock": "api=API_IMAGE"}},
1534
+ "service": {"ports": {"web": 5678}},
1535
+ "containers": {"api": {"livenessProbe": {"httpGet": {"path": "/health", "port": 5678}}}},
1536
+ },
1537
+ "api.yaml",
1538
+ )
1539
+
1540
+
1541
+ def test_a_probe_without_a_port_refuses() -> None:
1542
+ with pytest.raises(ValidationError, match=r"declares no port"):
1543
+ WorkloadDocument.parse(
1544
+ {
1545
+ "metadata": {"name": "api", "annotations": {"boatyard/lock": "api=API_IMAGE"}},
1546
+ "service": {"ports": {"web": 5678}},
1547
+ "containers": {"api": {"livenessProbe": {"httpGet": {"path": "/health"}}}},
1548
+ },
1549
+ "api.yaml",
1550
+ )
1551
+
1552
+
1553
+ def test_unknown_probe_listener_names_refuse_listing_the_declared_listeners() -> None:
1554
+ with pytest.raises(ValidationError, match=r"names no declared listener \(mgmt, web\)"):
1555
+ WorkloadDocument.parse(
1556
+ {
1557
+ "metadata": {
1558
+ "name": "api",
1559
+ "annotations": {"boatyard/container-ports": "mgmt=9000", "boatyard/lock": "api=API_IMAGE"},
1560
+ },
1561
+ "service": {"ports": {"web": 5678}},
1562
+ "containers": {"api": {"livenessProbe": {"httpGet": {"path": "/health", "port": "admin"}}}},
1563
+ },
1564
+ "api.yaml",
1565
+ )
1566
+
1567
+
1568
+ def test_malformed_container_ports_values_refuse() -> None:
1569
+ malformed = (
1570
+ ("", "comma-separated list of name=port pairs"),
1571
+ ("mgmt =9000", "unpadded name=port pair"),
1572
+ ("mgmt9000", "unpadded name=port pair"),
1573
+ ("mgmt=0", "range 1-65535"),
1574
+ ("mgmt=65536", "range 1-65535"),
1575
+ ("mgmt=9000,mgmt=9001", "names the listener 'mgmt' twice"),
1576
+ )
1577
+ for value, message in malformed:
1578
+ with pytest.raises(ValidationError, match=message):
1579
+ WorkloadDocument.parse(
1580
+ {
1581
+ "metadata": {"name": "api", "annotations": {"boatyard/container-ports": value}},
1582
+ "containers": {},
1583
+ },
1584
+ "api.yaml",
1585
+ )
1586
+
1587
+
1588
+ def test_a_container_ports_name_a_service_port_declares_refuses() -> None:
1589
+ with pytest.raises(ValidationError, match=r"listener 'web' that service\.ports already declares"):
1590
+ WorkloadDocument.parse(
1591
+ {
1592
+ "metadata": {
1593
+ "name": "api",
1594
+ "annotations": {"boatyard/container-ports": "web=9000", "boatyard/lock": "api=API_IMAGE"},
1595
+ },
1596
+ "service": {"ports": {"web": 5678}},
1597
+ "containers": {"api": {}},
1598
+ },
1599
+ "api.yaml",
1600
+ )
1601
+
1602
+
1603
+ def test_the_compose_rendering_receives_the_resolved_probe_port(
1604
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch
1605
+ ) -> None:
1606
+ (tmp_path / "stack" / "score").mkdir(parents=True)
1607
+ (tmp_path / "stack" / "score" / "api.yaml").write_text(WORKLOAD_PROBE_TARGET_SERVICE_PORT, encoding="utf-8")
1608
+ recorder = WorkloadContentsRecorder()
1609
+ monkeypatch.setattr(score_module, "bash", recorder.run)
1610
+ config = _generated_config(
1611
+ tmp_path,
1612
+ ["api.yaml"],
1613
+ repository="ghcr.io/org/repo",
1614
+ project_name="example",
1615
+ platforms=["linux/amd64"],
1616
+ services={"core": {"options": {"main": {"workloads": ["api.yaml"]}}}},
1617
+ )
1618
+
1619
+ score_compose_module.generate_compose(
1620
+ config,
1621
+ _lock_for_images({"API_IMAGE": "ghcr.io/org/api:1@" + DIGEST, **ALPINE_LOCK}),
1622
+ )
1623
+
1624
+ assert "port: 9090\n" in recorder.workload_contents["api.yaml"]
1625
+ assert "port: web\n" not in recorder.workload_contents["api.yaml"]
1626
+
1627
+
1628
+ WORKLOAD_PROBE_DOCKERFILE_PORT = (
1629
+ "metadata:\n"
1630
+ " name: api\n"
1631
+ " annotations:\n"
1632
+ " boatyard/dockerfile: api=workloads/api/Dockerfile\n"
1633
+ " boatyard/container-ports: mgmt=9000\n"
1634
+ "containers:\n"
1635
+ " api:\n"
1636
+ " livenessProbe:\n"
1637
+ " httpGet:\n"
1638
+ " path: /health\n"
1639
+ " port: mgmt\n"
1640
+ )
1641
+
1642
+
1643
+ def test_the_k8s_rendering_receives_the_resolved_probe_port(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
1644
+ _write_pins(tmp_path, {"API_SHA": PINNED_TAG})
1645
+ recorder = _pins_k8s_recorder(monkeypatch, tmp_path, WORKLOAD_PROBE_DOCKERFILE_PORT)
1646
+ config, k8s = _pinned_config(tmp_path)
1647
+
1648
+ generate_k8s(config, k8s, LockFile.model_validate({}), local=False)
1649
+
1650
+ assert "port: 9000\n" in recorder.workload_contents["api.yaml"]
1651
+ assert "port: mgmt\n" not in recorder.workload_contents["api.yaml"]
1652
+
1653
+
1463
1654
  def test_workload_resources_parse_typed() -> None:
1464
1655
  document = WorkloadDocument.parse(
1465
1656
  {"resources": {"db": {"type": "example-db"}}, "metadata": {"name": "api"}}, "api.yaml"
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