Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix values being unquoted #86

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 )' \
stig marked this conversation as resolved.
Show resolved Hide resolved
| tee "${PARAM_GENERATED_CONFIG_PATH}"
}

installCue
installYq
generateConfig