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 @@ def render_from_template(self): 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 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 @@ def test_generating_description_label(self): 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()