Skip to content

Commit

Permalink
Merge pull request #86 from CircleCI-Public/fix-config-quotes-removal
Browse files Browse the repository at this point in the history
Fix values being unquoted
  • Loading branch information
Fernando-Abreu authored Jul 11, 2023
2 parents c3822bd + 683fbea commit 6fb32db
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/scripts/generate-config.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
#!/usr/bin/env bash

# GitHub's URL for the latest release, will redirect.
GITHUB_BASE_URL="https://github.com/cue-lang/cue"
LATEST_URL="${GITHUB_BASE_URL}/releases/latest/"
GITHUB_BASE_URL="https://github.com/mikefarah/yq"
DESTDIR="${DESTDIR:-/usr/local/bin}"
VERSION="4.34.1"

function installCue() {
echo "Checking For CUE + CURL"
if command -v curl >/dev/null 2>&1 && ! command -v cue >/dev/null 2>&1; then
if [ -z "$VERSION" ]; then
VERSION=$(curl -sLI -o /dev/null -w '%{url_effective}' "$LATEST_URL" | cut -d "v" -f 2)
fi

echo "Installing CUE v${VERSION}"
function installYq() {
echo "Checking For yq + CURL"
if command -v curl >/dev/null 2>&1 && ! command -v yq >/dev/null 2>&1; then
echo "Installing yq v${VERSION}"

uname -a | grep Darwin > /dev/null 2>&1 && OS='darwin' || OS='linux'

RELEASE_URL="${GITHUB_BASE_URL}/releases/download/v${VERSION}/cue_v${VERSION}_${OS}_amd64.tar.gz"
RELEASE_URL="${GITHUB_BASE_URL}/releases/download/v${VERSION}/yq_${OS}_amd64.tar.gz"

# save the current checkout dir
CHECKOUT_DIR=$(pwd)
Expand All @@ -27,9 +23,9 @@ function installCue() {
curl -sL --retry 3 "${RELEASE_URL}" | tar zx

echo "Installing to $DESTDIR"
sudo install cue "$DESTDIR"
sudo install yq "$DESTDIR"

command -v cue >/dev/null 2>&1
command -v yq >/dev/null 2>&1

echo "Installation finished"
# Delete the working directory when the install was successful.
Expand All @@ -38,7 +34,7 @@ function installCue() {
return $?
else
command -v curl >/dev/null 2>&1 || { echo >&2 "PATH-FILTERING ORB ERROR: CURL is required. Please install."; exit 1; }
command -v cue >/dev/null 2>&1 || { echo >&2 "PATH-FILTERING ORB ERROR: CUE is required. Please install"; exit 1; }
command -v yq >/dev/null 2>&1 || { echo >&2 "PATH-FILTERING ORB ERROR: yq is required. Please install"; exit 1; }
return $?
fi
}
Expand All @@ -53,11 +49,12 @@ function generateConfig() {

touch "${PARAM_GENERATED_CONFIG_PATH}"

# shellcheck disable=SC2154,SC2016
< "${PARAM_CONFIG_LIST_PATH}" \
awk 'NF {printf "\"%s\" ", $0}' \
| xargs -0 -I {} sh -c 'cue export {} --out yaml' \
awk 'NF {$1=$1; printf "\"%s\" ", $0}' \
| xargs yq eval-all '. as $item ireduce ({}; . * $item )' \
| tee "${PARAM_GENERATED_CONFIG_PATH}"
}

installCue
installYq
generateConfig

0 comments on commit 6fb32db

Please sign in to comment.