Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Commit

Permalink
Added back lowercase env var
Browse files Browse the repository at this point in the history
that's because JQ ascii_downcase method is not present in all installations of JQ done via package managers
  • Loading branch information
marcingrzejszczak committed Sep 11, 2017
1 parent 4ddb279 commit aba2253
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions common/src/main/bash/pipeline-cf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ function deployService() {
deployEureka "${EUREKA_ARTIFACT_ID}-${EUREKA_VERSION}" "${serviceName}" "${ENVIRONMENT}"
;;
stubrunner)
UNIQUE_EUREKA_NAME="$( echo "${PARSED_YAML}" | jq --arg x "${ENVIRONMENT}" '.[$x | ascii_downcase].services[] | select(.type == "eureka") | .name' | sed 's/^"\(.*\)"$/\1/' )"
UNIQUE_RABBIT_NAME="$( echo "${PARSED_YAML}" | jq --arg x "${ENVIRONMENT}" '.[$x | ascii_downcase].services[] | select(.type == "rabbitmq") | .name' | sed 's/^"\(.*\)"$/\1/' )"
UNIQUE_EUREKA_NAME="$( echo "${PARSED_YAML}" | jq --arg x "${LOWERCASE_ENV}" '.[$x].services[] | select(.type == "eureka") | .name' | sed 's/^"\(.*\)"$/\1/' )"
UNIQUE_RABBIT_NAME="$( echo "${PARSED_YAML}" | jq --arg x "${LOWERCASE_ENV}" '.[$x].services[] | select(.type == "rabbitmq") | .name' | sed 's/^"\(.*\)"$/\1/' )"
PREVIOUS_IFS="${IFS}"
IFS=: read -r STUBRUNNER_GROUP_ID STUBRUNNER_ARTIFACT_ID STUBRUNNER_VERSION <<< "${serviceCoordinates}"
IFS="${PREVIOUS_IFS}"
PARSED_STUBRUNNER_USE_CLASSPATH="$( echo "${PARSED_YAML}" | jq --arg x "${ENVIRONMENT}" '.[$x | ascii_downcase].services[] | select(.type == "stubrunner") | .useClasspath' | sed 's/^"\(.*\)"$/\1/' )"
PARSED_STUBRUNNER_USE_CLASSPATH="$( echo "${PARSED_YAML}" | jq --arg x "${LOWERCASE_ENV}" '.[$x].services[] | select(.type == "stubrunner") | .useClasspath' | sed 's/^"\(.*\)"$/\1/' )"
STUBRUNNER_USE_CLASSPATH=$( if [[ "${PARSED_STUBRUNNER_USE_CLASSPATH}" == "null" ]] ; then echo "false"; else echo "${PARSED_STUBRUNNER_USE_CLASSPATH}" ; fi )
downloadAppBinary "${REPO_WITH_BINARIES}" "${STUBRUNNER_GROUP_ID}" "${STUBRUNNER_ARTIFACT_ID}" "${STUBRUNNER_VERSION}"
deployStubRunnerBoot "${STUBRUNNER_ARTIFACT_ID}-${STUBRUNNER_VERSION}" "${REPO_WITH_BINARIES}" "${UNIQUE_RABBIT_NAME}" "${UNIQUE_EUREKA_NAME}" "${ENVIRONMENT}" "${serviceName}"
Expand Down
7 changes: 6 additions & 1 deletion common/src/main/bash/pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function deployServices() {
fi
# retrieve the space separated type, name and coordinates
done <<< "$( echo "${PARSED_YAML}" | \
jq -r --arg x "${ENVIRONMENT}" '.[$x | ascii_downcase].services[] | "\(.type) \(.name) \(.coordinates)"' )"
jq -r --arg x "${LOWERCASE_ENV}" '.[$x].services[] | "\(.type) \(.name) \(.coordinates)"' )"
}

# Converts YAML to JSON - uses ruby
Expand All @@ -179,6 +179,11 @@ function toLowerCase() {
# CURRENTLY WE ONLY SUPPORT CF AS PAAS OUT OF THE BOX
PAAS_TYPE="${PAAS_TYPE:-cf}"
export PAAS_TYPE
# Not every linux distribution comes with installation of JQ that is new enough
# to have the asci_downcase method. That's why we're using the global env variable
# At some point we'll deprecate this and use what JQ provides
LOWERCASE_ENV="$( toLowerCase "${ENVIRONMENT}" )"
export LOWERCASE_ENV

echo "Picked PAAS is [${PAAS_TYPE}]"
echo "Current environment is [${ENVIRONMENT}]"
Expand Down

0 comments on commit aba2253

Please sign in to comment.