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

Refactor Taiga configuration script for readability and robustness: #194

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
76 changes: 56 additions & 20 deletions docker/config_env_subst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,86 @@

contribs=()

# Slack
if [[ -z "${ENABLE_SLACK}" ]]; then
export ENABLE_SLACK="false"
# Lowercase and set environment variables

# Check and set the PUBLIC_REGISTER_ENABLED variable
if [[ "${PUBLIC_REGISTER_ENABLED}" == "True" || "${PUBLIC_REGISTER_ENABLED}" == "true" ]]; then
export PUBLIC_REGISTER_ENABLED="true"
else
export PUBLIC_REGISTER_ENABLED="false"
fi

if [ ${ENABLE_SLACK} == "true" ]; then
contribs+=('"plugins/slack/slack.json"')
# Check and set the ENABLE_GITLAB_AUTH variable
if [[ "${ENABLE_GITLAB_AUTH}" == "True" || "${ENABLE_GITLAB_AUTH}" == "true" ]]; then
export ENABLE_GITLAB_AUTH="true"
else
export ENABLE_GITLAB_AUTH="false"
fi

# Public registration and oauth
if [[ -z "${PUBLIC_REGISTER_ENABLED}" ]]; then
export PUBLIC_REGISTER_ENABLED="false"
# Check and set the ENABLE_GITHUB_AUTH variable
if [[ "${ENABLE_GITHUB_AUTH}" == "True" || "${ENABLE_GITHUB_AUTH}" == "true" ]]; then
export ENABLE_GITHUB_AUTH="true"
else
export ENABLE_GITHUB_AUTH="false"
fi

# Check and set the ENABLE_GITHUB_IMPORTER variable
if [[ "${ENABLE_GITHUB_IMPORTER}" == "True" || "${ENABLE_GITHUB_IMPORTER}" == "true" ]]; then
export ENABLE_GITHUB_IMPORTER="true"
else
export ENABLE_GITHUB_IMPORTER="false"
fi

# Check and set the ENABLE_JIRA_IMPORTER variable
if [[ "${ENABLE_JIRA_IMPORTER}" == "True" || "${ENABLE_JIRA_IMPORTER}" == "true" ]]; then
export ENABLE_JIRA_IMPORTER="true"
else
export ENABLE_JIRA_IMPORTER="false"
fi

# Check and set the ENABLE_TRELLO_IMPORTER variable
if [[ "${ENABLE_TRELLO_IMPORTER}" == "True" || "${ENABLE_TRELLO_IMPORTER}" == "true" ]]; then
export ENABLE_TRELLO_IMPORTER="true"
else
export ENABLE_TRELLO_IMPORTER="false"
fi

# Check and set the ENABLE_SLACK variable
if [[ "${ENABLE_SLACK}" == "True" || "${ENABLE_SLACK}" == "true" ]]; then
export ENABLE_SLACK="true"
else
export ENABLE_SLACK="false"
fi

# Public registration and oauth
if [ ${PUBLIC_REGISTER_ENABLED} == "true" ]; then
# Include GitHub authentication plugin if enabled
if [ ${ENABLE_GITHUB_AUTH} == "true" ]; then
contribs+=('"plugins/github-auth/github-auth.json"')
fi
# Include GitLab authentication plugin if enabled
if [ ${ENABLE_GITLAB_AUTH} == "true" ]; then
contribs+=('"plugins/gitlab-auth/gitlab-auth.json"')
fi
fi

# Importers
if [[ -z "${ENABLE_GITHUB_IMPORTER}" ]]; then
export ENABLE_GITHUB_IMPORTER="false"
fi

if [[ -z "${ENABLE_JIRA_IMPORTER}" ]]; then
export ENABLE_JIRA_IMPORTER="false"
fi

if [[ -z "${ENABLE_TRELLO_IMPORTER}" ]]; then
export ENABLE_TRELLO_IMPORTER="false"
# Include Slack plugin if enabled
if [ ${ENABLE_SLACK} == "true" ]; then
contribs+=('"plugins/slack/slack.json"')
fi

# Convert array to a comma-separated string
contribs=$( IFS=,; echo "[${contribs[*]}]" )

# Set CONTRIB_PLUGINS environment variable
export CONTRIB_PLUGINS=$contribs

# Check if the configuration file exists, and if not, create it
FILE=/usr/share/nginx/html/conf.json
if [ ! -f "$FILE" ]; then
envsubst < /usr/share/nginx/html/conf.json.template \
> /usr/share/nginx/html/conf.json
fi

sed -i 's;<base href="/">;<base href="'"${TAIGA_SUBPATH}/"'">;g' /usr/share/nginx/html/index.html
# Update base href in the HTML file
sed -i 's;<base href="/">;<base href="'"${TAIGA_SUBPATH}/"'">;g' /usr/share/nginx/html/index.html