[virt-bootstrap] [PATCH 3/5] docker-source: Support blobs without .tar ext

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since skopeo v0.1.29 blobs are saved without the .tar extension.

See commit: projectatomic/skopeo@43acc74
Fix skopeo tests with changes to dir transport

The dir transport has been changed to save the blobs without the .tar extension
Fixes the skopeo tests failing due to this change

Signed-off-by: Radostin Stoyanov <rstoyanov1@xxxxxxxxx>
---
 src/virtBootstrap/sources/docker_source.py |  6 +++++-
 tests/docker_source.py                     | 13 +++++++++----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/virtBootstrap/sources/docker_source.py b/src/virtBootstrap/sources/docker_source.py
index 715e560..4281f55 100644
--- a/src/virtBootstrap/sources/docker_source.py
+++ b/src/virtBootstrap/sources/docker_source.py
@@ -107,7 +107,11 @@ class DockerSource(object):
             self.checksums.append([sum_type, layer_sum])  # Store checksums
 
             # Layers are tar files with hashsum used as name
-            file_path = os.path.join(self.images_dir, layer_sum + '.tar')
+            file_path = os.path.join(self.images_dir, layer_sum)
+            if not os.path.isfile(file_path):
+                file_path += '.tar'
+                if not os.path.isfile(file_path):
+                    raise ValueError('Blob %s does not exist.' % file_path)
             # Store 'file path' and set placeholder for 'size'
             self.layers.append([file_path, None])
 
diff --git a/tests/docker_source.py b/tests/docker_source.py
index 758cb97..f569eeb 100644
--- a/tests/docker_source.py
+++ b/tests/docker_source.py
@@ -335,9 +335,12 @@ class TestDockerSource(unittest.TestCase):
         }
 
         manifest = {'schemaVersion': 2, 'Layers': ['sha256:a7050fc1']}
-        (src_instance,
-         m_uri, m_utils) = self._mock_retrieve_layers_info(manifest,
-                                                           src_kwargs)
+
+        with mock.patch('os.path.isfile') as m_isfile:
+            m_isfile.return_value = True
+            result = self._mock_retrieve_layers_info(manifest, src_kwargs)
+
+        src_instance, m_uri, m_utils = result
 
         kwargs = {
             'insecure': src_instance.insecure,
@@ -373,7 +376,9 @@ class TestDockerSource(unittest.TestCase):
             ['/images_path/75c416ea.tar', None]
         ]
 
-        with mock.patch('os.path.getsize') as m_getsize:
+        with mock.patch('os.path.getsize') as m_getsize, \
+                mock.patch('os.path.isfile') as m_isfile:
             m_getsize.return_value = None
+            m_isfile.side_effect = lambda x: x.endswith(".tar")
             src_instance = self._mock_retrieve_layers_info(manifest, kwargs)[0]
         self.assertEqual(src_instance.layers, expected_result)
-- 
2.14.3

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list



[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux