Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/tests/test_spear_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
18 changes: 15 additions & 3 deletions scripts/spear-image
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)" \
Expand Down
Loading