From b41d362e187b7cdae8581b516bb1d93a369b15dc Mon Sep 17 00:00:00 2001 From: Tim Nelson Date: Tue, 12 Sep 2023 15:58:56 +1000 Subject: [PATCH] builder/mariadb.Dockerfile: Fixed a bug in hopes of making final container work mariadb-image-builder: Neatened up code with meaningful variable names and more comments --- builder/mariadb.Dockerfile | 5 ++++- mariadb-image-builder | 33 ++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/builder/mariadb.Dockerfile b/builder/mariadb.Dockerfile index 9c57893..5d39e30 100644 --- a/builder/mariadb.Dockerfile +++ b/builder/mariadb.Dockerfile @@ -34,4 +34,7 @@ RUN chown -R 100:root /initialized-db ARG CLEAN_IMAGE FROM ${CLEAN_IMAGE:-uselagoon/mariadb-10.6-drupal:latest} -COPY --from=builder /initialized-db /var/lib/mysql \ No newline at end of file +COPY --from=builder /initialized-db /var/lib/mysql + +RUN cp /var/lib/mysql/.my.cnf /etc/mysql/my.cnf + diff --git a/mariadb-image-builder b/mariadb-image-builder index 37ffbb8..784b66c 100644 --- a/mariadb-image-builder +++ b/mariadb-image-builder @@ -91,35 +91,42 @@ function featureFlag() { # function to run down environment variable checks through the chain # featureflag -> api variables -> fallback value +# +# Parameters are: +# - Name of variable to check +# - Current value of variable +# - Search key to use when searching JSON function projectEnvironmentVariableCheck() { - # check for argument - [ "$1" ] || return + local flagVariableName="$1" + local existingValue="$2" + local jsonSearchKey="$3" - local flagVar - flagVar="$1" + # check for argument + [ "$flagVariableName" ] || return # do feature flag checks first - flagValue=$(featureFlag ${flagVar}) + flagValue=$(featureFlag ${flagVariableName}) [ "$flagValue" ] && echo "$flagValue" && return - + # next check if the variable is in the json payload from an advanced task (this means the task has arguments that should override) - if [ "$3" ]; then - flagValue=$(echo "${JSON_PAYLOAD}" | base64 -d | jq -r '.'$1' // "'$3'"') - else - flagValue=$(echo "${JSON_PAYLOAD}" | base64 -d | jq -r '.'$1' // empty') + if [ -z "$jsonSearchKey" ]; then + jsonSearchKeyJq='empty' + else + jsonSearchKeyJq='"'$jsonSearchKey'"' fi + flagValue=$(echo "${JSON_PAYLOAD}" | base64 -d | jq -r '.'$flagVariableName' // '$jsonSearchKeyJq) [ "$flagValue" ] && echo "$flagValue" && return # next check if the variable exists in the variables from the API directly (requires support for this) # check Lagoon environment variables - flagValue=$(jq -r '.[] | select(.name == "'"$flagVar"'") | .value' <<<"$LAGOON_ENVIRONMENT_VARIABLES") + flagValue=$(jq -r '.[] | select(.name == "'"$flagVariableName"'") | .value' <<<"$LAGOON_ENVIRONMENT_VARIABLES") [ "$flagValue" ] && echo "$flagValue" && return # check Lagoon project variables - flagValue=$(jq -r '.[] | select(.name == "'"$flagVar"'") | .value' <<<"$LAGOON_PROJECT_VARIABLES") + flagValue=$(jq -r '.[] | select(.name == "'"$flagVariableName"'") | .value' <<<"$LAGOON_PROJECT_VARIABLES") [ "$flagValue" ] && echo "$flagValue" && return # lastly fall back to the provided value (this could be from a variable in the configmap mounted to the container) - echo "$2" + echo "$existingValue" } echo "======================="