boatyard 0.7.3.dev211__tar.gz → 0.8.0__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.7.3.dev211 → boatyard-0.8.0}/AGENTS.md +13 -8
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/PKG-INFO +1 -1
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/design/AGENTS.md +0 -3
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/design/precision-attribution.md +2 -2
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/publish.yml +1 -1
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/pyproject.toml +1 -1
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/build.py +1 -1
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/compose.py +7 -3
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/lock.py +157 -31
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/models/config_file.py +83 -81
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/models/image.py +11 -14
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/models/lock_file.py +14 -2
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/models/values_file.py +43 -35
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/models/workload.py +101 -6
- boatyard-0.8.0/src/boatyard/resolve.py +407 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/score_compose.py +8 -26
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/score_patch_templates/gpu-cuda.tpl +2 -2
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/score_patch_templates/gpu-pod.tpl +3 -3
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/score_patch_templates/gpu-rocm.tpl +2 -2
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/score_patch_templates/probe-adapter-healthchecks.tpl +2 -2
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/score_patch_templates/restart.tpl +2 -2
- boatyard-0.8.0/src/boatyard/verbs/down.py +42 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/verbs/lock.py +1 -1
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/verbs/mirror.py +2 -2
- boatyard-0.8.0/src/boatyard/verbs/up.py +335 -0
- boatyard-0.8.0/tests/test_assembly.py +822 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_build_docker.py +3 -1
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_bump.py +2 -2
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_compose.py +405 -362
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_config.py +107 -80
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_image_builds.py +2 -9
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_lock.py +149 -38
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_matrix.py +1 -1
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_mirror.py +16 -15
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_publish_compose.py +7 -2
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_score_generate.py +59 -76
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_tree_tags.py +1 -1
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_values.py +184 -47
- boatyard-0.8.0/uv.lock +467 -0
- boatyard-0.7.3.dev211/closeout.md +0 -1338
- boatyard-0.7.3.dev211/design/adoption-semver-wave.md +0 -31
- boatyard-0.7.3.dev211/design/dev-overlay.md +0 -17
- boatyard-0.7.3.dev211/design/gpu-template-collapse.md +0 -21
- boatyard-0.7.3.dev211/design/hack-cross-bundle-dns.md +0 -67
- boatyard-0.7.3.dev211/src/boatyard/resolve.py +0 -269
- boatyard-0.7.3.dev211/src/boatyard/verbs/down.py +0 -39
- boatyard-0.7.3.dev211/src/boatyard/verbs/up.py +0 -202
- boatyard-0.7.3.dev211/tests/test_assembly.py +0 -297
- boatyard-0.7.3.dev211/uv.lock +0 -463
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/.gitattributes +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/.github/workflows/cleanup-pr-releases.yml +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/.github/workflows/integrate.yml +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/.github/workflows/merge-gate.yml +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/.github/workflows/release.yml +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/.gitignore +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/.python-version +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/CLAUDE.md +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/LICENSE +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/NOTICE +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/README.md +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/design/CLAUDE.md +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/design/apt-hermeticity.md +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/design/mirror-digest-retention.md +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/design/semver-image-bundle-lines.md +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/ruff.base.toml +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/ruff.toml +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/scripts/preflight.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/__init__.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/cli.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/crane.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/markers.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/models/__init__.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/models/k8s_pins.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/models/pyproject.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/paths.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/publish.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/py.typed +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/score.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/score_generate.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/score_k8s.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/score_patch_templates/scale-to-zero.tpl +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/temp.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/verbs/__init__.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/verbs/build.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/verbs/bump.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/verbs/matrix.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/verbs/publish.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/verbs/score.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/verbs/tree_tags.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/src/boatyard/yaml.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/conftest.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_daemon_gc.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_markers.py +0 -0
- {boatyard-0.7.3.dev211 → boatyard-0.8.0}/tests/test_provisioners.py +0 -0
|
@@ -20,16 +20,20 @@ Design intent and silent-failure traps, one fact per bullet.
|
|
|
20
20
|
From 1.0 on, breaking changes ship with a manually bumped `major_minor`.
|
|
21
21
|
- Third-party images and charts are consumed through the org mirror namespace (upstream
|
|
22
22
|
manifests get GC'd). CI is the single writer — engineers never push, and error text never
|
|
23
|
-
teaches them to.
|
|
23
|
+
teaches them to. The one exception is boatyard's own machinery: the barrier and gateway
|
|
24
|
+
caddy pins live in boatyard's code as upstream tags, never in a consumer lock or mirror
|
|
25
|
+
(the barrier rides the global `BOATYARD_BARRIER_IMAGE` slot, minted at resolve; the
|
|
26
|
+
gateway document renders its pin literally); boatyard hosting its own mirror retires the
|
|
27
|
+
exception.
|
|
24
28
|
- Substrate split: compose renderings bake the lock's per-platform manifests (the exact bytes
|
|
25
29
|
one machine runs); k8s renderings bake the index form (kubelet resolves per node).
|
|
26
30
|
`helm template` is a renderer, never a deployer.
|
|
27
31
|
- `boatyard.values.yaml` (consumer root, gitignored) is the only machine-values source; the
|
|
28
32
|
ambient shell fills nothing. `up` requires it; `down` and score generation run without it.
|
|
29
|
-
- `down` reads
|
|
30
|
-
|
|
31
|
-
- The
|
|
32
|
-
treaty.
|
|
33
|
+
- `down` reads config only and derives every candidate project name from the config's full
|
|
34
|
+
entry set plus the bare project name, removing the shared network last.
|
|
35
|
+
- The `boatyard-gateway` service does no token validation; re-protection is a bundle-shipped
|
|
36
|
+
oauth2-proxy sidecar treaty.
|
|
33
37
|
- `$`-doubling: a literal `$` in file text placed inside a compose document (edge Caddyfile,
|
|
34
38
|
file-sourced configs, score's bind inlining) is doubled via `double_dollars` in
|
|
35
39
|
`models/config_file.py` — the one home. Text outside a compose document (k8s manifests) never
|
|
@@ -43,8 +47,8 @@ Design intent and silent-failure traps, one fact per bullet.
|
|
|
43
47
|
it (`options:`); the axis lives on the local `base_images` entry — the one spelling across
|
|
44
48
|
the Dockerfile ARG and the k8s selection, never re-described by hand.
|
|
45
49
|
- Plain score-compose silently drops `httpGet` probes; boatyard's lens makes the omission loud
|
|
46
|
-
instead via the workload's `
|
|
47
|
-
- Substrate needs live in workload files as `
|
|
50
|
+
instead via the workload's `boatyard/probe-adapter` annotation.
|
|
51
|
+
- Substrate needs live in workload files as `boatyard/*` annotations — `boatyard.yml`
|
|
48
52
|
holds no per-workload runtime fact. The shipped `score_patch_templates` are the reader; the
|
|
49
53
|
lens is `WorkloadDocument.parse(raw, file_name)`.
|
|
50
54
|
|
|
@@ -105,7 +109,8 @@ Quick loop: `uv run pytest`, `uv run ruff check`. Full gate:
|
|
|
105
109
|
- `paths.py` — consumer-repo document paths.
|
|
106
110
|
- `temp.py` — shared digest/platform/tree-tag regex spellings.
|
|
107
111
|
- `yaml.py` — strict YAML load + model load; `Yaml` and the `is_mapping`/`is_list` guards.
|
|
108
|
-
- `verbs/up.py` —
|
|
112
|
+
- `verbs/up.py` — per-bundle compose projects plus the gateway project over the shared
|
|
113
|
+
network, the override documents, the per-run dotenv, unwind on failure.
|
|
109
114
|
|
|
110
115
|
## This file
|
|
111
116
|
|
|
@@ -12,11 +12,8 @@ Active:
|
|
|
12
12
|
basis; precedes semver by construction
|
|
13
13
|
- semver-image-bundle-lines.md — per-unit image + bundle version lines
|
|
14
14
|
(toolkit + build-artifact-registry + boatyard)
|
|
15
|
-
- adoption-semver-wave.md — consumer adoption of the semver work
|
|
16
|
-
- dev-overlay.md — cross-repo dev overlay, trigger-gated on rebuild latency
|
|
17
15
|
|
|
18
16
|
Parked:
|
|
19
17
|
|
|
20
18
|
- apt-hermeticity.md — hermetic apt in image builds
|
|
21
19
|
- mirror-digest-retention.md — mirror digest retention policy
|
|
22
|
-
- gpu-template-collapse.md — open drill, operator's lead
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Precision cluster: attribution-based tree tags (boatyard)
|
|
2
2
|
|
|
3
|
-
Pre-implementation design. Prerequisite:
|
|
4
|
-
|
|
3
|
+
Pre-implementation design. Prerequisite, landed: consumers compute
|
|
4
|
+
disk-state tree tags. Precedes the semver
|
|
5
5
|
image/bundle lines by construction: that change gate compares tree tags, and
|
|
6
6
|
tags are a trustworthy change signal only once this makes them source-precise
|
|
7
7
|
— every over-inclusion is a spurious version bump.
|
|
@@ -157,7 +157,7 @@ def run_build(
|
|
|
157
157
|
services: dict[str, dict[str, dict[str, BakeValue]]] = {}
|
|
158
158
|
for image in config.images.values():
|
|
159
159
|
for target, variant in image.target_variants:
|
|
160
|
-
args: dict[str, str] = {key: f"${{{key}:-}}" for key in config.
|
|
160
|
+
args: dict[str, str] = {key: f"${{{key}:-}}" for key in config.remote_base_images}
|
|
161
161
|
args.update(image.bases)
|
|
162
162
|
axis = image.axis
|
|
163
163
|
if variant is not None and axis is not None:
|
|
@@ -7,18 +7,22 @@ from pathlib import Path
|
|
|
7
7
|
|
|
8
8
|
def compose_command(
|
|
9
9
|
root: Path,
|
|
10
|
-
|
|
10
|
+
compose_files: list[Path],
|
|
11
11
|
*arguments: str,
|
|
12
|
+
project_name: str,
|
|
12
13
|
env_file: Path | None = None,
|
|
13
14
|
slot_names: Iterable[str] = (),
|
|
14
15
|
) -> str:
|
|
15
16
|
# Spell the one docker compose invocation; the env -u scrub defeats compose's
|
|
16
17
|
# shell-beats-env-file precedence for every slot name.
|
|
17
18
|
quoted_arguments = [shlex.quote(argument) for argument in arguments]
|
|
18
|
-
files_argument = f"-f {shlex.quote(str(compose_file))}"
|
|
19
|
+
files_argument = "".join(f" -f {shlex.quote(str(compose_file))}" for compose_file in compose_files)
|
|
19
20
|
env_argument = f" --env-file {shlex.quote(str(env_file))}" if env_file is not None else ""
|
|
20
21
|
scrub = "".join(f" -u {shlex.quote(name)}" for name in sorted(set(slot_names)))
|
|
21
|
-
prefix =
|
|
22
|
+
prefix = (
|
|
23
|
+
f"docker compose -p {shlex.quote(project_name)}{files_argument} "
|
|
24
|
+
f"--project-directory {shlex.quote(str(root))}{env_argument}"
|
|
25
|
+
)
|
|
22
26
|
if scrub:
|
|
23
27
|
prefix = f"env{scrub} " + prefix
|
|
24
28
|
return " ".join([prefix, *quoted_arguments])
|
|
@@ -4,14 +4,17 @@ import base64
|
|
|
4
4
|
import json
|
|
5
5
|
import re
|
|
6
6
|
import shlex
|
|
7
|
+
from typing import NamedTuple
|
|
7
8
|
|
|
8
9
|
import yaml
|
|
9
10
|
from bashrun.bash import bash_output
|
|
10
11
|
from pydantic import BaseModel, ConfigDict, Field
|
|
11
12
|
|
|
12
13
|
from boatyard.models.config_file import (
|
|
13
|
-
|
|
14
|
+
GATEWAY_SERVICE_NAME,
|
|
14
15
|
OCI_REFERENCE_PREFIX,
|
|
16
|
+
PublishedPort,
|
|
17
|
+
Route,
|
|
15
18
|
ConfigFile,
|
|
16
19
|
artifact_slots,
|
|
17
20
|
bundle_lock_key,
|
|
@@ -27,6 +30,12 @@ from boatyard.models.lock_file import (
|
|
|
27
30
|
ConfigLockEntry,
|
|
28
31
|
refuse_local_lock_entries,
|
|
29
32
|
)
|
|
33
|
+
from boatyard.models.workload import (
|
|
34
|
+
PUBLISH_PORT_ANNOTATION,
|
|
35
|
+
ROUTE_ANNOTATION,
|
|
36
|
+
parse_publish_port_annotation,
|
|
37
|
+
parse_route_annotation,
|
|
38
|
+
)
|
|
30
39
|
from boatyard.temp import SHA256_DIGEST_REGEX
|
|
31
40
|
from boatyard.yaml import Yaml, is_list, is_mapping, load_yaml_model
|
|
32
41
|
|
|
@@ -34,7 +43,7 @@ DIGEST_TAIL_PATTERN = re.compile(rf"@{SHA256_DIGEST_REGEX}$")
|
|
|
34
43
|
COMPOSE_FILE_MEDIA_TYPE = "application/vnd.docker.compose.file+yaml"
|
|
35
44
|
|
|
36
45
|
|
|
37
|
-
# Model the OCI shapes crane answers with: index children and artifact layers
|
|
46
|
+
# Model the OCI shapes crane answers with: index children and artifact layers
|
|
38
47
|
class OciPlatform(BaseModel):
|
|
39
48
|
model_config = ConfigDict(extra="ignore")
|
|
40
49
|
|
|
@@ -65,11 +74,11 @@ class OciArtifactManifest(BaseModel):
|
|
|
65
74
|
|
|
66
75
|
@classmethod
|
|
67
76
|
def fetch_compose_texts(cls, pinned: str) -> list[str]:
|
|
68
|
-
# Read the bundle's compose files
|
|
77
|
+
# Read the bundle's compose files from the artifact's layers
|
|
69
78
|
print(f"Reading bundle content for: {pinned}")
|
|
70
79
|
artifact = cls.model_validate(json.loads(bash_output(f"crane manifest {shlex.quote(pinned)}")))
|
|
71
80
|
|
|
72
|
-
# Strip the tag
|
|
81
|
+
# Strip the tag only when no slash follows the colon
|
|
73
82
|
repository = pinned.rpartition("@")[0]
|
|
74
83
|
slash = repository.rfind("/")
|
|
75
84
|
colon = repository.rfind(":")
|
|
@@ -82,53 +91,72 @@ class OciArtifactManifest(BaseModel):
|
|
|
82
91
|
if layer.media_type == COMPOSE_FILE_MEDIA_TYPE
|
|
83
92
|
]
|
|
84
93
|
|
|
85
|
-
# Refuse a bundle that carries no compose file layer
|
|
94
|
+
# Refuse a bundle that carries no compose file layer
|
|
86
95
|
if not compose_texts:
|
|
87
96
|
raise ValueError(f"{pinned}: the compose bundle carries no compose file layer")
|
|
88
97
|
return compose_texts
|
|
89
98
|
|
|
90
99
|
|
|
100
|
+
class BundleRecords(NamedTuple):
|
|
101
|
+
services: list[str]
|
|
102
|
+
routes: list[Route]
|
|
103
|
+
ports: list[PublishedPort]
|
|
104
|
+
container_names: list[str]
|
|
105
|
+
declared_ports: dict[str, list[tuple[int, int, str]]]
|
|
106
|
+
|
|
107
|
+
|
|
91
108
|
def relock(config: ConfigFile, *, upgrade: bool = False, check: bool = False) -> LockFile:
|
|
92
|
-
# Install the pinned crane
|
|
109
|
+
# Install the pinned crane
|
|
93
110
|
install_crane()
|
|
94
111
|
prefix = config.mirror_prefix
|
|
95
|
-
|
|
112
|
+
|
|
113
|
+
# Read the committed lock schema-only
|
|
96
114
|
committed_path = config.root / LOCK_PATH
|
|
97
115
|
committed = load_yaml_model(LockFile, committed_path) if committed_path.is_file() else LockFile()
|
|
98
116
|
|
|
99
|
-
# Resolve
|
|
100
|
-
# validating declared references against it.
|
|
117
|
+
# Resolve the declared remote bundles direct
|
|
101
118
|
bundles: dict[str, ConfigLockBundle] = {}
|
|
102
119
|
for name, reference, entry in config.remote_declared_entries():
|
|
103
120
|
key = bundle_lock_key(name)
|
|
104
121
|
committed_entry = committed.bundles.get(key)
|
|
105
122
|
|
|
106
|
-
# Pin the frozen reference or resolve
|
|
123
|
+
# Pin the frozen reference or resolve a fresh digest
|
|
107
124
|
pinned = (
|
|
108
125
|
committed_entry.reference
|
|
109
126
|
if committed_entry is not None and not upgrade and committed_entry.reference.startswith(reference + "@")
|
|
110
127
|
else f"{reference}@{resolve_remote_digest(reference)}"
|
|
111
128
|
)
|
|
112
129
|
|
|
113
|
-
# Record the
|
|
130
|
+
# Record the bundle's lock entry
|
|
114
131
|
texts = OciArtifactManifest.fetch_compose_texts(pinned)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
132
|
+
refuse_unresolved_references(name, entry.routes, entry.ports, texts)
|
|
133
|
+
records = extract_bundle_records(texts)
|
|
134
|
+
if GATEWAY_SERVICE_NAME in records.services:
|
|
135
|
+
raise ValueError(f"{pinned}: the included bundle defines the reserved service {GATEWAY_SERVICE_NAME!r}")
|
|
136
|
+
bundles[key] = ConfigLockBundle(
|
|
137
|
+
reference=pinned,
|
|
138
|
+
slots=artifact_slots(texts),
|
|
139
|
+
services=records.services,
|
|
140
|
+
routes=records.routes,
|
|
141
|
+
ports=records.ports,
|
|
142
|
+
container_names=records.container_names,
|
|
143
|
+
)
|
|
119
144
|
|
|
145
|
+
# Refuse committed entries for local base_images keys
|
|
120
146
|
images: dict[str, ConfigLockEntry] = {}
|
|
121
147
|
refuse_local_lock_entries(committed, config, committed_path.as_posix())
|
|
122
|
-
|
|
148
|
+
|
|
149
|
+
# Resolve each remote base image under the mirror prefix
|
|
150
|
+
for name, reference in config.remote_base_images.items():
|
|
123
151
|
base = mirrored_ref(reference, prefix)
|
|
124
152
|
committed_entry = committed.images.get(name)
|
|
125
153
|
|
|
126
|
-
# Record a digest-pinned declaration as-is under the mirror prefix
|
|
154
|
+
# Record a digest-pinned declaration as-is under the mirror prefix
|
|
127
155
|
if DIGEST_TAIL_PATTERN.search(reference):
|
|
128
156
|
images[name] = ConfigLockEntry(index=base, platforms=dict.fromkeys(config.platforms, base))
|
|
129
157
|
continue
|
|
130
158
|
|
|
131
|
-
#
|
|
159
|
+
# If the committed pin still matches the tag and platforms, freeze it forward
|
|
132
160
|
if (
|
|
133
161
|
committed_entry is not None
|
|
134
162
|
and not upgrade
|
|
@@ -138,18 +166,18 @@ def relock(config: ConfigFile, *, upgrade: bool = False, check: bool = False) ->
|
|
|
138
166
|
images[name] = committed_entry
|
|
139
167
|
continue
|
|
140
168
|
|
|
141
|
-
# Resolve the reference into
|
|
169
|
+
# Resolve the reference into its index and child manifests
|
|
142
170
|
print(f"Resolving digests for: {reference}")
|
|
143
171
|
index_digest = resolve_remote_digest(reference)
|
|
144
172
|
children = OciIndex.model_validate(
|
|
145
173
|
json.loads(bash_output(f"crane manifest {shlex.quote(reference)}"))
|
|
146
174
|
).manifests
|
|
147
175
|
|
|
176
|
+
# If the answer is a plain manifest, it is every platform's sole manifest
|
|
148
177
|
if not children:
|
|
149
|
-
# Treat a manifest answer as every platform's sole manifest.
|
|
150
178
|
matches = {platform: [OciDescriptor(digest=index_digest)] for platform in config.platforms}
|
|
151
179
|
else:
|
|
152
|
-
# Match each
|
|
180
|
+
# Match each platform against its concrete, non-attestation children
|
|
153
181
|
matches = {
|
|
154
182
|
platform: [
|
|
155
183
|
child
|
|
@@ -160,7 +188,7 @@ def relock(config: ConfigFile, *, upgrade: bool = False, check: bool = False) ->
|
|
|
160
188
|
for platform in config.platforms
|
|
161
189
|
}
|
|
162
190
|
|
|
163
|
-
# Refuse any platform without exactly one match
|
|
191
|
+
# Refuse any platform without exactly one match
|
|
164
192
|
selected: dict[str, str] = {}
|
|
165
193
|
for platform in config.platforms:
|
|
166
194
|
if len(matches[platform]) != 1:
|
|
@@ -173,13 +201,13 @@ def relock(config: ConfigFile, *, upgrade: bool = False, check: bool = False) ->
|
|
|
173
201
|
raise ValueError(f"image pin {name}: upstream index child must carry a digest ({child!r})")
|
|
174
202
|
selected[platform] = child.digest
|
|
175
203
|
|
|
176
|
-
# Record the mirror-prefixed index and one reference per platform
|
|
204
|
+
# Record the mirror-prefixed index and one reference per platform
|
|
177
205
|
images[name] = ConfigLockEntry(
|
|
178
206
|
index=f"{base}@{index_digest}",
|
|
179
207
|
platforms={platform: f"{base}@{digest}" for platform, digest in selected.items()},
|
|
180
208
|
)
|
|
181
209
|
|
|
182
|
-
# Freeze
|
|
210
|
+
# Freeze or resolve each declared chart
|
|
183
211
|
charts: dict[str, str] = {}
|
|
184
212
|
for name, reference in config.declared_charts.items():
|
|
185
213
|
key = chart_lock_key(name)
|
|
@@ -187,29 +215,30 @@ def relock(config: ConfigFile, *, upgrade: bool = False, check: bool = False) ->
|
|
|
187
215
|
base = mirrored_ref(reference, prefix)
|
|
188
216
|
committed_entry = committed.charts.get(key)
|
|
189
217
|
|
|
190
|
-
# Record a digest-pinned declaration as-is under the mirror prefix
|
|
218
|
+
# Record a digest-pinned declaration as-is under the mirror prefix
|
|
191
219
|
if DIGEST_TAIL_PATTERN.search(reference):
|
|
192
220
|
charts[key] = base
|
|
193
221
|
continue
|
|
194
222
|
|
|
195
|
-
#
|
|
223
|
+
# If the committed pin still matches the tag, freeze it forward
|
|
196
224
|
if committed_entry is not None and not upgrade and committed_entry.startswith(base + "@"):
|
|
197
225
|
charts[key] = committed_entry
|
|
198
226
|
continue
|
|
199
227
|
|
|
200
228
|
charts[key] = f"{base}@{resolve_remote_digest(reference)}"
|
|
201
229
|
|
|
202
|
-
# Assemble the lock and render its canonical form
|
|
230
|
+
# Assemble the lock and render its canonical form
|
|
203
231
|
lock = LockFile(platforms=list(config.platforms), images=images, charts=charts, bundles=bundles)
|
|
204
232
|
document = {key: _canonical(value) for key, value in lock.model_dump(exclude_defaults=True).items()}
|
|
205
233
|
rendered = (
|
|
206
234
|
yaml.safe_dump(document, sort_keys=False, default_flow_style=False, width=10_000_000) if document else "{}\n"
|
|
207
235
|
)
|
|
208
|
-
#
|
|
236
|
+
# If not checking, write the rendered lock over the committed file
|
|
209
237
|
if not check:
|
|
210
238
|
committed_path.write_text(rendered, encoding="utf-8")
|
|
211
239
|
return lock
|
|
212
|
-
|
|
240
|
+
|
|
241
|
+
# If the committed lock is not the canonical bytes, refuse staleness
|
|
213
242
|
committed_text = committed_path.read_text(encoding="utf-8") if committed_path.is_file() else ""
|
|
214
243
|
if committed_text != rendered:
|
|
215
244
|
raise SystemExit("image lock is stale. Run 'boatyard lock' and commit the result.")
|
|
@@ -217,7 +246,7 @@ def relock(config: ConfigFile, *, upgrade: bool = False, check: bool = False) ->
|
|
|
217
246
|
|
|
218
247
|
|
|
219
248
|
def resolve_remote_digest(reference: str) -> str:
|
|
220
|
-
# Refuse crane digest output that is not one sha256 digest
|
|
249
|
+
# Refuse crane digest output that is not one sha256 digest
|
|
221
250
|
print(f"Resolving digest for: {reference}")
|
|
222
251
|
output = bash_output(f"crane digest {shlex.quote(reference)}").strip()
|
|
223
252
|
if re.fullmatch(SHA256_DIGEST_REGEX, output) is None:
|
|
@@ -225,8 +254,105 @@ def resolve_remote_digest(reference: str) -> str:
|
|
|
225
254
|
return output
|
|
226
255
|
|
|
227
256
|
|
|
257
|
+
def extract_bundle_records(texts: list[str]) -> BundleRecords:
|
|
258
|
+
# Collect every stanza before any reference is checked
|
|
259
|
+
services: list[str] = []
|
|
260
|
+
container_names: set[str] = set()
|
|
261
|
+
declared_ports: dict[str, list[tuple[int, int, str]]] = {}
|
|
262
|
+
stanzas: list[tuple[str, Yaml, dict[str, str]]] = []
|
|
263
|
+
for text in texts:
|
|
264
|
+
document = yaml.safe_load(text)
|
|
265
|
+
service_map = document.get("services") if is_mapping(document) else None
|
|
266
|
+
if not is_mapping(service_map):
|
|
267
|
+
continue
|
|
268
|
+
for service_name, stanza in service_map.items():
|
|
269
|
+
if service_name not in services:
|
|
270
|
+
services.append(service_name)
|
|
271
|
+
if not is_mapping(stanza):
|
|
272
|
+
stanzas.append((service_name, stanza, {}))
|
|
273
|
+
continue
|
|
274
|
+
if "container_name" in stanza:
|
|
275
|
+
container_names.add(service_name)
|
|
276
|
+
_collect_declared_ports(declared_ports, service_name, stanza.get("ports"))
|
|
277
|
+
stanzas.append((service_name, stanza, _stanza_annotations(stanza)))
|
|
278
|
+
|
|
279
|
+
# Read the routes and ports from the annotations
|
|
280
|
+
routes: list[Route] = []
|
|
281
|
+
ports: list[PublishedPort] = []
|
|
282
|
+
for service_name, _stanza, stanza_annotations in stanzas:
|
|
283
|
+
route_value = stanza_annotations.get(ROUTE_ANNOTATION)
|
|
284
|
+
if route_value is not None:
|
|
285
|
+
for route in parse_route_annotation(route_value):
|
|
286
|
+
upstream = route.upstream.partition(":")[0]
|
|
287
|
+
if upstream not in services:
|
|
288
|
+
raise ValueError(
|
|
289
|
+
f"{ROUTE_ANNOTATION}: the route {route.path} references the service {upstream!r}, "
|
|
290
|
+
f"which the bundle defines no stanza for"
|
|
291
|
+
)
|
|
292
|
+
routes.append(Route(path=route.path, upstream=route.upstream, strip_prefix=route.strip_prefix))
|
|
293
|
+
publish_value = stanza_annotations.get(PUBLISH_PORT_ANNOTATION)
|
|
294
|
+
if publish_value is not None:
|
|
295
|
+
ports.extend(
|
|
296
|
+
PublishedPort(
|
|
297
|
+
service=service_name,
|
|
298
|
+
published=published_port.published,
|
|
299
|
+
target=published_port.target,
|
|
300
|
+
protocol=published_port.protocol,
|
|
301
|
+
)
|
|
302
|
+
for published_port in parse_publish_port_annotation(publish_value)
|
|
303
|
+
)
|
|
304
|
+
return BundleRecords(
|
|
305
|
+
services=services,
|
|
306
|
+
routes=routes,
|
|
307
|
+
ports=ports,
|
|
308
|
+
container_names=sorted(container_names),
|
|
309
|
+
declared_ports=declared_ports,
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
def _stanza_annotations(stanza: dict[str, Yaml]) -> dict[str, str]:
|
|
314
|
+
annotations: dict[str, str] = {}
|
|
315
|
+
for key in ("annotations", "labels"):
|
|
316
|
+
value = stanza.get(key)
|
|
317
|
+
if is_mapping(value):
|
|
318
|
+
annotations.update({str(name): str(item) for name, item in value.items()})
|
|
319
|
+
return annotations
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def _collect_declared_ports(
|
|
323
|
+
declared_ports: dict[str, list[tuple[int, int, str]]], service_name: str, value: Yaml
|
|
324
|
+
) -> None:
|
|
325
|
+
if not is_list(value):
|
|
326
|
+
return
|
|
327
|
+
for entry in value:
|
|
328
|
+
record = _declared_port_record(entry)
|
|
329
|
+
if record is not None:
|
|
330
|
+
declared_ports.setdefault(service_name, []).append(record)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def _declared_port_record(entry: Yaml) -> tuple[int, int, str] | None:
|
|
334
|
+
if is_mapping(entry):
|
|
335
|
+
published = entry.get("published")
|
|
336
|
+
target = entry.get("target")
|
|
337
|
+
if isinstance(published, int) and isinstance(target, int):
|
|
338
|
+
protocol = entry.get("protocol", "tcp")
|
|
339
|
+
return (published, target, str(protocol))
|
|
340
|
+
if len(entry) == 1:
|
|
341
|
+
# Treat the short syntax as a single-pair mapping (6178:6178 parses as {6178: 6178})
|
|
342
|
+
[(short_published, short_target)] = entry.items()
|
|
343
|
+
if isinstance(short_target, int) and str(short_published).isdigit():
|
|
344
|
+
return (int(short_published), short_target, "tcp")
|
|
345
|
+
return None
|
|
346
|
+
if isinstance(entry, str):
|
|
347
|
+
ports, _separator, protocol = entry.partition("/")
|
|
348
|
+
published, port_separator, target = ports.partition(":")
|
|
349
|
+
if port_separator and published.isdigit() and target.isdigit():
|
|
350
|
+
return (int(published), int(target), protocol if protocol else "tcp")
|
|
351
|
+
return None
|
|
352
|
+
|
|
353
|
+
|
|
228
354
|
def _canonical(value: Yaml) -> Yaml:
|
|
229
|
-
# Return the value with every nested dict's keys sorted
|
|
355
|
+
# Return the value with every nested dict's keys sorted
|
|
230
356
|
if is_mapping(value):
|
|
231
357
|
return {key: _canonical(item) for key, item in sorted(value.items())}
|
|
232
358
|
if is_list(value):
|