Skip to content

Commit

Permalink
fix: manually filter for dangling images for older dockers
Browse files Browse the repository at this point in the history
Old versions of docker do not correctly filter out dangling images with
dangling=false, so we have to do it manually.
  • Loading branch information
bloodearnest committed Aug 21, 2024
1 parent cbf8cca commit 78058a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions opensafely/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ def get_local_images():
for line in ps.stdout.splitlines():
if not line.strip():
continue
# dangling=false does not work on older versions of docker, so manually do it
if "<none>" in line:
continue

line = line.replace("ghcr.io/opensafely-core/", "")

Expand Down
10 changes: 10 additions & 0 deletions tests/test_pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ def test_default_with_local_images(run, capsys):
]


def test_default_with_old_docker(run, capsys):
run.expect(["docker", "info"])
expect_local_images(run, stdout="ghcr.io/opensafely-core/r:<none>=sha")

pull.main(image="all", force=False)
out, err = capsys.readouterr()
assert err == ""
assert out.strip() == "No OpenSAFELY docker images found to update."


def test_specific_image(run, capsys):
run.expect(["docker", "info"])
expect_local_images(run)
Expand Down

0 comments on commit 78058a0

Please sign in to comment.