From 04655187cb94f2f16af16b61f044ea42a31cdb72 Mon Sep 17 00:00:00 2001 From: Daniel Rossier Date: Sat, 14 Nov 2026 15:06:54 +0100 Subject: [PATCH] spear-image: read labels from the neutral spear.* namespace build-tiered.sh writes its labels under spear.* (as push.sh already reads), but spear-image inspect/list still looked only under the old ch.heig-vd.reds.spear.* namespace, so a tiered image showed a blank profile and redistributable, and list did not show it at all. Read spear.* first and fall back to the old namespace, exactly as push.sh does, and union both in list so tiered and legacy images both appear. Update the stale build-needs-a-profile assertion to the current message. --- client/tests/test_spear_image.py | 3 ++- scripts/spear-image | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/client/tests/test_spear_image.py b/client/tests/test_spear_image.py index af5b469..4d971e4 100644 --- a/client/tests/test_spear_image.py +++ b/client/tests/test_spear_image.py @@ -59,7 +59,8 @@ def test_help_names_every_action(self): def test_build_needs_a_profile(self): result = self.run_image("build") self.assertNotEqual(result.returncode, 0) - self.assertIn("public, reds or private", result.stderr) + self.assertIn("harness, base, project", result.stderr) + self.assertIn("public, reds, private", result.stderr) def test_an_unknown_name_is_refused_not_guessed(self): result = self.run_image("erase", "engagement") diff --git a/scripts/spear-image b/scripts/spear-image index 1833401..428712b 100755 --- a/scripts/spear-image +++ b/scripts/spear-image @@ -56,7 +56,15 @@ image_of() { exists() { docker image inspect "$1" >/dev/null 2>&1; } +# Labels moved to the neutral `spear.` namespace (build-tiered.sh); read it +# first, falling back to the old one so images built before the rename still +# show their profile. + label() { + local v + v="$(docker image inspect "$1" \ + --format "{{ index .Config.Labels \"spear.$2\" }}" 2>/dev/null)" + [ -n "$v" ] && { printf '%s' "$v"; return; } docker image inspect "$1" \ --format "{{ index .Config.Labels \"$LABEL.$2\" }}" 2>/dev/null } @@ -94,9 +102,13 @@ case "$action" in list) # The label, not the repository name: an image retagged for a registry - # is still one of ours, and says which profile it is. - docker images --filter "label=$LABEL.profile" \ - --format '{{.Repository}}:{{.Tag}}\t{{.ID}}\t{{.Size}}\t{{.CreatedSince}}' | + # is still one of ours, and says which profile it is. Both namespaces: + # the tiered images carry spear.profile, the legacy ones the old one. + { docker images --filter "label=spear.profile" \ + --format '{{.Repository}}:{{.Tag}}\t{{.ID}}\t{{.Size}}\t{{.CreatedSince}}' + docker images --filter "label=$LABEL.profile" \ + --format '{{.Repository}}:{{.Tag}}\t{{.ID}}\t{{.Size}}\t{{.CreatedSince}}' + } | sort -u | while IFS=$'\t' read -r name id size created; do printf '%-40s %-11s %-9s redistributable=%-5s %s\n' "$name" \ "$(label "$id" profile)" "$size" "$(label "$id" redistributable)" \