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)" \