add artifact-link-mode option

The openstack-ansible project doesn't produce separate tarball
artifacts, so give them a way to turn off links that point to files that
don't exist.

Change-Id: I3fa5a053b61cd57e65222cde785ea7742870c8ee
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2016-03-11 13:46:47 -05:00
parent 6db650bf37
commit bf2443d340
4 changed files with 33 additions and 13 deletions

View File

@ -193,6 +193,17 @@ The top level of a deliverable file is a mapping with keys:
announcement should include the link to the package on
PyPI. Defaults to ``no``.
``artifact-link-mode``
Describe how to link to artifacts produced by the project. The
default is ``tarball`. Valid values are:
tarball
Automatically generates links to version-specific files on
tarballs.openstack.org.
none
Do not link to anything, just show the version number.
``releases``
A list of the releases for the deliverable.

View File

@ -1,6 +1,7 @@
---
launchpad: openstack-ansible
send-announcements-to: openstack-announce@lists.openstack.org
artifact-link-mode: none
releases:
- version: 11.0.0
projects:

View File

@ -2,6 +2,7 @@
launchpad: openstack-ansible
send-announcements-to: openstack-announce@lists.openstack.org
release-notes: http://docs.openstack.org/releasenotes/openstack-ansible/liberty.html
artifact-link-mode: none
releases:
- version: 12.0.0
projects:

View File

@ -168,18 +168,24 @@ class DeliverableDirectiveBase(rst.Directive):
}
@staticmethod
def _tarball_link(version, project):
repo_base = project['repo'].rsplit('/')[-1]
if 'tarball-base' in project:
base = project['tarball-base']
else:
base = repo_base
return '`{v} <{s}/{r}/{n}-{v}.tar.gz>`__'.format(
s='https://tarballs.openstack.org',
v=version,
r=repo_base,
n=base,
)
def _artifact_link(mode, version, project):
if mode == 'tarball':
# Link the version number to the tarball for downloading.
repo_base = project['repo'].rsplit('/')[-1]
if 'tarball-base' in project:
base = project['tarball-base']
else:
base = repo_base
return '`{v} <{s}/{r}/{n}-{v}.tar.gz>`__'.format(
s='https://tarballs.openstack.org',
v=version,
r=repo_base,
n=base,
)
elif mode == 'none':
# Only show the version number.
return version
raise ValueError('Unrecognized artifact-link-mode: %r' % mode)
def _add_deliverables(self, type_tag, deliverables, series, app, result):
source_name = '<' + __name__ + '>'
@ -244,10 +250,11 @@ class DeliverableDirectiveBase(rst.Directive):
_add('')
_add('Release Notes: %s' % release_notes)
_add('')
link_mode = deliverable_info.get('artifact-link-mode', 'tarball')
_list_table(
_add,
['Version', 'Repo', 'Git Commit'],
((self._tarball_link(r['version'], p),
((self._artifact_link(link_mode, r['version'], p),
p['repo'], p['hash'])
for r in reversed(deliverable_info.get('releases', []))
for p in r.get('projects', [])),