Repository: jboss-dockerfiles/dogen

Issue:
Set summary label to value provided in description key
If the `summary` label is not defined, its value should be set to value of the `description` key. If it's not provided, summary label should not be set.

Discussion:

Patch:
diff --git a/dogen/generator.py b/dogen/generator.py
index 1106f49..3a13051 100644
--- a/dogen/generator.py
+++ b/dogen/generator.py
@@ -232,13 +232,24 @@ class Generator(object):
         if not self.cfg.get('labels'):
             self.cfg['labels'] = []
 
+        labels = {}
+
+        for label in self.cfg.get('labels'):
+            labels[label['name']] = label['value']
+
         # https://github.com/jboss-dockerfiles/dogen/issues/129
         # https://github.com/jboss-dockerfiles/dogen/issues/137
         for label in ['maintainer', 'description']:
             value = self.cfg.get(label)
 
-            if value:
+            if value and not label in labels:
                 self.cfg['labels'].append({'name': label, 'value': value})
+                labels[label] = value
+
+        # https://github.com/jboss-dockerfiles/dogen/issues/195
+        if 'summary' not in labels:
+            if 'description' in labels:
+                self.cfg['labels'].append({'name': 'summary', 'value': labels.get('description')})
 
         if self.template:
             template_file = self.template


Test patch:
diff --git a/tests/test_dockerfile.py b/tests/test_dockerfile.py
index 3ab2885..9f34741 100644
--- a/tests/test_dockerfile.py
+++ b/tests/test_dockerfile.py
@@ -170,7 +170,7 @@ class TestDockerfile(unittest.TestCase):
         generator.configure()
         generator.render_from_template()
 
-        self.assertEqual(generator.cfg['labels'], [{'name': 'description', 'value': 'This is a nice image'}])
+        self.assertEqual(generator.cfg['labels'], [{'name': 'description', 'value': 'This is a nice image'}, {'name': 'summary', 'value': 'This is a nice image'}])
 
         with open(os.path.join(self.target, "Dockerfile"), "r") as f:
             dockerfile = f.read()