Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Merge pull request #196 from goldmann/summary_label
Browse files Browse the repository at this point in the history
Set summary label to value provided in description key
  • Loading branch information
goldmann committed Sep 4, 2017
1 parent 88e3651 commit c23265c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion dogen/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dockerfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c23265c

Please sign in to comment.