diff --git a/data/devstack-plugins-registry.header b/data/devstack-plugins-registry.header index 46d5e60749..f105fe9d35 100644 --- a/data/devstack-plugins-registry.header +++ b/data/devstack-plugins-registry.header @@ -18,7 +18,3 @@ Detected Plugins The following are plugins that a script has found in the openstack/ namespace, which includes but is not limited to official OpenStack projects. - -+----------------------------+-------------------------------------------------------------------------+ -|Plugin Name |URL | -+----------------------------+-------------------------------------------------------------------------+ diff --git a/tools/generate-devstack-plugins-list.py b/tools/generate-devstack-plugins-list.py index 1fa550192e..aeec4dd27d 100644 --- a/tools/generate-devstack-plugins-list.py +++ b/tools/generate-devstack-plugins-list.py @@ -23,9 +23,12 @@ # working directory # * network access to https://git.openstack.org/cgit +import logging import json import requests +logging.basicConfig(level=logging.DEBUG) + url = 'https://review.openstack.org/projects/' # This is what a project looks like @@ -37,6 +40,8 @@ url = 'https://review.openstack.org/projects/' ''' def is_in_openstack_namespace(proj): + # only interested in openstack namespace (e.g. not retired + # stackforge, etc) return proj.startswith('openstack/') # Rather than returning a 404 for a nonexistent file, cgit delivers a @@ -50,10 +55,13 @@ def has_devstack_plugin(proj): else: False +logging.debug("Getting project list from %s" % url) r = requests.get(url) projects = sorted(filter(is_in_openstack_namespace, json.loads(r.text[4:]))) +logging.debug("Found %d projects" % len(projects)) found_plugins = filter(has_devstack_plugin, projects) for project in found_plugins: + # strip of openstack/ print project[10:] diff --git a/tools/generate-devstack-plugins-list.sh b/tools/generate-devstack-plugins-list.sh index be3f60a136..82486f5b2d 100644 --- a/tools/generate-devstack-plugins-list.sh +++ b/tools/generate-devstack-plugins-list.sh @@ -38,6 +38,17 @@ # current working directory, it will be prepended or appended to # the generated reStructuredText plugins table respectively. +# Print the title underline for a RST table. Argument is the length +# of the first column, second column is assumed to be "URL" +function title_underline { + local len=$1 + while [[ $len -gt 0 ]]; do + printf "=" + len=$(( len - 1)) + done + printf " ===\n" +} + ( declare -A plugins @@ -47,11 +58,24 @@ fi sorted_plugins=$(python tools/generate-devstack-plugins-list.py) -for k in ${sorted_plugins}; do - project=${k:0:28} - giturl="git://git.openstack.org/openstack/${k:0:26}" - printf "|%-28s|%-73s|\n" "${project}" "${giturl}" - printf "+----------------------------+-------------------------------------------------------------------------+\n" +# find the length of the name column & pad +name_col_len=$(echo "${sorted_plugins}" | wc -L) +name_col_len=$(( name_col_len + 2 )) + +# ====================== === +# Plugin Name URL +# ====================== === +# foobar `git://... `__ +# ... + +title_underline ${name_col_len} +printf "%-${name_col_len}s %s\n" "Plugin Name" "URL" +title_underline ${name_col_len} + +for plugin in ${sorted_plugins}; do + giturl="git://git.openstack.org/openstack/${plugin}" + gitlink="https://git.openstack.org/cgit/openstack/${plugin}" + printf "%-${name_col_len}s %s\n" "${p}" "\`${giturl} <${gitlink}>\`__" done if [[ -r data/devstack-plugins-registry.footer ]]; then