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