| Clint Adams | 4fd874b | 2016-01-19 18:17:49 -0500 | [diff] [blame] | 1 | #!/bin/bash -ex | 
 | 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 | 
| Clint Adams | e3e8051 | 2016-02-18 14:46:35 -0500 | [diff] [blame] | 22 | #   * a writable doc/source directory relative to the current | 
 | 23 | #     working directory | 
 | 24 | #   AND ( ( | 
| Clint Adams | 4fd874b | 2016-01-19 18:17:49 -0500 | [diff] [blame] | 25 | #   * git | 
 | 26 | #   * all git repos meant to be searched for plugins cloned and | 
 | 27 | #     at the desired level of up-to-datedness | 
| Clint Adams | e3e8051 | 2016-02-18 14:46:35 -0500 | [diff] [blame] | 28 | #   * the environment variable git_dir pointing to the location | 
 | 29 | #   * of said git repositories | 
 | 30 | #   ) OR ( | 
| Ian Wienand | d5634c4 | 2019-06-04 17:30:13 +1000 | [diff] [blame] | 31 | #   * network access to the review.opendev.org Gerrit API | 
| Clint Adams | 4fd874b | 2016-01-19 18:17:49 -0500 | [diff] [blame] | 32 | #     working directory | 
| Ian Wienand | d5634c4 | 2019-06-04 17:30:13 +1000 | [diff] [blame] | 33 | #   * network access to https://opendev.org | 
| Clint Adams | e3e8051 | 2016-02-18 14:46:35 -0500 | [diff] [blame] | 34 | #   )) | 
| Clint Adams | 4fd874b | 2016-01-19 18:17:49 -0500 | [diff] [blame] | 35 | # | 
 | 36 | # If a file named data/devstack-plugins-registry.header or | 
 | 37 | # data/devstack-plugins-registry.footer is found relative to the | 
 | 38 | # current working directory, it will be prepended or appended to | 
 | 39 | # the generated reStructuredText plugins table respectively. | 
 | 40 |  | 
| Ian Wienand | c10989b | 2016-03-21 13:03:34 +1100 | [diff] [blame] | 41 | # Print the title underline for a RST table.  Argument is the length | 
 | 42 | # of the first column, second column is assumed to be "URL" | 
 | 43 | function title_underline { | 
 | 44 |     local len=$1 | 
 | 45 |     while [[ $len -gt 0 ]]; do | 
 | 46 |         printf "=" | 
 | 47 |         len=$(( len - 1)) | 
 | 48 |     done | 
 | 49 |     printf " ===\n" | 
 | 50 | } | 
 | 51 |  | 
| Clint Adams | 4fd874b | 2016-01-19 18:17:49 -0500 | [diff] [blame] | 52 | ( | 
| Clint Adams | f3b6feb | 2016-03-07 01:52:35 -0500 | [diff] [blame] | 53 | if [[ -r data/devstack-plugins-registry.header ]]; then | 
 | 54 |     cat data/devstack-plugins-registry.header | 
 | 55 | fi | 
| Clint Adams | 4fd874b | 2016-01-19 18:17:49 -0500 | [diff] [blame] | 56 |  | 
| Jens Harbott | 04fdd8c | 2020-08-02 13:13:00 +0200 | [diff] [blame] | 57 | sorted_plugins=$(python3 tools/generate-devstack-plugins-list.py) | 
| Clint Adams | 4fd874b | 2016-01-19 18:17:49 -0500 | [diff] [blame] | 58 |  | 
| Ian Wienand | c10989b | 2016-03-21 13:03:34 +1100 | [diff] [blame] | 59 | # find the length of the name column & pad | 
 | 60 | name_col_len=$(echo "${sorted_plugins}" | wc -L) | 
 | 61 | name_col_len=$(( name_col_len + 2 )) | 
 | 62 |  | 
 | 63 | # ====================== === | 
 | 64 | # Plugin Name            URL | 
 | 65 | # ====================== === | 
| Ian Wienand | 6509fd3 | 2019-03-04 17:26:20 +1100 | [diff] [blame] | 66 | # foobar                 `https://... <https://...>`__ | 
| Ian Wienand | c10989b | 2016-03-21 13:03:34 +1100 | [diff] [blame] | 67 | # ... | 
 | 68 |  | 
| Ian Wienand | 17e4501 | 2016-04-06 09:27:56 +1000 | [diff] [blame] | 69 | printf "\n\n" | 
| Ian Wienand | c10989b | 2016-03-21 13:03:34 +1100 | [diff] [blame] | 70 | title_underline ${name_col_len} | 
 | 71 | printf "%-${name_col_len}s %s\n" "Plugin Name" "URL" | 
 | 72 | title_underline ${name_col_len} | 
 | 73 |  | 
 | 74 | for plugin in ${sorted_plugins}; do | 
| Ian Wienand | d5634c4 | 2019-06-04 17:30:13 +1000 | [diff] [blame] | 75 |     giturl="https://opendev.org/${plugin}" | 
 | 76 |     gitlink="https://opendev.org/${plugin}" | 
| Clint Adams | 930bc43 | 2016-04-02 15:11:45 -0400 | [diff] [blame] | 77 |     printf "%-${name_col_len}s %s\n" "${plugin}" "\`${giturl} <${gitlink}>\`__" | 
| Clint Adams | 8ce3faf | 2016-02-26 08:18:13 -0700 | [diff] [blame] | 78 | done | 
| Ian Wienand | e982073 | 2016-04-08 09:10:55 +1000 | [diff] [blame] | 79 |  | 
 | 80 | title_underline ${name_col_len} | 
 | 81 |  | 
| Ian Wienand | 17e4501 | 2016-04-06 09:27:56 +1000 | [diff] [blame] | 82 | printf "\n\n" | 
| Clint Adams | 4fd874b | 2016-01-19 18:17:49 -0500 | [diff] [blame] | 83 |  | 
| Clint Adams | f3b6feb | 2016-03-07 01:52:35 -0500 | [diff] [blame] | 84 | if [[ -r data/devstack-plugins-registry.footer ]]; then | 
 | 85 |     cat data/devstack-plugins-registry.footer | 
 | 86 | fi | 
| Clint Adams | 4fd874b | 2016-01-19 18:17:49 -0500 | [diff] [blame] | 87 | ) > doc/source/plugin-registry.rst | 
| Clint Adams | e6f0d8c | 2016-02-26 08:25:32 -0700 | [diff] [blame] | 88 |  | 
 | 89 | if [[ -n ${1} ]]; then | 
 | 90 |     cp doc/source/plugin-registry.rst ${1}/doc/source/plugin-registry.rst | 
 | 91 | fi |