From d3dd0ac7fdedce6a5e58f513478a7a038fbfb393 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Mon, 18 Jul 2016 16:02:58 +0200 Subject: [PATCH 1/7] Fix and improve documentation. --- docs/api-reference-v0.rst | 19 ++++++++++--------- docs/getting-started.rst | 4 ++-- docs/introduction.rst | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/api-reference-v0.rst b/docs/api-reference-v0.rst index 790a791..2a89075 100644 --- a/docs/api-reference-v0.rst +++ b/docs/api-reference-v0.rst @@ -49,7 +49,8 @@ Example: https://api.debops.org/v0/roles/debops.list ~~~~~~~~~~~~~~~~~~~~~~ Returns the total number of roles in the given name space. -The ``[:]`` is optional and allows to limit the count to the role owner. +The ``[:]`` is optional and allows to limit the count to the given role +owner. Examples: @@ -69,6 +70,12 @@ full role name to meta data (described below) mapping. this API. Keys might be missing for roles with this version. Do a version compare for ``0.2.0`` or higher of fixup the DebOps API. +``role_name`` + Ansible Galaxy role name. + +``role_owner`` + Ansible Galaxy role owner. + ``authors`` List of dicts, one dict for each author. @@ -108,12 +115,6 @@ full role name to meta data (described below) mapping. ``pr_url`` HTML URL on the VCS platform where Pull/Merge requests can be submitted to. -``role_name`` - Ansible Galaxy role name. - -``role_owner`` - Ansible Galaxy role owner. - ``tags`` List of tags of the repository, currently equivalent with Ansible Galaxy role tags. @@ -125,8 +126,8 @@ full role name to meta data (described below) mapping. repository is tested. ``ci_url`` - HTML URL for the continues integration system on which the repository is - tested. + HTML URL for the test page of the continues integration system which is used + for the repository. ``vcs_last_committer_date`` Date of last commit in VCS. diff --git a/docs/getting-started.rst b/docs/getting-started.rst index 57e0d56..6591877 100644 --- a/docs/getting-started.rst +++ b/docs/getting-started.rst @@ -9,9 +9,9 @@ Checkout the following example to get started: .. code-block:: console - curl --silent https://api.debops.org/roles/debops.unattended_upgrades.json | jq '.' + curl https://api.debops.org/v0/role/debops.unattended_upgrades.json -k | jq '.' You can also open that URL in your browser via HTTP GET: -https://api.debops.org/roles/debops.unattended_upgrades.json +https://api.debops.org/v0/role/debops.unattended_upgrades.json But note that the encoded JSON object is not prettified. diff --git a/docs/introduction.rst b/docs/introduction.rst index 4816815..eb69a18 100644 --- a/docs/introduction.rst +++ b/docs/introduction.rst @@ -6,8 +6,8 @@ internally by the project but can also be used by third parties. API URL: https://api.debops.org/ -Used by -------- +Example usages +-------------- * https://github.com/debops/debops.github.io/ From 7095483ff64791d4eaa3d9c053a4ae849193cff8 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Mon, 18 Jul 2016 16:09:57 +0200 Subject: [PATCH 2/7] Add example_roles/debops.ansible.rst which currently produces wrong URLs. --- tests/api_data/v0/role/debops.ansible.json | 1 + tests/api_data/v0/roles/count | 2 +- tests/api_data/v0/roles/count:debops | 2 +- tests/api_data/v0/roles/debops.json | 2 +- tests/api_data/v0/roles/debops.list | 1 + tests/example_roles/debops.ansible.rst | 0 6 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 tests/api_data/v0/role/debops.ansible.json create mode 100644 tests/example_roles/debops.ansible.rst diff --git a/tests/api_data/v0/role/debops.ansible.json b/tests/api_data/v0/role/debops.ansible.json new file mode 100644 index 0000000..af4b093 --- /dev/null +++ b/tests/api_data/v0/role/debops.ansible.json @@ -0,0 +1 @@ +{"ci_badge_url": "https://api.travis-ci.org/debops/ansible-ansible.png", "ci_url": "https://travis-ci.org/debops/ansible-ansible", "clone_url": "https://github.com/debops/ansible-ansible.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/ansible", "issue_url": "https://github.com/debops/ansible-ansible/issues", "pr_url": "https://github.com/debops/ansible-ansible/pulls", "role_name": "ansible", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-ansible", "vcs_url": "https://github.com/debops/ansible-ansible"} diff --git a/tests/api_data/v0/roles/count b/tests/api_data/v0/roles/count index 0cfbf08..00750ed 100644 --- a/tests/api_data/v0/roles/count +++ b/tests/api_data/v0/roles/count @@ -1 +1 @@ -2 +3 diff --git a/tests/api_data/v0/roles/count:debops b/tests/api_data/v0/roles/count:debops index 0cfbf08..00750ed 100644 --- a/tests/api_data/v0/roles/count:debops +++ b/tests/api_data/v0/roles/count:debops @@ -1 +1 @@ -2 +3 diff --git a/tests/api_data/v0/roles/debops.json b/tests/api_data/v0/roles/debops.json index 7fb3f7c..824dfeb 100644 --- a/tests/api_data/v0/roles/debops.json +++ b/tests/api_data/v0/roles/debops.json @@ -1 +1 @@ -{"debops.unattended_upgrades": {"authors": [{"name": "Maciej Delmanowski", "nick": "drybjed"}, {"name": "Robin Schneider", "nick": "ypid"}], "ci_badge_url": "https://api.travis-ci.org/debops/ansible-unattended_upgrades.png", "ci_url": "https://travis-ci.org/debops/ansible-unattended_upgrades", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "description": "Configure unattended upgrades on Debian-based hosts", "docs_format_version": "0.2.0", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "galaxy_url": "https://galaxy.ansible.com/debops/unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "license": "GPL-3.0", "min_ansible_version": "2.0.0", "platforms": [{"name": "Ubuntu", "versions": ["precise", "quantal", "raring", "saucy", "trusty"]}, {"name": "Debian", "versions": ["wheezy", "jessie"]}], "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "role_name": "unattended_upgrades", "role_owner": "debops", "tags": ["apt", "system", "security"], "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-unattended_upgrades", "vcs_last_committer_date": "1970-01-01 00:00:00 +0000", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades", "version": "0.0.0"}, "debops.users": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-users.png", "ci_url": "https://travis-ci.org/debops/ansible-users", "clone_url": "https://github.com/debops/ansible-users.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/users", "issue_url": "https://github.com/debops/ansible-users/issues", "pr_url": "https://github.com/debops/ansible-users/pulls", "role_name": "users", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-users", "vcs_url": "https://github.com/debops/ansible-users"}} \ No newline at end of file +{"debops.ansible": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-ansible.png", "ci_url": "https://travis-ci.org/debops/ansible-ansible", "clone_url": "https://github.com/debops/ansible-ansible.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/ansible", "issue_url": "https://github.com/debops/ansible-ansible/issues", "pr_url": "https://github.com/debops/ansible-ansible/pulls", "role_name": "ansible", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-ansible", "vcs_url": "https://github.com/debops/ansible-ansible"}, "debops.unattended_upgrades": {"authors": [{"name": "Maciej Delmanowski", "nick": "drybjed"}, {"name": "Robin Schneider", "nick": "ypid"}], "ci_badge_url": "https://api.travis-ci.org/debops/ansible-unattended_upgrades.png", "ci_url": "https://travis-ci.org/debops/ansible-unattended_upgrades", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "description": "Configure unattended upgrades on Debian-based hosts", "docs_format_version": "0.2.0", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "galaxy_url": "https://galaxy.ansible.com/debops/unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "license": "GPL-3.0", "min_ansible_version": "2.0.0", "platforms": [{"name": "Ubuntu", "versions": ["precise", "quantal", "raring", "saucy", "trusty"]}, {"name": "Debian", "versions": ["wheezy", "jessie"]}], "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "role_name": "unattended_upgrades", "role_owner": "debops", "tags": ["apt", "system", "security"], "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-unattended_upgrades", "vcs_last_committer_date": "1970-01-01 00:00:00 +0000", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades", "version": "0.0.0"}, "debops.users": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-users.png", "ci_url": "https://travis-ci.org/debops/ansible-users", "clone_url": "https://github.com/debops/ansible-users.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/users", "issue_url": "https://github.com/debops/ansible-users/issues", "pr_url": "https://github.com/debops/ansible-users/pulls", "role_name": "users", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-users", "vcs_url": "https://github.com/debops/ansible-users"}} \ No newline at end of file diff --git a/tests/api_data/v0/roles/debops.list b/tests/api_data/v0/roles/debops.list index ad50440..ef79902 100644 --- a/tests/api_data/v0/roles/debops.list +++ b/tests/api_data/v0/roles/debops.list @@ -1,2 +1,3 @@ +debops.ansible debops.unattended_upgrades debops.users diff --git a/tests/example_roles/debops.ansible.rst b/tests/example_roles/debops.ansible.rst new file mode 100644 index 0000000..e69de29 From f61c441cd20227236ab81726f0b45b3bfd539c5b Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Mon, 18 Jul 2016 16:50:53 +0200 Subject: [PATCH 3/7] Role names need to be normalized before using them to construct URLs. --- Makefile | 2 +- bin/debops-api | 30 ++++++++++++++----- docs/api-reference-v0.rst | 9 ++++-- tests/api_data/v0/role/debops.ansible.json | 2 +- .../v0/role/debops.unattended_upgrades.json | 2 +- tests/api_data/v0/role/debops.users.json | 2 +- tests/api_data/v0/roles/debops.json | 2 +- 7 files changed, 35 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 4e4b94f..f64460a 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ check: tests/api_data tests/api_data: bin/debops-api tests/example_roles FORCE_MAKE "$<" --test-mode --role-path tests/example_roles/ \ - --docs-url-pattern 'http://docs.debops.org/en/latest/ansible/roles/ansible-{name}/docs/index.html' \ + --docs-url-pattern 'http://docs.debops.org/en/latest/ansible/roles/ansible-{role_name}/docs/index.html' \ --role-owner debops \ --api-dir "$@" diff --git a/bin/debops-api b/bin/debops-api index 5aa88c1..73f12ad 100755 --- a/bin/debops-api +++ b/bin/debops-api @@ -85,7 +85,11 @@ class DebOpsAPI: """ github_base_url = 'https://github.com' - return '/'.join(github_base_url, role_owner, role_name) + return '/'.join([ + github_base_url, + role_owner, + 'ansible-' + self._get_normalized_role_name(role_name), + ]) def _read_github_repos_api_response( self, @@ -261,6 +265,16 @@ class DebOpsAPI: return metadata + def _get_normalized_role_name(self, role_name): + """ + Returns normalized role name as used in URLs + Example role name: `ansible`, returns: `role-ansible`. + """ + + if role_name == 'ansible': + role_name = 'role-' + role_name + return role_name + def _get_normalized_meta_main(self, meta_main): """ Returns normalized meta/main.yml data intended for inclusion in @@ -305,16 +319,17 @@ class DebOpsAPI: role_name = metadata['role_name'] additonal_metadata = { + 'normalized_role_name': self._get_normalized_role_name(role_name), 'ci_badge_url': 'https://api.travis-ci.org/{}/ansible-{}.png'.format( role_owner, - role_name, + self._get_normalized_role_name(role_name), ), 'ci_url': 'https://travis-ci.org/{}/ansible-{}'.format( role_owner, - role_name, + self._get_normalized_role_name(role_name), ), 'test_suite_url': 'https://github.com/debops/test-suite/tree/master/ansible-{}'.format( - role_name, + self._get_normalized_role_name(role_name), ), 'galaxy_url': 'https://galaxy.ansible.com/{}/{}'.format( role_owner, @@ -333,8 +348,9 @@ class DebOpsAPI: StrictVersion(metadata['docs_format_version']): additonal_metadata['docs_url'] = self._docs_url_pattern.format( - owner=role_owner, - name=role_name, + role_owner=role_owner, + role_name=role_name, + normalized_role_name=self._get_normalized_role_name(role_name), ) self._metadata[role_full_name].update(additonal_metadata) @@ -385,7 +401,7 @@ class DebOpsAPI: if not role_owner: raise Exception('Default role owner not given but required.') - role_vcs_url = 'https://github.com/{}/ansible-{}'.format( + role_vcs_url = self._get_repo_url( role_owner, role_name, ) diff --git a/docs/api-reference-v0.rst b/docs/api-reference-v0.rst index 2a89075..8e71217 100644 --- a/docs/api-reference-v0.rst +++ b/docs/api-reference-v0.rst @@ -70,11 +70,16 @@ full role name to meta data (described below) mapping. this API. Keys might be missing for roles with this version. Do a version compare for ``0.2.0`` or higher of fixup the DebOps API. +``role_owner`` + Ansible Galaxy role owner. + ``role_name`` Ansible Galaxy role name. -``role_owner`` - Ansible Galaxy role owner. +``normalized_role_name`` + Ansible role name as used in URLs. Currently the only case where this is + different to ``role_name`` is when ``role_name`` is ``ansible`` (in this case + ``normalized_role_name`` will be ``role-ansible``). ``authors`` List of dicts, one dict for each author. diff --git a/tests/api_data/v0/role/debops.ansible.json b/tests/api_data/v0/role/debops.ansible.json index af4b093..d069213 100644 --- a/tests/api_data/v0/role/debops.ansible.json +++ b/tests/api_data/v0/role/debops.ansible.json @@ -1 +1 @@ -{"ci_badge_url": "https://api.travis-ci.org/debops/ansible-ansible.png", "ci_url": "https://travis-ci.org/debops/ansible-ansible", "clone_url": "https://github.com/debops/ansible-ansible.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/ansible", "issue_url": "https://github.com/debops/ansible-ansible/issues", "pr_url": "https://github.com/debops/ansible-ansible/pulls", "role_name": "ansible", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-ansible", "vcs_url": "https://github.com/debops/ansible-ansible"} +{"ci_badge_url": "https://api.travis-ci.org/debops/ansible-role-ansible.png", "ci_url": "https://travis-ci.org/debops/ansible-role-ansible", "clone_url": "https://github.com/debops/ansible-role-ansible.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/ansible", "issue_url": "https://github.com/debops/ansible-role-ansible/issues", "normalized_role_name": "role-ansible", "pr_url": "https://github.com/debops/ansible-role-ansible/pulls", "role_name": "ansible", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-role-ansible", "vcs_url": "https://github.com/debops/ansible-role-ansible"} diff --git a/tests/api_data/v0/role/debops.unattended_upgrades.json b/tests/api_data/v0/role/debops.unattended_upgrades.json index 61f6c4c..7a3e4e6 100644 --- a/tests/api_data/v0/role/debops.unattended_upgrades.json +++ b/tests/api_data/v0/role/debops.unattended_upgrades.json @@ -1 +1 @@ -{"authors": [{"name": "Maciej Delmanowski", "nick": "drybjed"}, {"name": "Robin Schneider", "nick": "ypid"}], "ci_badge_url": "https://api.travis-ci.org/debops/ansible-unattended_upgrades.png", "ci_url": "https://travis-ci.org/debops/ansible-unattended_upgrades", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "description": "Configure unattended upgrades on Debian-based hosts", "docs_format_version": "0.2.0", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "galaxy_url": "https://galaxy.ansible.com/debops/unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "license": "GPL-3.0", "min_ansible_version": "2.0.0", "platforms": [{"name": "Ubuntu", "versions": ["precise", "quantal", "raring", "saucy", "trusty"]}, {"name": "Debian", "versions": ["wheezy", "jessie"]}], "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "role_name": "unattended_upgrades", "role_owner": "debops", "tags": ["apt", "system", "security"], "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-unattended_upgrades", "vcs_last_committer_date": "1970-01-01 00:00:00 +0000", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades", "version": "0.0.0"} +{"authors": [{"name": "Maciej Delmanowski", "nick": "drybjed"}, {"name": "Robin Schneider", "nick": "ypid"}], "ci_badge_url": "https://api.travis-ci.org/debops/ansible-unattended_upgrades.png", "ci_url": "https://travis-ci.org/debops/ansible-unattended_upgrades", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "description": "Configure unattended upgrades on Debian-based hosts", "docs_format_version": "0.2.0", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "galaxy_url": "https://galaxy.ansible.com/debops/unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "license": "GPL-3.0", "min_ansible_version": "2.0.0", "normalized_role_name": "unattended_upgrades", "platforms": [{"name": "Ubuntu", "versions": ["precise", "quantal", "raring", "saucy", "trusty"]}, {"name": "Debian", "versions": ["wheezy", "jessie"]}], "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "role_name": "unattended_upgrades", "role_owner": "debops", "tags": ["apt", "system", "security"], "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-unattended_upgrades", "vcs_last_committer_date": "1970-01-01 00:00:00 +0000", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades", "version": "0.0.0"} diff --git a/tests/api_data/v0/role/debops.users.json b/tests/api_data/v0/role/debops.users.json index b038d5e..868e755 100644 --- a/tests/api_data/v0/role/debops.users.json +++ b/tests/api_data/v0/role/debops.users.json @@ -1 +1 @@ -{"ci_badge_url": "https://api.travis-ci.org/debops/ansible-users.png", "ci_url": "https://travis-ci.org/debops/ansible-users", "clone_url": "https://github.com/debops/ansible-users.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/users", "issue_url": "https://github.com/debops/ansible-users/issues", "pr_url": "https://github.com/debops/ansible-users/pulls", "role_name": "users", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-users", "vcs_url": "https://github.com/debops/ansible-users"} +{"ci_badge_url": "https://api.travis-ci.org/debops/ansible-users.png", "ci_url": "https://travis-ci.org/debops/ansible-users", "clone_url": "https://github.com/debops/ansible-users.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/users", "issue_url": "https://github.com/debops/ansible-users/issues", "normalized_role_name": "users", "pr_url": "https://github.com/debops/ansible-users/pulls", "role_name": "users", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-users", "vcs_url": "https://github.com/debops/ansible-users"} diff --git a/tests/api_data/v0/roles/debops.json b/tests/api_data/v0/roles/debops.json index 824dfeb..85af400 100644 --- a/tests/api_data/v0/roles/debops.json +++ b/tests/api_data/v0/roles/debops.json @@ -1 +1 @@ -{"debops.ansible": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-ansible.png", "ci_url": "https://travis-ci.org/debops/ansible-ansible", "clone_url": "https://github.com/debops/ansible-ansible.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/ansible", "issue_url": "https://github.com/debops/ansible-ansible/issues", "pr_url": "https://github.com/debops/ansible-ansible/pulls", "role_name": "ansible", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-ansible", "vcs_url": "https://github.com/debops/ansible-ansible"}, "debops.unattended_upgrades": {"authors": [{"name": "Maciej Delmanowski", "nick": "drybjed"}, {"name": "Robin Schneider", "nick": "ypid"}], "ci_badge_url": "https://api.travis-ci.org/debops/ansible-unattended_upgrades.png", "ci_url": "https://travis-ci.org/debops/ansible-unattended_upgrades", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "description": "Configure unattended upgrades on Debian-based hosts", "docs_format_version": "0.2.0", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "galaxy_url": "https://galaxy.ansible.com/debops/unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "license": "GPL-3.0", "min_ansible_version": "2.0.0", "platforms": [{"name": "Ubuntu", "versions": ["precise", "quantal", "raring", "saucy", "trusty"]}, {"name": "Debian", "versions": ["wheezy", "jessie"]}], "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "role_name": "unattended_upgrades", "role_owner": "debops", "tags": ["apt", "system", "security"], "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-unattended_upgrades", "vcs_last_committer_date": "1970-01-01 00:00:00 +0000", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades", "version": "0.0.0"}, "debops.users": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-users.png", "ci_url": "https://travis-ci.org/debops/ansible-users", "clone_url": "https://github.com/debops/ansible-users.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/users", "issue_url": "https://github.com/debops/ansible-users/issues", "pr_url": "https://github.com/debops/ansible-users/pulls", "role_name": "users", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-users", "vcs_url": "https://github.com/debops/ansible-users"}} \ No newline at end of file +{"debops.ansible": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-role-ansible.png", "ci_url": "https://travis-ci.org/debops/ansible-role-ansible", "clone_url": "https://github.com/debops/ansible-role-ansible.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/ansible", "issue_url": "https://github.com/debops/ansible-role-ansible/issues", "normalized_role_name": "role-ansible", "pr_url": "https://github.com/debops/ansible-role-ansible/pulls", "role_name": "ansible", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-role-ansible", "vcs_url": "https://github.com/debops/ansible-role-ansible"}, "debops.unattended_upgrades": {"authors": [{"name": "Maciej Delmanowski", "nick": "drybjed"}, {"name": "Robin Schneider", "nick": "ypid"}], "ci_badge_url": "https://api.travis-ci.org/debops/ansible-unattended_upgrades.png", "ci_url": "https://travis-ci.org/debops/ansible-unattended_upgrades", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "description": "Configure unattended upgrades on Debian-based hosts", "docs_format_version": "0.2.0", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "galaxy_url": "https://galaxy.ansible.com/debops/unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "license": "GPL-3.0", "min_ansible_version": "2.0.0", "normalized_role_name": "unattended_upgrades", "platforms": [{"name": "Ubuntu", "versions": ["precise", "quantal", "raring", "saucy", "trusty"]}, {"name": "Debian", "versions": ["wheezy", "jessie"]}], "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "role_name": "unattended_upgrades", "role_owner": "debops", "tags": ["apt", "system", "security"], "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-unattended_upgrades", "vcs_last_committer_date": "1970-01-01 00:00:00 +0000", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades", "version": "0.0.0"}, "debops.users": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-users.png", "ci_url": "https://travis-ci.org/debops/ansible-users", "clone_url": "https://github.com/debops/ansible-users.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/users", "issue_url": "https://github.com/debops/ansible-users/issues", "normalized_role_name": "users", "pr_url": "https://github.com/debops/ansible-users/pulls", "role_name": "users", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-users", "vcs_url": "https://github.com/debops/ansible-users"}} \ No newline at end of file From 1ac1ad1b65af1bee6f7b381514f9309f2e541902 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Mon, 18 Jul 2016 16:56:16 +0200 Subject: [PATCH 4/7] Ensure last line of API data is terminated by `\n`. --- bin/debops-api | 1 + tests/api_data/v0/roles/debops.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/debops-api b/bin/debops-api index 73f12ad..315bcf4 100755 --- a/bin/debops-api +++ b/bin/debops-api @@ -503,6 +503,7 @@ class DebOpsAPI: outfile.write('\n'.join(sorted(role_list)) + '\n') with open(os.path.join(api_work_dir, 'roles', role_owner + '.json'), 'w') as outfile: json.dump(self.get_metadata(metadata), outfile, sort_keys=True) + outfile.write('\n') with open(os.path.join(api_work_dir, 'roles', 'count:' + role_owner), 'w') as outfile: outfile.write('{}\n'.format(len(self.get_metadata(metadata).keys()))) diff --git a/tests/api_data/v0/roles/debops.json b/tests/api_data/v0/roles/debops.json index 85af400..2227c4a 100644 --- a/tests/api_data/v0/roles/debops.json +++ b/tests/api_data/v0/roles/debops.json @@ -1 +1 @@ -{"debops.ansible": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-role-ansible.png", "ci_url": "https://travis-ci.org/debops/ansible-role-ansible", "clone_url": "https://github.com/debops/ansible-role-ansible.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/ansible", "issue_url": "https://github.com/debops/ansible-role-ansible/issues", "normalized_role_name": "role-ansible", "pr_url": "https://github.com/debops/ansible-role-ansible/pulls", "role_name": "ansible", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-role-ansible", "vcs_url": "https://github.com/debops/ansible-role-ansible"}, "debops.unattended_upgrades": {"authors": [{"name": "Maciej Delmanowski", "nick": "drybjed"}, {"name": "Robin Schneider", "nick": "ypid"}], "ci_badge_url": "https://api.travis-ci.org/debops/ansible-unattended_upgrades.png", "ci_url": "https://travis-ci.org/debops/ansible-unattended_upgrades", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "description": "Configure unattended upgrades on Debian-based hosts", "docs_format_version": "0.2.0", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "galaxy_url": "https://galaxy.ansible.com/debops/unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "license": "GPL-3.0", "min_ansible_version": "2.0.0", "normalized_role_name": "unattended_upgrades", "platforms": [{"name": "Ubuntu", "versions": ["precise", "quantal", "raring", "saucy", "trusty"]}, {"name": "Debian", "versions": ["wheezy", "jessie"]}], "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "role_name": "unattended_upgrades", "role_owner": "debops", "tags": ["apt", "system", "security"], "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-unattended_upgrades", "vcs_last_committer_date": "1970-01-01 00:00:00 +0000", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades", "version": "0.0.0"}, "debops.users": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-users.png", "ci_url": "https://travis-ci.org/debops/ansible-users", "clone_url": "https://github.com/debops/ansible-users.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/users", "issue_url": "https://github.com/debops/ansible-users/issues", "normalized_role_name": "users", "pr_url": "https://github.com/debops/ansible-users/pulls", "role_name": "users", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-users", "vcs_url": "https://github.com/debops/ansible-users"}} \ No newline at end of file +{"debops.ansible": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-role-ansible.png", "ci_url": "https://travis-ci.org/debops/ansible-role-ansible", "clone_url": "https://github.com/debops/ansible-role-ansible.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/ansible", "issue_url": "https://github.com/debops/ansible-role-ansible/issues", "normalized_role_name": "role-ansible", "pr_url": "https://github.com/debops/ansible-role-ansible/pulls", "role_name": "ansible", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-role-ansible", "vcs_url": "https://github.com/debops/ansible-role-ansible"}, "debops.unattended_upgrades": {"authors": [{"name": "Maciej Delmanowski", "nick": "drybjed"}, {"name": "Robin Schneider", "nick": "ypid"}], "ci_badge_url": "https://api.travis-ci.org/debops/ansible-unattended_upgrades.png", "ci_url": "https://travis-ci.org/debops/ansible-unattended_upgrades", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "description": "Configure unattended upgrades on Debian-based hosts", "docs_format_version": "0.2.0", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "galaxy_url": "https://galaxy.ansible.com/debops/unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "license": "GPL-3.0", "min_ansible_version": "2.0.0", "normalized_role_name": "unattended_upgrades", "platforms": [{"name": "Ubuntu", "versions": ["precise", "quantal", "raring", "saucy", "trusty"]}, {"name": "Debian", "versions": ["wheezy", "jessie"]}], "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "role_name": "unattended_upgrades", "role_owner": "debops", "tags": ["apt", "system", "security"], "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-unattended_upgrades", "vcs_last_committer_date": "1970-01-01 00:00:00 +0000", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades", "version": "0.0.0"}, "debops.users": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-users.png", "ci_url": "https://travis-ci.org/debops/ansible-users", "clone_url": "https://github.com/debops/ansible-users.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/users", "issue_url": "https://github.com/debops/ansible-users/issues", "normalized_role_name": "users", "pr_url": "https://github.com/debops/ansible-users/pulls", "role_name": "users", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-users", "vcs_url": "https://github.com/debops/ansible-users"}} From fa27cc7b5c6b64c4363a23a6e68e2911ab7bd7bd Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Mon, 18 Jul 2016 17:03:57 +0200 Subject: [PATCH 5/7] Renamed `docs_format_version` to `role_format_version`. --- bin/debops-api | 16 ++++++++-------- .../api/role/debops.unattended_upgrades.json | 2 +- docs/_static/api/roles/debops.json | 2 +- docs/api-reference-v0.rst | 7 ++++--- tests/api_data/v0/role/debops.ansible.json | 2 +- .../v0/role/debops.unattended_upgrades.json | 2 +- tests/api_data/v0/role/debops.users.json | 2 +- tests/api_data/v0/roles/debops.json | 2 +- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/bin/debops-api b/bin/debops-api index 315bcf4..dafda46 100755 --- a/bin/debops-api +++ b/bin/debops-api @@ -117,7 +117,7 @@ class DebOpsAPI: 'role_owner': role_owner, 'role_name': role_name, 'vcs_url': repo['html_url'], - 'docs_format_version': '0.1.0', + 'role_format_version': '0.1.0', } self._metadata.setdefault(role_full_name, {}) self._metadata[role_full_name].update(metadata_from_api) @@ -144,7 +144,7 @@ class DebOpsAPI: '0.2.0': re.compile(r'^ansible-(?P[a-z0-9_-]+)$'), } - for docs_format_version, pattern in version_by_pattern_map.items(): + for role_format_version, pattern in version_by_pattern_map.items(): _re = pattern.search(role_dir_name) if _re: role_owner = None @@ -152,13 +152,13 @@ class DebOpsAPI: role_owner = _re.group('role_owner') role_name = _re.group('role_name') logger.debug('Detected docs format version {} for owner: {}, name: {} from {}'.format( - docs_format_version, + role_format_version, role_owner, role_name, role_dir_name, )) return { - 'docs_format_version': docs_format_version, + 'role_format_version': role_format_version, 'role_owner': role_owner, 'role_name': role_name, } @@ -345,7 +345,7 @@ class DebOpsAPI: }) if self._docs_url_pattern and StrictVersion('0.2.0') <= \ - StrictVersion(metadata['docs_format_version']): + StrictVersion(metadata['role_format_version']): additonal_metadata['docs_url'] = self._docs_url_pattern.format( role_owner=role_owner, @@ -367,7 +367,7 @@ class DebOpsAPI: # required to get the meta data from external servers (and to # encourage conversion to the new docs format). if role_dir_info: - if StrictVersion('0.2.0') <= StrictVersion(role_dir_info['docs_format_version']): + if StrictVersion('0.2.0') <= StrictVersion(role_dir_info['role_format_version']): role_name = role_dir_info['role_name'] role_metadata = self._get_role_metadata(os.path.join(role_path, role_dir_name)) role_vcs_url = role_metadata['ansigenome']['github_url'] @@ -380,7 +380,7 @@ class DebOpsAPI: 'vcs_url': role_vcs_url, 'vcs_last_committer_date': vcs_info['last_committer_date'], 'version': vcs_info['version'], - 'docs_format_version': role_dir_info['docs_format_version'], + 'role_format_version': role_dir_info['role_format_version'], 'role_owner': role_owner, 'role_name': role_name, } @@ -409,7 +409,7 @@ class DebOpsAPI: metadata = { 'vcs_url': role_vcs_url, - 'docs_format_version': '0.1.0', + 'role_format_version': '0.1.0', 'role_owner': role_owner, 'role_name': role_name, } diff --git a/docs/_static/api/role/debops.unattended_upgrades.json b/docs/_static/api/role/debops.unattended_upgrades.json index ee98760..d6a0b0c 100644 --- a/docs/_static/api/role/debops.unattended_upgrades.json +++ b/docs/_static/api/role/debops.unattended_upgrades.json @@ -1 +1 @@ -{"role_owner": "debops", "role_name": "unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "vcs_last_committer_date": "2016-07-10 21:50:38 +0200", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "version": "0.2.0", "docs_format_version": "0.2.0", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades"} +{"role_owner": "debops", "role_name": "unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "vcs_last_committer_date": "2016-07-10 21:50:38 +0200", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "version": "0.2.0", "role_format_version": "0.2.0", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades"} diff --git a/docs/_static/api/roles/debops.json b/docs/_static/api/roles/debops.json index c3f360c..d713f1d 100644 --- a/docs/_static/api/roles/debops.json +++ b/docs/_static/api/roles/debops.json @@ -1 +1 @@ -{"debops.unattended_upgrades": {"role_owner": "debops", "role_name": "unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "vcs_last_committer_date": "2016-07-10 21:50:38 +0200", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "version": "0.2.0", "docs_format_version": "0.2.0", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades"}} \ No newline at end of file +{"debops.unattended_upgrades": {"role_owner": "debops", "role_name": "unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "vcs_last_committer_date": "2016-07-10 21:50:38 +0200", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "version": "0.2.0", "role_format_version": "0.2.0", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades"}} \ No newline at end of file diff --git a/docs/api-reference-v0.rst b/docs/api-reference-v0.rst index 8e71217..0d83c8c 100644 --- a/docs/api-reference-v0.rst +++ b/docs/api-reference-v0.rst @@ -66,7 +66,7 @@ described below. :regexp:`^/roles/.*\.json$` API calls return a JSON object. The outer dict is a full role name to meta data (described below) mapping. -.. note:: ``docs_format_version`` below ``0.2.0`` are not fully supported by +.. note:: ``role_format_version`` below ``0.2.0`` are not fully supported by this API. Keys might be missing for roles with this version. Do a version compare for ``0.2.0`` or higher of fixup the DebOps API. @@ -96,8 +96,9 @@ full role name to meta data (described below) mapping. ``description`` Description of the repository. -``docs_format_version`` - Version of the DebOps documentation format used for the repository. +``role_format_version`` + To which version of the DebOps role standard does the role comply to. + TODO: The versions are currently not documented elsewhere. ``docs_url`` HTML URL of the rendered documentation of the repository diff --git a/tests/api_data/v0/role/debops.ansible.json b/tests/api_data/v0/role/debops.ansible.json index d069213..42ec3db 100644 --- a/tests/api_data/v0/role/debops.ansible.json +++ b/tests/api_data/v0/role/debops.ansible.json @@ -1 +1 @@ -{"ci_badge_url": "https://api.travis-ci.org/debops/ansible-role-ansible.png", "ci_url": "https://travis-ci.org/debops/ansible-role-ansible", "clone_url": "https://github.com/debops/ansible-role-ansible.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/ansible", "issue_url": "https://github.com/debops/ansible-role-ansible/issues", "normalized_role_name": "role-ansible", "pr_url": "https://github.com/debops/ansible-role-ansible/pulls", "role_name": "ansible", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-role-ansible", "vcs_url": "https://github.com/debops/ansible-role-ansible"} +{"ci_badge_url": "https://api.travis-ci.org/debops/ansible-role-ansible.png", "ci_url": "https://travis-ci.org/debops/ansible-role-ansible", "clone_url": "https://github.com/debops/ansible-role-ansible.git", "galaxy_url": "https://galaxy.ansible.com/debops/ansible", "issue_url": "https://github.com/debops/ansible-role-ansible/issues", "normalized_role_name": "role-ansible", "pr_url": "https://github.com/debops/ansible-role-ansible/pulls", "role_format_version": "0.1.0", "role_name": "ansible", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-role-ansible", "vcs_url": "https://github.com/debops/ansible-role-ansible"} diff --git a/tests/api_data/v0/role/debops.unattended_upgrades.json b/tests/api_data/v0/role/debops.unattended_upgrades.json index 7a3e4e6..642307b 100644 --- a/tests/api_data/v0/role/debops.unattended_upgrades.json +++ b/tests/api_data/v0/role/debops.unattended_upgrades.json @@ -1 +1 @@ -{"authors": [{"name": "Maciej Delmanowski", "nick": "drybjed"}, {"name": "Robin Schneider", "nick": "ypid"}], "ci_badge_url": "https://api.travis-ci.org/debops/ansible-unattended_upgrades.png", "ci_url": "https://travis-ci.org/debops/ansible-unattended_upgrades", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "description": "Configure unattended upgrades on Debian-based hosts", "docs_format_version": "0.2.0", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "galaxy_url": "https://galaxy.ansible.com/debops/unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "license": "GPL-3.0", "min_ansible_version": "2.0.0", "normalized_role_name": "unattended_upgrades", "platforms": [{"name": "Ubuntu", "versions": ["precise", "quantal", "raring", "saucy", "trusty"]}, {"name": "Debian", "versions": ["wheezy", "jessie"]}], "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "role_name": "unattended_upgrades", "role_owner": "debops", "tags": ["apt", "system", "security"], "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-unattended_upgrades", "vcs_last_committer_date": "1970-01-01 00:00:00 +0000", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades", "version": "0.0.0"} +{"authors": [{"name": "Maciej Delmanowski", "nick": "drybjed"}, {"name": "Robin Schneider", "nick": "ypid"}], "ci_badge_url": "https://api.travis-ci.org/debops/ansible-unattended_upgrades.png", "ci_url": "https://travis-ci.org/debops/ansible-unattended_upgrades", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "description": "Configure unattended upgrades on Debian-based hosts", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "galaxy_url": "https://galaxy.ansible.com/debops/unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "license": "GPL-3.0", "min_ansible_version": "2.0.0", "normalized_role_name": "unattended_upgrades", "platforms": [{"name": "Ubuntu", "versions": ["precise", "quantal", "raring", "saucy", "trusty"]}, {"name": "Debian", "versions": ["wheezy", "jessie"]}], "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "role_format_version": "0.2.0", "role_name": "unattended_upgrades", "role_owner": "debops", "tags": ["apt", "system", "security"], "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-unattended_upgrades", "vcs_last_committer_date": "1970-01-01 00:00:00 +0000", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades", "version": "0.0.0"} diff --git a/tests/api_data/v0/role/debops.users.json b/tests/api_data/v0/role/debops.users.json index 868e755..1c6f060 100644 --- a/tests/api_data/v0/role/debops.users.json +++ b/tests/api_data/v0/role/debops.users.json @@ -1 +1 @@ -{"ci_badge_url": "https://api.travis-ci.org/debops/ansible-users.png", "ci_url": "https://travis-ci.org/debops/ansible-users", "clone_url": "https://github.com/debops/ansible-users.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/users", "issue_url": "https://github.com/debops/ansible-users/issues", "normalized_role_name": "users", "pr_url": "https://github.com/debops/ansible-users/pulls", "role_name": "users", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-users", "vcs_url": "https://github.com/debops/ansible-users"} +{"ci_badge_url": "https://api.travis-ci.org/debops/ansible-users.png", "ci_url": "https://travis-ci.org/debops/ansible-users", "clone_url": "https://github.com/debops/ansible-users.git", "galaxy_url": "https://galaxy.ansible.com/debops/users", "issue_url": "https://github.com/debops/ansible-users/issues", "normalized_role_name": "users", "pr_url": "https://github.com/debops/ansible-users/pulls", "role_format_version": "0.1.0", "role_name": "users", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-users", "vcs_url": "https://github.com/debops/ansible-users"} diff --git a/tests/api_data/v0/roles/debops.json b/tests/api_data/v0/roles/debops.json index 2227c4a..a2e12d0 100644 --- a/tests/api_data/v0/roles/debops.json +++ b/tests/api_data/v0/roles/debops.json @@ -1 +1 @@ -{"debops.ansible": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-role-ansible.png", "ci_url": "https://travis-ci.org/debops/ansible-role-ansible", "clone_url": "https://github.com/debops/ansible-role-ansible.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/ansible", "issue_url": "https://github.com/debops/ansible-role-ansible/issues", "normalized_role_name": "role-ansible", "pr_url": "https://github.com/debops/ansible-role-ansible/pulls", "role_name": "ansible", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-role-ansible", "vcs_url": "https://github.com/debops/ansible-role-ansible"}, "debops.unattended_upgrades": {"authors": [{"name": "Maciej Delmanowski", "nick": "drybjed"}, {"name": "Robin Schneider", "nick": "ypid"}], "ci_badge_url": "https://api.travis-ci.org/debops/ansible-unattended_upgrades.png", "ci_url": "https://travis-ci.org/debops/ansible-unattended_upgrades", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "description": "Configure unattended upgrades on Debian-based hosts", "docs_format_version": "0.2.0", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "galaxy_url": "https://galaxy.ansible.com/debops/unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "license": "GPL-3.0", "min_ansible_version": "2.0.0", "normalized_role_name": "unattended_upgrades", "platforms": [{"name": "Ubuntu", "versions": ["precise", "quantal", "raring", "saucy", "trusty"]}, {"name": "Debian", "versions": ["wheezy", "jessie"]}], "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "role_name": "unattended_upgrades", "role_owner": "debops", "tags": ["apt", "system", "security"], "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-unattended_upgrades", "vcs_last_committer_date": "1970-01-01 00:00:00 +0000", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades", "version": "0.0.0"}, "debops.users": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-users.png", "ci_url": "https://travis-ci.org/debops/ansible-users", "clone_url": "https://github.com/debops/ansible-users.git", "docs_format_version": "0.1.0", "galaxy_url": "https://galaxy.ansible.com/debops/users", "issue_url": "https://github.com/debops/ansible-users/issues", "normalized_role_name": "users", "pr_url": "https://github.com/debops/ansible-users/pulls", "role_name": "users", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-users", "vcs_url": "https://github.com/debops/ansible-users"}} +{"debops.ansible": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-role-ansible.png", "ci_url": "https://travis-ci.org/debops/ansible-role-ansible", "clone_url": "https://github.com/debops/ansible-role-ansible.git", "galaxy_url": "https://galaxy.ansible.com/debops/ansible", "issue_url": "https://github.com/debops/ansible-role-ansible/issues", "normalized_role_name": "role-ansible", "pr_url": "https://github.com/debops/ansible-role-ansible/pulls", "role_format_version": "0.1.0", "role_name": "ansible", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-role-ansible", "vcs_url": "https://github.com/debops/ansible-role-ansible"}, "debops.unattended_upgrades": {"authors": [{"name": "Maciej Delmanowski", "nick": "drybjed"}, {"name": "Robin Schneider", "nick": "ypid"}], "ci_badge_url": "https://api.travis-ci.org/debops/ansible-unattended_upgrades.png", "ci_url": "https://travis-ci.org/debops/ansible-unattended_upgrades", "clone_url": "https://github.com/debops/ansible-unattended_upgrades.git", "description": "Configure unattended upgrades on Debian-based hosts", "docs_url": "http://docs.debops.org/en/latest/ansible/roles/ansible-unattended_upgrades/docs/index.html", "galaxy_url": "https://galaxy.ansible.com/debops/unattended_upgrades", "issue_url": "https://github.com/debops/ansible-unattended_upgrades/issues", "license": "GPL-3.0", "min_ansible_version": "2.0.0", "normalized_role_name": "unattended_upgrades", "platforms": [{"name": "Ubuntu", "versions": ["precise", "quantal", "raring", "saucy", "trusty"]}, {"name": "Debian", "versions": ["wheezy", "jessie"]}], "pr_url": "https://github.com/debops/ansible-unattended_upgrades/pulls", "role_format_version": "0.2.0", "role_name": "unattended_upgrades", "role_owner": "debops", "tags": ["apt", "system", "security"], "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-unattended_upgrades", "vcs_last_committer_date": "1970-01-01 00:00:00 +0000", "vcs_url": "https://github.com/debops/ansible-unattended_upgrades", "version": "0.0.0"}, "debops.users": {"ci_badge_url": "https://api.travis-ci.org/debops/ansible-users.png", "ci_url": "https://travis-ci.org/debops/ansible-users", "clone_url": "https://github.com/debops/ansible-users.git", "galaxy_url": "https://galaxy.ansible.com/debops/users", "issue_url": "https://github.com/debops/ansible-users/issues", "normalized_role_name": "users", "pr_url": "https://github.com/debops/ansible-users/pulls", "role_format_version": "0.1.0", "role_name": "users", "role_owner": "debops", "test_suite_url": "https://github.com/debops/test-suite/tree/master/ansible-users", "vcs_url": "https://github.com/debops/ansible-users"}} From d2e8ae04c0c5fa678a03e7a5098f7583abc504d2 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Mon, 18 Jul 2016 18:14:49 +0200 Subject: [PATCH 6/7] Added debops/docs to the example usage section of the API. --- docs/introduction.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/introduction.rst b/docs/introduction.rst index eb69a18..4b1a3b5 100644 --- a/docs/introduction.rst +++ b/docs/introduction.rst @@ -9,7 +9,8 @@ API URL: https://api.debops.org/ Example usages -------------- -* https://github.com/debops/debops.github.io/ +* https://github.com/debops/debops.github.io +* https://github.com/debops/docs .. Local Variables: From edde00737d8c70ec3b54c702d090ceb2a8af39d1 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Mon, 18 Jul 2016 18:45:14 +0200 Subject: [PATCH 7/7] Add API role data `vcs_commits_since_last_release`. --- bin/debops-api | 32 ++++++++++++++++++++++---------- docs/api-reference-v0.rst | 11 ++++++++--- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/bin/debops-api b/bin/debops-api index dafda46..4061eb8 100755 --- a/bin/debops-api +++ b/bin/debops-api @@ -217,18 +217,30 @@ class DebOpsAPI: # except git.exc.GitCommandError: version = '0.0.0' - version = re.sub(r'^v', '', version) - # logger.debug(version) - if self._test_mode: # Fake committer date in test mode last_committer_date = '1970-01-01 00:00:00 +0000' - return { - 'last_committer_date': last_committer_date, - 'version': version, + metadata = { + 'vcs_last_committer_date': last_committer_date, + 'version': re.sub(r'^v', '', version), } + if not self._test_mode and version != '0.0.0': + try: + commits_since_last_release = len( + g.log('{}...HEAD'.format(version), '--oneline').split('\n') + ) + except: + commits_since_last_release = None + + if commits_since_last_release is not None: + metadata.update({ + 'vcs_commits_since_last_release': commits_since_last_release, + }) + + return metadata + def _get_role_metadata(self, role_path): """ Read metadata for the given role. @@ -374,17 +386,17 @@ class DebOpsAPI: role_owner = self._get_owner_from_vcs_url(role_vcs_url) role_full_name = self._get_role_full_name(role_owner, role_name) - vcs_info = self._get_vcs_info(os.path.join(role_path, role_dir_name)) - metadata = { 'vcs_url': role_vcs_url, - 'vcs_last_committer_date': vcs_info['last_committer_date'], - 'version': vcs_info['version'], 'role_format_version': role_dir_info['role_format_version'], 'role_owner': role_owner, 'role_name': role_name, } + metadata.update( + self._get_vcs_info(os.path.join(role_path, role_dir_name)) + ) + if 'meta' in role_metadata: metadata.update( self._get_normalized_meta_main(role_metadata['meta']) diff --git a/docs/api-reference-v0.rst b/docs/api-reference-v0.rst index 0d83c8c..217f671 100644 --- a/docs/api-reference-v0.rst +++ b/docs/api-reference-v0.rst @@ -135,11 +135,16 @@ full role name to meta data (described below) mapping. HTML URL for the test page of the continues integration system which is used for the repository. -``vcs_last_committer_date`` - Date of last commit in VCS. - ``vcs_url`` HTML URL to the VCS platform where the repository is hosted. ``version`` Latest released version of the repository. + Is ``0.0.0`` when no release has been made. + +``vcs_commits_since_last_release`` + Number of commits since the last release. + Is missing when no release has been made. + +``vcs_last_committer_date`` + Date of last commit in VCS.