From bf2443d340174fb26abbbaacf98bd5906eb21998 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 11 Mar 2016 13:46:47 -0500 Subject: [PATCH] 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 --- README.rst | 11 +++++++ deliverables/kilo/openstack-ansible.yaml | 1 + deliverables/liberty/openstack-ansible.yaml | 1 + openstack_releases/sphinxext.py | 33 +++++++++++++-------- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/README.rst b/README.rst index fc505b8622..745c43bad2 100644 --- a/README.rst +++ b/README.rst @@ -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. diff --git a/deliverables/kilo/openstack-ansible.yaml b/deliverables/kilo/openstack-ansible.yaml index a2d8e900ef..9614567ea3 100644 --- a/deliverables/kilo/openstack-ansible.yaml +++ b/deliverables/kilo/openstack-ansible.yaml @@ -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: diff --git a/deliverables/liberty/openstack-ansible.yaml b/deliverables/liberty/openstack-ansible.yaml index 65ecd464af..1d069453fd 100644 --- a/deliverables/liberty/openstack-ansible.yaml +++ b/deliverables/liberty/openstack-ansible.yaml @@ -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: diff --git a/openstack_releases/sphinxext.py b/openstack_releases/sphinxext.py index e03b44680d..604469a990 100644 --- a/openstack_releases/sphinxext.py +++ b/openstack_releases/sphinxext.py @@ -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', [])),