docker-squash 1.2.0__tar.gz → 1.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {docker-squash-1.2.0/docker_squash.egg-info → docker_squash-1.2.1}/PKG-INFO +2 -2
- {docker-squash-1.2.0 → docker_squash-1.2.1}/docker_squash/image.py +3 -3
- {docker-squash-1.2.0 → docker_squash-1.2.1}/docker_squash/v2_image.py +6 -2
- docker_squash-1.2.1/docker_squash/version.py +1 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1/docker_squash.egg-info}/PKG-INFO +2 -2
- {docker-squash-1.2.0 → docker_squash-1.2.1}/tests/test_integ_squash.py +22 -38
- docker-squash-1.2.0/docker_squash/version.py +0 -1
- {docker-squash-1.2.0 → docker_squash-1.2.1}/LICENSE +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/MANIFEST.in +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/README.rst +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/docker_squash/__init__.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/docker_squash/cli.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/docker_squash/errors.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/docker_squash/lib/__init__.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/docker_squash/lib/common.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/docker_squash/squash.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/docker_squash/v1_image.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/docker_squash.egg-info/SOURCES.txt +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/docker_squash.egg-info/dependency_links.txt +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/docker_squash.egg-info/entry_points.txt +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/docker_squash.egg-info/requires.txt +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/docker_squash.egg-info/top_level.txt +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/requirements.txt +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/setup.cfg +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/setup.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/tests/test_qa.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/tests/test_unit_squash.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/tests/test_unit_v1_image.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.1}/tests/test_unit_v2_image.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: docker-squash
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.1
|
|
4
4
|
Summary: Docker layer squashing tool
|
|
5
5
|
Home-page: https://github.com/goldmann/docker-squash
|
|
6
|
-
Download-URL: https://github.com/goldmann/docker-squash/archive/1.2.
|
|
6
|
+
Download-URL: https://github.com/goldmann/docker-squash/archive/1.2.1.tar.gz
|
|
7
7
|
Author: Marek Goldmann
|
|
8
8
|
Author-email: marek.goldmann@gmail.com
|
|
9
9
|
License: MIT
|
|
@@ -220,9 +220,9 @@ class Image(object):
|
|
|
220
220
|
"Single layer marked to squash, no squashing is required"
|
|
221
221
|
)
|
|
222
222
|
|
|
223
|
-
self.log.info("Attempting to squash last
|
|
224
|
-
self.log.debug("Layers to squash:
|
|
225
|
-
self.log.debug("Layers to move:
|
|
223
|
+
self.log.info(f"Attempting to squash last {number_of_layers} layers...")
|
|
224
|
+
self.log.debug(f"Layers to squash: {self.layers_to_squash}")
|
|
225
|
+
self.log.debug(f"Layers to move: {self.layers_to_move}")
|
|
226
226
|
|
|
227
227
|
# Fetch the image and unpack it on the fly to the old image directory
|
|
228
228
|
self._save_image(self.old_image_id, self.old_image_dir)
|
|
@@ -16,6 +16,9 @@ class V2Image(Image):
|
|
|
16
16
|
def _before_squashing(self):
|
|
17
17
|
super(V2Image, self)._before_squashing()
|
|
18
18
|
|
|
19
|
+
# New OCI Archive format type
|
|
20
|
+
self.oci_format = True
|
|
21
|
+
|
|
19
22
|
# Read old image manifest file
|
|
20
23
|
self.old_image_manifest = self._get_manifest()
|
|
21
24
|
self.log.debug(
|
|
@@ -39,6 +42,9 @@ class V2Image(Image):
|
|
|
39
42
|
if self.layer_paths_to_move:
|
|
40
43
|
self.squash_id = self.layer_paths_to_move[-1]
|
|
41
44
|
|
|
45
|
+
self.log.debug(f"Layers paths to squash: {self.layer_paths_to_squash}")
|
|
46
|
+
self.log.debug(f"Layers paths to move: {self.layer_paths_to_move}")
|
|
47
|
+
|
|
42
48
|
def _squash(self):
|
|
43
49
|
if self.layer_paths_to_squash:
|
|
44
50
|
# Prepare the directory
|
|
@@ -372,8 +378,6 @@ class V2Image(Image):
|
|
|
372
378
|
|
|
373
379
|
def _get_manifest(self):
|
|
374
380
|
if os.path.exists(os.path.join(self.old_image_dir, "index.json")):
|
|
375
|
-
# New OCI Archive format type
|
|
376
|
-
self.oci_format = True
|
|
377
381
|
# Not using index.json to extract manifest details as while the config
|
|
378
382
|
# sha could be extracted via some indirection i.e.
|
|
379
383
|
#
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version = "1.2.1"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: docker-squash
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.1
|
|
4
4
|
Summary: Docker layer squashing tool
|
|
5
5
|
Home-page: https://github.com/goldmann/docker-squash
|
|
6
|
-
Download-URL: https://github.com/goldmann/docker-squash/archive/1.2.
|
|
6
|
+
Download-URL: https://github.com/goldmann/docker-squash/archive/1.2.1.tar.gz
|
|
7
7
|
Author: Marek Goldmann
|
|
8
8
|
Author-email: marek.goldmann@gmail.com
|
|
9
9
|
License: MIT
|
|
@@ -13,6 +13,7 @@ import docker.errors
|
|
|
13
13
|
import mock
|
|
14
14
|
import pytest
|
|
15
15
|
from packaging import version as packaging_version
|
|
16
|
+
from parameterized import parameterized
|
|
16
17
|
|
|
17
18
|
from docker_squash.errors import SquashError, SquashUnnecessaryError
|
|
18
19
|
from docker_squash.lib import common
|
|
@@ -37,7 +38,7 @@ class ImageHelper(object):
|
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
class IntegSquash(unittest.TestCase):
|
|
40
|
-
BUSYBOX_IMAGE = "busybox:1.
|
|
41
|
+
BUSYBOX_IMAGE = "busybox:1.36.1"
|
|
41
42
|
|
|
42
43
|
log = logging.getLogger()
|
|
43
44
|
handler = logging.StreamHandler()
|
|
@@ -698,7 +699,7 @@ class TestIntegSquash(IntegSquash):
|
|
|
698
699
|
)
|
|
699
700
|
|
|
700
701
|
with self.Image(dockerfile) as image:
|
|
701
|
-
with self.SquashedImage(image, 2) as squashed_image:
|
|
702
|
+
with self.SquashedImage(image, 2, numeric=True) as squashed_image:
|
|
702
703
|
self.assertEqual(len(squashed_image.layers), len(image.layers) - 1)
|
|
703
704
|
image_data_layers = [s for s in image.tarnames if "layer.tar" in s]
|
|
704
705
|
squashed_image_data_layers = [
|
|
@@ -735,7 +736,7 @@ class TestIntegSquash(IntegSquash):
|
|
|
735
736
|
)
|
|
736
737
|
|
|
737
738
|
with self.Image(dockerfile) as image:
|
|
738
|
-
with self.SquashedImage(image, 2) as squashed_image:
|
|
739
|
+
with self.SquashedImage(image, 2, numeric=True) as squashed_image:
|
|
739
740
|
self.assertEqual(len(squashed_image.layers), len(image.layers) - 1)
|
|
740
741
|
|
|
741
742
|
def test_should_squash_exactly_3_layers_with_data(self):
|
|
@@ -757,9 +758,9 @@ class TestIntegSquash(IntegSquash):
|
|
|
757
758
|
dockerfile = (
|
|
758
759
|
"""
|
|
759
760
|
FROM %s
|
|
760
|
-
RUN touch /abc
|
|
761
761
|
CMD /bin/env
|
|
762
762
|
LABEL foo bar
|
|
763
|
+
RUN touch /abc
|
|
763
764
|
"""
|
|
764
765
|
% TestIntegSquash.BUSYBOX_IMAGE
|
|
765
766
|
)
|
|
@@ -796,7 +797,7 @@ class TestIntegSquash(IntegSquash):
|
|
|
796
797
|
def test_remove_tmp_dir_after_failure(self):
|
|
797
798
|
self.caplog.set_level(logging.DEBUG, logger="cekit")
|
|
798
799
|
dockerfile = """
|
|
799
|
-
FROM busybox:1.
|
|
800
|
+
FROM busybox:1.36.1
|
|
800
801
|
LABEL foo bar
|
|
801
802
|
"""
|
|
802
803
|
|
|
@@ -820,7 +821,7 @@ class TestIntegSquash(IntegSquash):
|
|
|
820
821
|
|
|
821
822
|
def test_should_not_remove_tmp_dir_after_failure_if_development_mode_is_on(self):
|
|
822
823
|
dockerfile = """
|
|
823
|
-
FROM busybox:1.
|
|
824
|
+
FROM busybox:1.36.1
|
|
824
825
|
LABEL foo bar
|
|
825
826
|
"""
|
|
826
827
|
|
|
@@ -1261,7 +1262,7 @@ class NumericValues(IntegSquash):
|
|
|
1261
1262
|
@classmethod
|
|
1262
1263
|
def setUpClass(cls):
|
|
1263
1264
|
dockerfile = """
|
|
1264
|
-
FROM busybox:1.
|
|
1265
|
+
FROM busybox:1.36.1
|
|
1265
1266
|
RUN touch /tmp/test1
|
|
1266
1267
|
RUN touch /tmp/test2
|
|
1267
1268
|
CMD /bin/env
|
|
@@ -1306,41 +1307,24 @@ class NumericValues(IntegSquash):
|
|
|
1306
1307
|
with self.SquashedImage(NumericValues.image, 1, numeric=True):
|
|
1307
1308
|
pass
|
|
1308
1309
|
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1310
|
+
@parameterized.expand([(2,), (3,), (4,)])
|
|
1311
|
+
def test_should_squash_n_layers(self, number_of_layers):
|
|
1312
|
+
with self.SquashedImage(
|
|
1313
|
+
NumericValues.image, number_of_layers, numeric=True
|
|
1314
|
+
) as squashed_image:
|
|
1315
|
+
i_h = NumericValues.image.history[number_of_layers:]
|
|
1316
|
+
s_h = squashed_image.history[1:]
|
|
1313
1317
|
|
|
1314
|
-
for key in "Comment", "Size":
|
|
1315
|
-
self.assertEqual(i_h[key], s_h[key])
|
|
1316
|
-
self.assertEqual(s_h["CreatedBy"], "")
|
|
1317
1318
|
self.assertEqual(
|
|
1318
|
-
len(squashed_image.layers),
|
|
1319
|
+
len(squashed_image.layers),
|
|
1320
|
+
len(NumericValues.image.layers) - (number_of_layers - 1),
|
|
1319
1321
|
)
|
|
1320
1322
|
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
for key in "Comment", "Size":
|
|
1327
|
-
self.assertEqual(i_h[key], s_h[key])
|
|
1328
|
-
self.assertEqual(s_h["CreatedBy"], "")
|
|
1329
|
-
self.assertEqual(
|
|
1330
|
-
len(squashed_image.layers), len(NumericValues.image.layers) - 2
|
|
1331
|
-
)
|
|
1332
|
-
|
|
1333
|
-
def test_should_squash_4_layers(self):
|
|
1334
|
-
with self.SquashedImage(NumericValues.image, 4, numeric=True) as squashed_image:
|
|
1335
|
-
i_h = NumericValues.image.history[0]
|
|
1336
|
-
s_h = squashed_image.history[0]
|
|
1337
|
-
|
|
1338
|
-
for key in "Comment", "Size":
|
|
1339
|
-
self.assertEqual(i_h[key], s_h[key])
|
|
1340
|
-
self.assertEqual(s_h["CreatedBy"], "")
|
|
1341
|
-
self.assertEqual(
|
|
1342
|
-
len(squashed_image.layers), len(NumericValues.image.layers) - 3
|
|
1343
|
-
)
|
|
1323
|
+
for c in range(len(i_h)):
|
|
1324
|
+
for key in "CreatedBy", "Comment", "Size":
|
|
1325
|
+
self.assertEqual(s_h[c][key], i_h[c][key])
|
|
1326
|
+
self.assertEqual(squashed_image.history[0]["Comment"], "")
|
|
1327
|
+
self.assertEqual(squashed_image.history[0]["CreatedBy"], "")
|
|
1344
1328
|
|
|
1345
1329
|
|
|
1346
1330
|
if __name__ == "__main__":
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
version = "1.2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|