mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 19:06:09 +00:00
hooks: Add a common/ directory and factor out common Sentry code.
This commit is contained in:
committed by
Alex Vandiver
parent
f4d70a2e37
commit
377f2d6d03
45
puppet/zulip/files/hooks/common/sentry.sh
Executable file
45
puppet/zulip/files/hooks/common/sentry.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
if ! grep -Eq 'SENTRY_DSN|SENTRY_FRONTEND_DSN' /etc/zulip/settings.py; then
|
||||
echo "sentry: No DSN configured! Set SENTRY_DSN or SENTRY_FRONTEND_DSN in /etc/zulip/settings.py"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! SENTRY_AUTH_TOKEN=$(crudini --get /etc/zulip/zulip-secrets.conf secrets sentry_release_auth_token); then
|
||||
echo "sentry: No release auth token set! Set sentry_release_auth_token in /etc/zulip/zulip-secrets.conf"
|
||||
exit 0
|
||||
fi
|
||||
export SENTRY_AUTH_TOKEN
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
if ! sentry_org=$(crudini --get /etc/zulip/zulip.conf sentry organization); then
|
||||
echo "sentry: No organization set! Set sentry.organization in /etc/zulip/zulip.conf"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sentry_project=$(crudini --get /etc/zulip/zulip.conf sentry project)
|
||||
sentry_frontend_project=$(crudini --get /etc/zulip/zulip.conf sentry frontend_project)
|
||||
if [ -z "$sentry_project" ] && [ -z "$sentry_frontend_project" ]; then
|
||||
echo "sentry: No project set! Set sentry.project and/or sentry.frontend_project in /etc/zulip/zulip.conf"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "$sentry_project" ] && ! grep -q 'SENTRY_DSN' /etc/zulip/settings.py; then
|
||||
echo "sentry: sentry.project is set but SENTRY_DSN is not set in /etc/zulip/settings.py"
|
||||
exit 0
|
||||
fi
|
||||
if [ -n "$sentry_frontend_project" ] && ! grep -q 'SENTRY_FRONTEND_DSN' /etc/zulip/settings.py; then
|
||||
echo "sentry: sentry.frontend_project is set but SENTRY_FRONTEND_DSN is not set in /etc/zulip/settings.py"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! which sentry-cli >/dev/null; then
|
||||
echo "sentry: No sentry-cli installed!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
sentry_release="zulip-server@$ZULIP_NEW_VERSION"
|
||||
@@ -3,40 +3,7 @@
|
||||
set -e
|
||||
set -u
|
||||
|
||||
if ! grep -q 'SENTRY_DSN' /etc/zulip/settings.py; then
|
||||
echo "sentry: No DSN configured! Set SENTRY_DSN in /etc/zulip/settings.py"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! SENTRY_AUTH_TOKEN=$(crudini --get /etc/zulip/zulip-secrets.conf secrets sentry_release_auth_token); then
|
||||
echo "sentry: No release auth token set! Set sentry_release_auth_token in /etc/zulip/zulip-secrets.conf"
|
||||
exit 0
|
||||
fi
|
||||
export SENTRY_AUTH_TOKEN
|
||||
|
||||
if ! sentry_org=$(crudini --get /etc/zulip/zulip.conf sentry organization); then
|
||||
echo "sentry: No organization set! Set sentry.organization in /etc/zulip/zulip.conf"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sentry_project=$(crudini --get /etc/zulip/zulip.conf sentry project)
|
||||
sentry_frontend_project=$(crudini --get /etc/zulip/zulip.conf sentry frontend_project)
|
||||
if [ -z "$sentry_project" ] && [ -z "$sentry_frontend_project" ]; then
|
||||
echo "sentry: No project set! Set sentry.project and/or sentry.frontend_project in /etc/zulip/zulip.conf"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! which sentry-cli >/dev/null; then
|
||||
echo "sentry: No sentry-cli installed!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! [ -f ./sentry-release ]; then
|
||||
echo "sentry: No Sentry sentry-release file found!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sentry_release=$(cat ./sentry-release)
|
||||
source "$(dirname "$0")/../common/sentry.sh"
|
||||
|
||||
deploy_environment=$(crudini --get /etc/zulip/zulip.conf machine deploy_type || echo "development")
|
||||
|
||||
|
||||
@@ -3,44 +3,8 @@
|
||||
set -e
|
||||
set -u
|
||||
|
||||
if ! grep -Eq 'SENTRY_DSN|SENTRY_FRONTEND_DSN' /etc/zulip/settings.py; then
|
||||
echo "sentry: No DSN configured! Set SENTRY_DSN or SENTRY_FRONTEND_DSN in /etc/zulip/settings.py"
|
||||
exit 0
|
||||
fi
|
||||
source "$(dirname "$0")/../common/sentry.sh"
|
||||
|
||||
if ! SENTRY_AUTH_TOKEN=$(crudini --get /etc/zulip/zulip-secrets.conf secrets sentry_release_auth_token); then
|
||||
echo "sentry: No release auth token set! Set sentry_release_auth_token in /etc/zulip/zulip-secrets.conf"
|
||||
exit 0
|
||||
fi
|
||||
export SENTRY_AUTH_TOKEN
|
||||
|
||||
if ! sentry_org=$(crudini --get /etc/zulip/zulip.conf sentry organization); then
|
||||
echo "sentry: No organization set! Set sentry.organization in /etc/zulip/zulip.conf"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sentry_project=$(crudini --get /etc/zulip/zulip.conf sentry project)
|
||||
sentry_frontend_project=$(crudini --get /etc/zulip/zulip.conf sentry frontend_project)
|
||||
if [ -z "$sentry_project" ] && [ -z "$sentry_frontend_project" ]; then
|
||||
echo "sentry: No project set! Set sentry.project and/or sentry.frontend_project in /etc/zulip/zulip.conf"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "$sentry_project" ] && ! grep -q 'SENTRY_DSN' /etc/zulip/settings.py; then
|
||||
echo "sentry: sentry.project is set but SENTRY_DSN is not set in /etc/zulip/settings.py"
|
||||
exit 0
|
||||
fi
|
||||
if [ -n "$sentry_frontend_project" ] && ! grep -q 'SENTRY_FRONTEND_DSN' /etc/zulip/settings.py; then
|
||||
echo "sentry: sentry.frontend_project is set but SENTRY_FRONTEND_DSN is not set in /etc/zulip/settings.py"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! which sentry-cli >/dev/null; then
|
||||
echo "sentry: No sentry-cli installed!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sentry_release="zulip-server@$ZULIP_NEW_VERSION"
|
||||
echo "$sentry_release" >./sentry-release
|
||||
|
||||
echo "sentry: Creating release $sentry_release"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
class zulip::hooks::base {
|
||||
file { [
|
||||
'/etc/zulip/hooks',
|
||||
'/etc/zulip/hooks/common',
|
||||
'/etc/zulip/hooks/pre-deploy.d',
|
||||
'/etc/zulip/hooks/post-deploy.d',
|
||||
]:
|
||||
|
||||
@@ -20,5 +20,9 @@ class zulip::hooks::sentry {
|
||||
target => $bin,
|
||||
}
|
||||
|
||||
zulip::hooks::file { ['pre-deploy.d/sentry.hook', 'post-deploy.d/sentry.hook']: }
|
||||
zulip::hooks::file { [
|
||||
'common/sentry.sh',
|
||||
'pre-deploy.d/sentry.hook',
|
||||
'post-deploy.d/sentry.hook',
|
||||
]: }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user