Masayuki Igawa | e1a5083 | 2017-04-11 16:24:00 +0900 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 2 | |
| 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 ( |
caoyuan | 349ba75 | 2019-04-23 19:40:06 +0800 | [diff] [blame] | 31 | # * network access to the review.opendev.org Gerrit API |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 32 | # working directory |
caoyuan | 349ba75 | 2019-04-23 19:40:06 +0800 | [diff] [blame] | 33 | # * network access to https://opendev.org/openstack |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 34 | # )) |
| 35 | # |
Masayuki Igawa | 6d5a48c | 2017-09-06 18:31:57 +0900 | [diff] [blame] | 36 | # 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 Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 38 | # current working directory, it will be prepended or appended to |
| 39 | # the generated reStructuredText plugins table respectively. |
| 40 | |
Masayuki Igawa | e1a5083 | 2017-04-11 16:24:00 +0900 | [diff] [blame] | 41 | set -ex |
| 42 | |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 43 | ( |
Masayuki Igawa | 6d5a48c | 2017-09-06 18:31:57 +0900 | [diff] [blame] | 44 | if [[ -r doc/source/data/tempest-plugins-registry.header ]]; then |
| 45 | cat doc/source/data/tempest-plugins-registry.header |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 46 | fi |
| 47 | |
| 48 | sorted_plugins=$(python tools/generate-tempest-plugins-list.py) |
| 49 | |
ghanshyam | df03731 | 2018-07-27 09:31:16 +0000 | [diff] [blame] | 50 | name_col_len=$(echo "${sorted_plugins}" | wc -L) |
akhiljain23 | a2260de | 2018-07-26 18:23:36 +0530 | [diff] [blame] | 51 | name_col_len=$(( name_col_len + 20 )) |
ghanshyam | df03731 | 2018-07-27 09:31:16 +0000 | [diff] [blame] | 52 | |
| 53 | # Print the title underline for a RST table. |
| 54 | function title_underline { |
| 55 | printf "== " |
| 56 | local len=$1 |
| 57 | while [[ $len -gt 0 ]]; do |
| 58 | printf "=" |
| 59 | len=$(( len - 1)) |
| 60 | done |
| 61 | printf " ===\n" |
| 62 | } |
| 63 | |
Masayuki Igawa | de1153b | 2019-07-30 18:02:07 +0900 | [diff] [blame] | 64 | function print_plugin_table { |
Masayuki Igawa | ac8ae64 | 2019-05-23 11:39:02 +0200 | [diff] [blame] | 65 | title_underline ${name_col_len} |
| 66 | printf "%-3s %-${name_col_len}s %s\n" "SR" "Plugin Name" "URL" |
| 67 | title_underline ${name_col_len} |
| 68 | |
| 69 | i=0 |
| 70 | for plugin in $1; do |
| 71 | i=$((i+1)) |
saswati | 61f03b7 | 2019-08-15 08:44:30 +0800 | [diff] [blame] | 72 | giturl="https://opendev.org/${plugin}" |
Masayuki Igawa | ac8ae64 | 2019-05-23 11:39:02 +0200 | [diff] [blame] | 73 | printf "%-3s %-${name_col_len}s %s\n" "$i" "${plugin}" "${giturl}" |
| 74 | done |
| 75 | |
| 76 | title_underline ${name_col_len} |
| 77 | } |
| 78 | |
ghanshyam | df03731 | 2018-07-27 09:31:16 +0000 | [diff] [blame] | 79 | printf "\n\n" |
Masayuki Igawa | ac8ae64 | 2019-05-23 11:39:02 +0200 | [diff] [blame] | 80 | print_plugin_table "${sorted_plugins}" |
ghanshyam | df03731 | 2018-07-27 09:31:16 +0000 | [diff] [blame] | 81 | |
Masayuki Igawa | ac8ae64 | 2019-05-23 11:39:02 +0200 | [diff] [blame] | 82 | printf "\n\n" |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 83 | |
Martin Kopec | dc84423 | 2020-12-24 15:57:53 +0000 | [diff] [blame] | 84 | # Print NON_ACTIVE_LIST |
| 85 | if [[ -r doc/source/data/tempest-non-active-plugins-registry.header ]]; then |
| 86 | cat doc/source/data/tempest-non-active-plugins-registry.header |
Masayuki Igawa | ac8ae64 | 2019-05-23 11:39:02 +0200 | [diff] [blame] | 87 | fi |
| 88 | |
Martin Kopec | dc84423 | 2020-12-24 15:57:53 +0000 | [diff] [blame] | 89 | nonactivelist=$(python tools/generate-tempest-plugins-list.py nonactivelist) |
| 90 | name_col_len=$(echo "${nonactivelist}" | wc -L) |
Masayuki Igawa | ac8ae64 | 2019-05-23 11:39:02 +0200 | [diff] [blame] | 91 | name_col_len=$(( name_col_len + 20 )) |
| 92 | |
| 93 | printf "\n\n" |
Martin Kopec | dc84423 | 2020-12-24 15:57:53 +0000 | [diff] [blame] | 94 | print_plugin_table "${nonactivelist}" |
ghanshyam | df03731 | 2018-07-27 09:31:16 +0000 | [diff] [blame] | 95 | |
| 96 | printf "\n\n" |
| 97 | |
Masayuki Igawa | 6d5a48c | 2017-09-06 18:31:57 +0900 | [diff] [blame] | 98 | if [[ -r doc/source/data/tempest-plugins-registry.footer ]]; then |
| 99 | cat doc/source/data/tempest-plugins-registry.footer |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 100 | fi |
Ghanshyam Mann | da3bb61 | 2020-05-04 20:52:01 -0500 | [diff] [blame] | 101 | ) > doc/source/plugins/plugin-registry.rst |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 102 | |
| 103 | if [[ -n ${1} ]]; then |
Ghanshyam Mann | da3bb61 | 2020-05-04 20:52:01 -0500 | [diff] [blame] | 104 | cp doc/source/plugins/plugin-registry.rst ${1}/doc/source/plugins/plugin-registry.rst |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 105 | fi |