1#!/bin/bash -e
2
3# Removes docker images created by 'build-unit-test-docker' which are older
4# than the current week.
5#   - Images start with 'openbmc/ubuntu-unit-test'.
6#   - Image tags contain YYYY-Www where:
7#       * YYYY is the 4 digit year. (date format %Y)
8#       * W is the literal 'W'
9#       * ww is the two digit ISO week. (date format %V)
10
11docker image ls \
12    "openbmc/ubuntu-unit-test*" \
13    --format "{{.Repository}}:{{.Tag}}" |
14grep -v "$(date '+%Y-W%V')" | xargs -r docker image rm || true
15