Skip to content

Commit

Permalink
feat: unify version handeling (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
Threated authored Jan 29, 2025
1 parent 1ad73d8 commit e355337
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
49 changes: 28 additions & 21 deletions bridgehead
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,44 @@ case "$PROJECT" in
;;
esac

# Loads config variables and runs the projects setup script
loadVars() {
# Load variables from /etc/bridgehead and /srv/docker/bridgehead
set -a
# Source the project specific config file
source /etc/bridgehead/$PROJECT.conf || fail_and_report 1 "/etc/bridgehead/$PROJECT.conf not found"
# Source the project specific local config file if present
# This file is ignored by git as oposed to the regular config file as it contains private site information like etl auth data
if [ -e /etc/bridgehead/$PROJECT.local.conf ]; then
log INFO "Applying /etc/bridgehead/$PROJECT.local.conf"
source /etc/bridgehead/$PROJECT.local.conf || fail_and_report 1 "Found /etc/bridgehead/$PROJECT.local.conf but failed to import"
fi
# Set execution environment on main default to prod else test
if [[ -z "${ENVIRONMENT+x}" ]]; then
if [ "$(git rev-parse --abbrev-ref HEAD)" == "main" ]; then
ENVIRONMENT="production"
else
ENVIRONMENT="test"
fi
fi
# Source the versions of the images components
case "$ENVIRONMENT" in
"production")
source ./versions/prod
;;
"test")
source ./versions/test
;;
*)
report_error 7 "Environment \"$ENVIRONMENT\" is unknown. Assuming production. FIX THIS!"
source ./versions/prod
;;
esac
fetchVarsFromVaultByFile /etc/bridgehead/$PROJECT.conf || fail_and_report 1 "Unable to fetchVarsFromVaultByFile"
setHostname
optimizeBlazeMemoryUsage
# Run project specific setup if it exists
# This will ususally modiy the `OVERRIDE` to include all the compose files that the project depends on
# This is also where projects specify which modules to load
[ -e ./$PROJECT/vars ] && source ./$PROJECT/vars
set +a

Expand All @@ -79,26 +106,6 @@ loadVars() {
fi
detectCompose
setupProxy

# Set some project-independent default values
: ${ENVIRONMENT:=production}
export ENVIRONMENT

case "$ENVIRONMENT" in
"production")
export FOCUS_TAG=main
export BEAM_TAG=main
;;
"test")
export FOCUS_TAG=develop
export BEAM_TAG=develop
;;
*)
report_error 7 "Environment \"$ENVIRONMENT\" is unknown. Assuming production. FIX THIS!"
export FOCUS_TAG=main
export BEAM_TAG=main
;;
esac
}

case "$ACTION" in
Expand Down
2 changes: 2 additions & 0 deletions versions/prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FOCUS_TAG=main
BEAM_TAG=main
2 changes: 2 additions & 0 deletions versions/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FOCUS_TAG=develop
BEAM_TAG=develop

0 comments on commit e355337

Please sign in to comment.