2 # ============LICENSE_START=======================================================
3 # Copyright (c)2020 AT&T Intellectual Property. All rights reserved.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 # ============LICENSE_END=========================================================
18 # Use the Nexus API to get a list of all the plugins/typefiles currently in Nexus
19 # under a specified root directory, passed as the first argument to the script
20 # We assume the repo structure that the build process uses:
21 # PLUGIN_ROOT/<plugin_name>/<version>/<wagon_name>.wgn
22 # PLUGIN_ROOT/<plugin_name>/<version>/<type_file_name>.yaml
24 # This code could be used as the basis for an alternative to the existing
25 # 'get-plugins.sh' script. Instead of pulling a hard-coded list of plugins and
26 # type files from Nexus, it would pull all of the plugins and type files, in all
27 # available versions, from the Nexus repo.
29 # At the very least, it is a useful tool for finding out what plugins and
30 # type files have been loaded into the Nexus repo and are therefore available
31 # to be included in the hard-coded list.
33 shopt -s expand_aliases
35 alias cu='curl -Ss -H "Accept: application/json" -L -f'
36 PLUGIN_ROOT=${1:-"https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R7/"}
38 function getPlugins() {
40 # Get URLs for all of the plugins under the plugin root directory
41 local PLUGINS=$(cu $root | jq .data[].resourceURI | sed -e 's/"//g')
43 # Go into each plugin directory
46 # Get the available versions of the plugin
47 local VERSIONS=$(cu $p | jq .data[].resourceURI | sed -e 's/"//g')
49 # Get wagon and type file for each version
52 local RESOURCES=$(cu $v | jq .data[].relativePath)
53 # RESOURCES will have a list of everything in the version directory, including many timestamped
54 # wagons and type files, and some zip files as well. For each version, there should be a single
55 # non-time-stamped .wgn and a single non-timestamped .yaml file. We try to pull these from the
56 # from the list using grep, and then we reformat the results to remove quote marks and to remove
57 # the first two levels of the relative path.
58 # Just in case we're wrong about how many non-timestamped .wgn and .yaml files are in each directory,
59 # we treat the result of the grep as an array and we take the first element only.
60 local w=($((for r in $RESOURCES; do echo $r; done) | grep ".wgn\"" | tr -d '"' | sed -e 's#^/[^/]*/[^/]*##'))
61 local t=($((for r in $RESOURCES; do echo $r; done) | grep ".yaml\"" | tr -d '"' | sed -e 's#^/[^/]*/[^/]*##'))
62 echo "${w[0]}|${t[0]}"
63 # We could potentially fetch the plugin wagon file and the type file here. Probably wouldn't need
64 # to have this code as a function in that case. Also, probably should the .resourceURI (the full URL
65 # of each file) rather than .relativePath, and not strip off any part of the path (the 'sed' operation
66 # would not be needed.)
71 for p in $(getPlugins $PLUGIN_ROOT | sort)