Skip to content

Commit 76a5d98

Browse files
committed
support for usage of multiple versions of a specific image
1 parent 97518ce commit 76a5d98

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

compose_diff/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def diff(self, old, new):
7878

7979
@staticmethod
8080
def format_diff(old, new):
81+
if old is not None and type(old) is list:
82+
old = ', '.join(sorted(set(old)))
83+
if new is not None and type(new) is list:
84+
new = ', '.join(sorted(set(new)))
8185
if old is None:
8286
if new is None:
8387
return ''
@@ -104,7 +108,9 @@ def image_versions(data):
104108
continue
105109
image_name, tag = ComposeDiff.split_image(content['image'])
106110

107-
result[image_name] = tag
111+
if image_name not in result:
112+
result[image_name] = []
113+
result[image_name].append(tag)
108114
return result
109115

110116
@staticmethod

features/versions.feature

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,33 @@ Feature: Versions
3737
| two | 2 (1) |
3838
"""
3939

40+
Scenario: Multiple Versions for specific image
41+
Given a file named "A.yml" with:
42+
"""
43+
version: "2"
44+
services:
45+
one:
46+
image: A:1
47+
two:
48+
image: A:2
49+
"""
50+
And a file named "B.yml" with:
51+
"""
52+
version: "2"
53+
services:
54+
one:
55+
image: A:2
56+
two:
57+
image: A:3
58+
"""
59+
When I run `bin/compose_diff --versions A.yml B.yml`
60+
Then it should pass with exactly:
61+
"""
62+
| Name | Version |
63+
| - | - |
64+
| A | 2, 3 (1, 2) |
65+
"""
66+
4067
Scenario: Filter
4168
Given a file named "A.yml" with:
4269
"""

0 commit comments

Comments
 (0)