Skip to content

Commit

Permalink
Moved network name references to normalization function to resolve #127
Browse files Browse the repository at this point in the history
  • Loading branch information
davidalger committed Mar 26, 2020
1 parent 53e919e commit 7287de4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

* Fixed issue where `-` in `WARDEN_ENV_NAME` would results in `0.0.0.0` being used in `extra_hosts` passed to containers
* Fixed race condition caused by docker-compose starting two containers with identical mounts simultaneously (issue [#110](https://github.com/davidalger/warden/issues/110))
* Fixed issue with incorrect network name reference when uppercase characters are present in `WARDEN_ENV_NAME` (issue [#127](https://github.com/davidalger/warden/issues/127))

## Version [0.3.1](https://github.com/davidalger/warden/tree/0.3.1) (2020-03-06)
[All Commits](https://github.com/davidalger/warden/compare/0.3.0..0.3.1)
Expand Down
8 changes: 4 additions & 4 deletions commands/env.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,26 @@ fi

## disconnect peered service containers from environment network
if [[ "${WARDEN_PARAMS[0]}" == "down" ]]; then
disconnectPeeredServices "${WARDEN_ENV_NAME}_default"
disconnectPeeredServices "$(renderEnvNetworkName)"
fi

## connect peered service containers to environment network
if [[ "${WARDEN_PARAMS[0]}" == "up" ]]; then
## create environment network for attachments if it does not already exist
if [[ $(docker network ls -f "name=${WARDEN_ENV_NAME}_default" -q) == "" ]]; then
if [[ $(docker network ls -f "name=$(renderEnvNetworkName)" -q) == "" ]]; then
docker-compose \
--project-directory "${WARDEN_ENV_PATH}" -p "${WARDEN_ENV_NAME}" \
"${DOCKER_COMPOSE_ARGS[@]}" up --no-start
fi

## connect globally peered services to the environment network
connectPeeredServices "${WARDEN_ENV_NAME}_default"
connectPeeredServices "$(renderEnvNetworkName)"
fi

## lookup address of traefik container on environment network
export TRAEFIK_ADDRESS="$(docker container inspect traefik \
--format '
{{- $network := index .NetworkSettings.Networks "'"${WARDEN_ENV_NAME}_default"'" -}}
{{- $network := index .NetworkSettings.Networks "'"$(renderEnvNetworkName)"'" -}}
{{- if $network }}{{ $network.IPAddress }}{{ end -}}
' 2>/dev/null || true
)"
Expand Down
4 changes: 4 additions & 0 deletions utils/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ function loadEnvConfig () {
assertValidEnvType
}

function renderEnvNetworkName() {
echo "${WARDEN_ENV_NAME}_default" | tr '[:upper:]' '[:lower:]'
}

function assertValidEnvType () {
if [[ ! -f "${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}/${WARDEN_ENV_TYPE}.base.yml" ]]; then
>&2 echo -e "\033[31mInvalid environment type \"${WARDEN_ENV_TYPE}\" specified.\033[0m"
Expand Down

0 comments on commit 7287de4

Please sign in to comment.