Repository: jboss-dockerfiles/dogen

Issue:
Do not require md5sum for artifacts
The EnMasse community images need to be built using the 'latest' artifacts.  To import these using sources, we need the latest md5sum.  The md5sum might change after every build.  Can we have an option to skip the md5sum, or have it pull & recalculate it?

Discussion:

Patch:
diff --git a/dogen/generator.py b/dogen/generator.py
index 6d0793b..98ec763 100644
--- a/dogen/generator.py
+++ b/dogen/generator.py
@@ -292,7 +292,8 @@ class Generator(object):
             passed = False
             try:
                 if os.path.exists(filename):
-                    self.check_sum(filename, source['md5sum'])
+                    if source.get('md5sum'):
+                        self.check_sum(filename, source['md5sum'])
                     passed = True
             except Exception as e:
                 self.log.warn(str(e))
@@ -307,9 +308,11 @@ class Generator(object):
 
                 self._fetch_file(url, filename)
 
-                self.check_sum(filename, source['md5sum'])
-
-            self.cfg['artifacts'][target] = "md5:%s" % source['md5sum']
+                if source.get('md5sum'):
+                    self.check_sum(filename, source['md5sum'])
+                    self.cfg['artifacts'][target] = "md5:%s" % source['md5sum']
+                else:
+                    self.cfg['artifacts'][target] = None
 
     def check_sum(self, filename, checksum):
         self.log.info("Checking '%s' MD5 hash..." % os.path.basename(filename))


Test patch:
diff --git a/tests/test_package.py b/tests/test_package.py
index b742e65..3b961bc 100644
--- a/tests/test_package.py
+++ b/tests/test_package.py
@@ -5,7 +5,6 @@ import tempfile
 import unittest
 import shutil
 import re
-import sys
 
 from dogen.plugins.repo import Repo
 from dogen.generator import Generator
@@ -45,6 +44,5 @@ class TestPackage(unittest.TestCase):
 
         dockerfile = open(os.path.join(self.target_dir, "Dockerfile")).read()
 
-        sys.stderr.write("\t\t\tDEBUGDEBUG\n{}\n".format(dockerfile))
         self.assertTrue(re.match(r'.*yum install[^\n]+wget', dockerfile, re.DOTALL))
         self.assertTrue(re.match(r'.*rpm -q +wget', dockerfile, re.DOTALL))
diff --git a/tests/test_unit_generate_configuration.py b/tests/test_unit_generate_configuration.py
index 9c01463..e439971 100644
--- a/tests/test_unit_generate_configuration.py
+++ b/tests/test_unit_generate_configuration.py
@@ -261,6 +261,17 @@ class TestConfig(unittest.TestCase):
         generator._handle_scripts()
         # success if no stack trace thrown
 
+    @mock.patch('dogen.generator.Generator._fetch_file')
+    def test_handling_sources_without_specified_md5sum(self, mock_fetch_file):
+        with self.descriptor as f:
+            f.write("sources:\n  - url: http://somehost.com/file.zip".encode())
+
+        generator = Generator(self.log, self.args)
+        generator.configure()
+        generator.handle_sources()
+
+        mock_fetch_file.assert_called_with('http://somehost.com/file.zip', 'target/file.zip')
+
     @mock.patch('dogen.generator.Generator.check_sum')
     @mock.patch('dogen.generator.Generator._fetch_file')
     def test_handling_sources(self, mock_fetch_file, mock_check_sum):