docker-squash 1.2.0__tar.gz → 1.2.2__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.2}/PKG-INFO +2 -2
- {docker-squash-1.2.0 → docker_squash-1.2.2}/docker_squash/image.py +7 -6
- {docker-squash-1.2.0 → docker_squash-1.2.2}/docker_squash/squash.py +5 -2
- {docker-squash-1.2.0 → docker_squash-1.2.2}/docker_squash/v2_image.py +3 -0
- docker_squash-1.2.2/docker_squash/version.py +1 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2/docker_squash.egg-info}/PKG-INFO +2 -2
- {docker-squash-1.2.0 → docker_squash-1.2.2}/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.2}/LICENSE +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/MANIFEST.in +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/README.rst +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/docker_squash/__init__.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/docker_squash/cli.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/docker_squash/errors.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/docker_squash/lib/__init__.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/docker_squash/lib/common.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/docker_squash/v1_image.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/docker_squash.egg-info/SOURCES.txt +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/docker_squash.egg-info/dependency_links.txt +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/docker_squash.egg-info/entry_points.txt +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/docker_squash.egg-info/requires.txt +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/docker_squash.egg-info/top_level.txt +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/requirements.txt +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/setup.cfg +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/setup.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/tests/test_qa.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/tests/test_unit_squash.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/tests/test_unit_v1_image.py +0 -0
- {docker-squash-1.2.0 → docker_squash-1.2.2}/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.2
|
|
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.2.tar.gz
|
|
7
7
|
Author: Marek Goldmann
|
|
8
8
|
Author-email: marek.goldmann@gmail.com
|
|
9
9
|
License: MIT
|
|
@@ -186,11 +186,12 @@ class Image(object):
|
|
|
186
186
|
try:
|
|
187
187
|
number_of_layers = int(self.from_layer)
|
|
188
188
|
|
|
189
|
-
self.log.debug(
|
|
189
|
+
self.log.debug(
|
|
190
|
+
f"We detected number of layers ({number_of_layers}) as the argument to squash"
|
|
191
|
+
)
|
|
190
192
|
except ValueError:
|
|
191
|
-
self.log.debug("We detected layer as the argument to squash")
|
|
192
|
-
|
|
193
193
|
squash_id = self._squash_id(self.from_layer)
|
|
194
|
+
self.log.debug(f"We detected layer ({squash_id}) as the argument to squash")
|
|
194
195
|
|
|
195
196
|
if not squash_id:
|
|
196
197
|
raise SquashError(
|
|
@@ -220,9 +221,9 @@ class Image(object):
|
|
|
220
221
|
"Single layer marked to squash, no squashing is required"
|
|
221
222
|
)
|
|
222
223
|
|
|
223
|
-
self.log.info("Attempting to squash last
|
|
224
|
-
self.log.debug("Layers to squash:
|
|
225
|
-
self.log.debug("Layers to move:
|
|
224
|
+
self.log.info(f"Attempting to squash last {number_of_layers} layers...")
|
|
225
|
+
self.log.debug(f"Layers to squash: {self.layers_to_squash}")
|
|
226
|
+
self.log.debug(f"Layers to move: {self.layers_to_move}")
|
|
226
227
|
|
|
227
228
|
# Fetch the image and unpack it on the fly to the old image directory
|
|
228
229
|
self._save_image(self.old_image_id, self.old_image_dir)
|
|
@@ -143,8 +143,11 @@ class Squash(object):
|
|
|
143
143
|
# Load squashed image into Docker
|
|
144
144
|
image.load_squashed_image()
|
|
145
145
|
|
|
146
|
-
#
|
|
147
|
-
|
|
146
|
+
# If development mode is not enabled, make sure we clean up the
|
|
147
|
+
# temporary directory
|
|
148
|
+
if not self.development:
|
|
149
|
+
# Clean up all temporary files
|
|
150
|
+
image.cleanup()
|
|
148
151
|
|
|
149
152
|
# Remove the source image - this is the only possible way
|
|
150
153
|
# to remove orphaned layers from Docker daemon at the build time.
|
|
@@ -39,6 +39,9 @@ class V2Image(Image):
|
|
|
39
39
|
if self.layer_paths_to_move:
|
|
40
40
|
self.squash_id = self.layer_paths_to_move[-1]
|
|
41
41
|
|
|
42
|
+
self.log.debug(f"Layers paths to squash: {self.layer_paths_to_squash}")
|
|
43
|
+
self.log.debug(f"Layers paths to move: {self.layer_paths_to_move}")
|
|
44
|
+
|
|
42
45
|
def _squash(self):
|
|
43
46
|
if self.layer_paths_to_squash:
|
|
44
47
|
# Prepare the directory
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version = "1.2.2"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: docker-squash
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
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.2.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
|