Skip to content

Commit

Permalink
scripts: add helper function to join elements
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-allard committed Feb 3, 2021
1 parent c7016ee commit a7d4876
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 11 additions & 0 deletions scripts/common.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,14 @@ retry() {

echo "$stdout"
}

# helper function to join elements with a separator
join() {
local -r sep=$1; shift
local -ra elements=("$@")

echo -n "${elements[0]}"
if [ ${#elements[@]} -gt 1 ]; then
printf "$sep%s" "${elements[@]:1}"
fi
}
7 changes: 1 addition & 6 deletions scripts/iso-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@ _add_archives() {
done
echo "Collecting archives..."
echo "${archives[@]}"
# build archive list
archive_list=${archives[0]}
for i in "${archives[@]:1}"; do
archive_list+=,$i
done
archive_list="$(join , "${archives[@]}")"
echo "Updating bootstrap.yaml"
$SALT_CALL state.single file.serialize "$BOOTSTRAP_CONFIG" \
dataset="{'archives': [$archive_list]}" \
Expand All @@ -120,7 +116,6 @@ _add_archives() {
show_changes=True \
test="$DRY_RUN" \
--retcode-passthrough
return $?
}

_configure_archives() {
Expand Down

0 comments on commit a7d4876

Please sign in to comment.