Repository: cekit/cekit

Issue:
cekit (-v) warns about missing module version for a dependency
**Describe the bug**

Cekit (in verbose mode) complains (WARNING) about a missing module version, for a module dependency, and chooses a default version. But in practise the most common way to depend upon a module is version-less. So this is very noisy.

**To reproduce**
The OpenJDK image demonstrates this (see logs below)

**Expected behavior**

Perhaps cekit could only WARN if it knew about more than one module version instead of always.

**Logs**

```
2019-09-16 15:54:22,483 cekit        DEBUG    Preparing module 'jboss.container.user' required by 'jboss.container.openjdk.jdk'.
2019-09-16 15:54:22,483 cekit        WARNING  Module version not specified for 'jboss.container.user' module, using '1.0' default version
2
```

this is cekit 3.4.0

Discussion:

Patch:
diff --git a/cekit/generator/base.py b/cekit/generator/base.py
index 85ed250..d79739b 100644
--- a/cekit/generator/base.py
+++ b/cekit/generator/base.py
@@ -526,7 +526,7 @@ class ModuleRegistry(object):
 
             default_module = self.get_module(name, default_version)
 
-            if not suppress_warnings:
+            if not suppress_warnings and len(modules) > 1:
                 LOGGER.warning("Module version not specified for '{}' module, using '{}' default version".format(
                     name, default_version))
 


Test patch:
diff --git a/tests/test_unit_image.py b/tests/test_unit_image.py
index 5e78f66..747520e 100644
--- a/tests/test_unit_image.py
+++ b/tests/test_unit_image.py
@@ -192,6 +192,45 @@ def test_module_processing_modules_with_multiple_versions(caplog):
     assert "Module version not specified for 'org.test.module.b' module, using '1.1' default version" in caplog.text
 
 
+# https://github.com/cekit/cekit/issues/617
+def test_module_processing_modules_with_single_versions(caplog):
+    caplog.set_level(logging.DEBUG, logger="cekit")
+
+    image = Image(yaml.safe_load("""
+        from: foo
+        name: test/foo
+        version: 1.9
+        """), 'foo')
+
+    module_a = Module(yaml.safe_load("""
+        name: org.test.module.a
+        version: 1.0
+        """), 'path', 'artifact_path')
+
+    module_b = Module(yaml.safe_load("""
+        name: org.test.module.b
+        version: 1.0
+        """), 'path', 'artifact_path')
+
+    module_registry = ModuleRegistry()
+    module_registry.add_module(module_a)
+    module_registry.add_module(module_b)
+
+    resulting_install_list = OrderedDict()
+
+    to_install_list = [
+        Map({'name': 'org.test.module.a', 'version': '1.0'}),
+        Map({'name': 'org.test.module.b'})
+    ]
+
+    image.process_install_list(image, to_install_list, resulting_install_list, module_registry)
+
+    assert resulting_install_list == OrderedDict(
+        [('org.test.module.a', {'name': 'org.test.module.a', 'version': '1.0'}), ('org.test.module.b', {'name': 'org.test.module.b'})])
+
+    assert "Module version not specified for" not in caplog.text
+
+
 def test_module_processing_fail_when_a_module_aready_exists_in_registry():
     module_a = Module(yaml.safe_load("""
         name: org.test.module.a