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

Optional Mutagen #749

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion commands/env.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ trap '' ERR
## define source repository
if [[ -f "${WARDEN_HOME_DIR}/.env" ]]; then
eval "$(sed 's/\r$//g' < "${WARDEN_HOME_DIR}/.env" | grep "^WARDEN_")"

## configure mutagen enable by default
WARDEN_MUTAGEN_ENABLE=${WARDEN_MUTAGEN_ENABLE:-1}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only automatically enable mutagen for Darwin OS Types. While the current code won't have an issue with this variable being enabled, in a theoretical future where we expand Mutagen support beyond Mac OS (why would we ever?) this would be enable Mutagen for people who were not expecting it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no problem because WARDEN_MUTAGEN_ENABLE is not consulted by itself, to use Mutagen it is verified that it is active and that you use Darwin OS Types

fi
export WARDEN_IMAGE_REPOSITORY="${WARDEN_IMAGE_REPOSITORY:-"docker.io/wardenenv"}"

Expand Down Expand Up @@ -174,7 +177,10 @@ TRAEFIK_ADDRESS="$(docker container inspect traefik \
)"
export TRAEFIK_ADDRESS;

if [[ $OSTYPE =~ ^darwin ]]; then
if [[ $OSTYPE =~ ^darwin ]] && [[ ${WARDEN_MUTAGEN_ENABLE} -eq 1 ]]; then
echo -e "\033[31mWe noticed that you're on MacOS and using Mutagen sync.\033[0m"
echo -e "\033[31mWe recommend configuring Docker Desktop to use VirtioFS and disable Mutagen sync by adding WARDEN_MUTAGEN_ENABLE=0 in ~/.warden/.env file.\033[0m"

export MUTAGEN_SYNC_FILE="${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}/${WARDEN_ENV_TYPE}.mutagen.yml"

if [[ -f "${WARDEN_HOME_DIR}/environments/${WARDEN_ENV_TYPE}/${WARDEN_ENV_TYPE}.mutagen.yml" ]]; then
Expand Down
2 changes: 2 additions & 0 deletions commands/install.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,7 @@ if [[ ! -f "${WARDEN_HOME_DIR}/.env" ]]; then
WARDEN_PORTAINER_ENABLE=0
# SEt to "0" to disable DNSMasq
WARDEN_DNSMASQ_ENABLE=1
# Set to "1" to enable Mutagen
WARDEN_MUTAGEN_ENABLE=1
EOT
fi
40 changes: 25 additions & 15 deletions utils/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ function loadEnvConfig () {
;;
esac

if [[ -f "${WARDEN_HOME_DIR}/.env" ]]; then
eval "$(sed 's/\r$//g' < "${WARDEN_HOME_DIR}/.env" | grep "^WARDEN_")"
fi

assertValidEnvType
}

Expand Down Expand Up @@ -119,21 +123,27 @@ function appendEnvPartialIfExists () {
local PARTIAL_PATH=""

for PARTIAL_PATH in \
"${WARDEN_DIR}/environments/includes/${PARTIAL_NAME}.base.yml" \
"${WARDEN_DIR}/environments/includes/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" \
"${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.base.yml" \
"${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" \
"${WARDEN_HOME_DIR}/environments/includes/${PARTIAL_NAME}.base.yml" \
"${WARDEN_HOME_DIR}/environments/includes/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" \
"${WARDEN_HOME_DIR}/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.base.yml" \
"${WARDEN_HOME_DIR}/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" \
"${WARDEN_ENV_PATH}/.warden/environments/includes/${PARTIAL_NAME}.base.yml" \
"${WARDEN_ENV_PATH}/.warden/environments/includes/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" \
"${WARDEN_ENV_PATH}/.warden/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.base.yml" \
"${WARDEN_ENV_PATH}/.warden/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml"
"${WARDEN_DIR}/environments" \
"${WARDEN_HOME_DIR}/environments" \
"${WARDEN_ENV_PATH}/.warden/environments";
do
if [[ -f "${PARTIAL_PATH}" ]]; then
DOCKER_COMPOSE_ARGS+=("-f" "${PARTIAL_PATH}")
fi
for PARTIAL_PATH in \
"${PARTIAL_PATH}/includes/${PARTIAL_NAME}" \
"${PARTIAL_PATH}/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}";
do
for PARTIAL_PATH in \
"${PARTIAL_PATH}.base" \
"${PARTIAL_PATH}.${WARDEN_ENV_SUBT}";
do
if [[ -f "${PARTIAL_PATH}.yml" ]]; then
DOCKER_COMPOSE_ARGS+=("-f" "${PARTIAL_PATH}.yml")
fi
if [[ "${WARDEN_ENV_SUBT}" == "darwin" ]] &&
[[ "${WARDEN_MUTAGEN_ENABLE}" == "1" ]] &&
[[ -f "${PARTIAL_PATH}.mutagen.yml" ]]; then
DOCKER_COMPOSE_ARGS+=("-f" "${PARTIAL_PATH}.mutagen.yml")
fi
done
done
done
}