blob: b27b23ab718e353524e3d526b7c72181cf5ca0a0 [file] [log] [blame]
Masayuki Igawae1a50832017-04-11 16:24:00 +09001#!/usr/bin/env bash
Clint Adamsa4136522016-03-10 20:24:34 -05002
3# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16
17# This script is intended to be run as a periodic proposal bot job
18# in OpenStack infrastructure, though you can run it as a one-off.
19#
20# In order to function correctly, the environment in which the
21# script runs must have
22# * a writable doc/source directory relative to the current
23# working directory
24# AND ( (
25# * git
26# * all git repos meant to be searched for plugins cloned and
27# at the desired level of up-to-datedness
28# * the environment variable git_dir pointing to the location
29# * of said git repositories
30# ) OR (
31# * network access to the review.openstack.org Gerrit API
32# working directory
33# * network access to https://git.openstack.org/cgit
34# ))
35#
Masayuki Igawa6d5a48c2017-09-06 18:31:57 +090036# If a file named doc/source/data/tempest-plugins-registry.header or
37# doc/source/data/tempest-plugins-registry.footer is found relative to the
Clint Adamsa4136522016-03-10 20:24:34 -050038# current working directory, it will be prepended or appended to
39# the generated reStructuredText plugins table respectively.
40
Masayuki Igawae1a50832017-04-11 16:24:00 +090041set -ex
42
Clint Adamsa4136522016-03-10 20:24:34 -050043(
44declare -A plugins
45
Masayuki Igawa6d5a48c2017-09-06 18:31:57 +090046if [[ -r doc/source/data/tempest-plugins-registry.header ]]; then
47 cat doc/source/data/tempest-plugins-registry.header
Clint Adamsa4136522016-03-10 20:24:34 -050048fi
49
50sorted_plugins=$(python tools/generate-tempest-plugins-list.py)
51
ghanshyamdf037312018-07-27 09:31:16 +000052name_col_len=$(echo "${sorted_plugins}" | wc -L)
akhiljain23a2260de2018-07-26 18:23:36 +053053name_col_len=$(( name_col_len + 20 ))
ghanshyamdf037312018-07-27 09:31:16 +000054
55# Print the title underline for a RST table.
56function title_underline {
57 printf "== "
58 local len=$1
59 while [[ $len -gt 0 ]]; do
60 printf "="
61 len=$(( len - 1))
62 done
63 printf " ===\n"
64}
65
66printf "\n\n"
67title_underline ${name_col_len}
68printf "%-3s %-${name_col_len}s %s\n" "SR" "Plugin Name" "URL"
69title_underline ${name_col_len}
70
71i=0
akhiljain23a2260de2018-07-26 18:23:36 +053072for plugin in ${sorted_plugins}; do
ghanshyamdf037312018-07-27 09:31:16 +000073 i=$((i+1))
akhiljain23a2260de2018-07-26 18:23:36 +053074 giturl="git://git.openstack.org/openstack/${plugin}"
75 gitlink="https://git.openstack.org/cgit/openstack/${plugin}"
76 printf "%-3s %-${name_col_len}s %s\n" "$i" "${plugin}" "\`${giturl} <${gitlink}>\`__"
Clint Adamsa4136522016-03-10 20:24:34 -050077done
78
ghanshyamdf037312018-07-27 09:31:16 +000079title_underline ${name_col_len}
80
81printf "\n\n"
82
Masayuki Igawa6d5a48c2017-09-06 18:31:57 +090083if [[ -r doc/source/data/tempest-plugins-registry.footer ]]; then
84 cat doc/source/data/tempest-plugins-registry.footer
Clint Adamsa4136522016-03-10 20:24:34 -050085fi
86) > doc/source/plugin-registry.rst
87
88if [[ -n ${1} ]]; then
89 cp doc/source/plugin-registry.rst ${1}/doc/source/plugin-registry.rst
90fi