Skip to content

Commit

Permalink
scripts: make metalk8s archives pillar accessible globally
Browse files Browse the repository at this point in the history
Also ensure that archive names are not splitted on
space which was not the case.

Refs: #3079
  • Loading branch information
alexandre-allard committed Feb 3, 2021
1 parent 8c8bb82 commit 75b9774
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/iso-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ _usage() {
}

ARCHIVES=()
CONFIGURED_ARCHIVES=()

while (( "$#" )); do
case "$1" in
Expand Down Expand Up @@ -79,6 +80,11 @@ _set_env() {
fi
}

get_configured_archives() {
salt-call pillar.get metalk8s:archives --out yaml |
sed -rn 's/^- (.+)$/\1/p'
}

_add_archives() {
# Skip adding archive if None passed
[ $# -lt 1 ] && return 0
Expand All @@ -87,9 +93,7 @@ _add_archives() {
# local: ["/srv/scality/metalk8s-2.0.0/", "/tmp/metalk8s-2.1.0.iso"]
# parsed archives:
# ("/srv/scality/metalk8s-2.0.0/" "/tmp/metalk8s-2.1.0.iso")
IFS=" " read -r -a \
archives <<< "$(salt-call pillar.get metalk8s:archives \
--out txt | cut -d' ' -f2- | tr -d '[],')"
local -a archives=("${CONFIGURED_ARCHIVES[@]}")
for archive in "$@"; do
if ! contains "$archive" "${archives[@]}"; then
archives+=("'$archive'")
Expand Down Expand Up @@ -146,5 +150,6 @@ _configure_archives() {
_set_env
[ -z "$SALTENV" ] && die "saltenv not set"

mapfile -t CONFIGURED_ARCHIVES < <(get_configured_archives)
run "Add archives" _add_archives ${ARCHIVES[@]+"${ARCHIVES[@]}"}
run "Configure archives" _configure_archives

0 comments on commit 75b9774

Please sign in to comment.