Support building an allow-list of providers (#527)

* Add providers subcommand to verify providers

Allows users to check what providers are available

* Fix version output to add new line

This command was totally broken until we moved around the call to
`initConfig()`, this just fixes the output now that it works.

* Flip boolean of provider include tags

All providers are still included by default and fix tags using the old
format.
This commit is contained in:
Brian Goff
2019-03-02 11:25:47 -08:00
committed by GitHub
parent a5d7400232
commit f8c51004d4
17 changed files with 162 additions and 25 deletions

56
scripts/process_build_tags.sh Executable file
View File

@@ -0,0 +1,56 @@
#!/bin/bash
# set -e -o pipefail
orig_tags=(${@})
new_tags=()
omit_providers=()
let found_provider=0
function debug() {
if [ "${V}" = "1" ]; then
(>&2 echo "$@")
fi
}
for tag in ${orig_tags[@]}; do
case "${tag}" in
no_*_provider)
# filtered
debug "filtered old, invalid ${tag} from tag list, provider is already excluded"
# store just in case no "proper" provider tags were provided
# In such cases we'd build everything, but we don't want to build these
p="${tag#no_}"
p="${p%_*}"
omit_providers+=("${p}")
;;
*_provider)
found_provider+=1
new_tags+=("${tag}")
;;
*)
new_tags+=("${tag}")
;;
esac
done
if [ ${found_provider} -eq 0 ]; then
# include all providers
for i in $(ls providers/register/provider_*.go); do
p="${i#*provider_}"
p="${p%.*}"
if [[ ! "${omit_providers[*]}" =~ "${p}" ]]; then
debug "including provider ${p}"
new_tags+=("${p}_provider")
else
debug "excluding provider ${p}"
fi
done
fi
echo "${new_tags[@]}"