Skip to content

Commit

Permalink
Add endpoint to get version info (#2242)
Browse files Browse the repository at this point in the history
Co-authored-by: Vignesh Hari <vichuhari100@gmail.com>
  • Loading branch information
sainak and vigneshhari authored Jun 5, 2024
1 parent 8790cde commit 369b9df
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
14 changes: 8 additions & 6 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,9 @@
)
FILE_UPLOAD_BUCKET_EXTERNAL_ENDPOINT = env(
"FILE_UPLOAD_BUCKET_EXTERNAL_ENDPOINT",
default=BUCKET_EXTERNAL_ENDPOINT
if BUCKET_ENDPOINT
else FILE_UPLOAD_BUCKET_ENDPOINT,
default=(
BUCKET_EXTERNAL_ENDPOINT if BUCKET_ENDPOINT else FILE_UPLOAD_BUCKET_ENDPOINT
),
)

ALLOWED_MIME_TYPES = env.list(
Expand Down Expand Up @@ -578,9 +578,9 @@
)
FACILITY_S3_BUCKET_EXTERNAL_ENDPOINT = env(
"FACILITY_S3_BUCKET_EXTERNAL_ENDPOINT",
default=BUCKET_EXTERNAL_ENDPOINT
if BUCKET_ENDPOINT
else FACILITY_S3_BUCKET_ENDPOINT,
default=(
BUCKET_EXTERNAL_ENDPOINT if BUCKET_ENDPOINT else FACILITY_S3_BUCKET_ENDPOINT
),
)

# for setting the shifting mode
Expand All @@ -604,6 +604,8 @@
json.loads(base64.b64decode(env("JWKS_BASE64", default=generate_encoded_jwks())))
)

APP_VERSION = env("APP_VERSION", default="unknown")

# ABDM
ENABLE_ABDM = env.bool("ENABLE_ABDM", default=False)
ABDM_CLIENT_ID = env("ABDM_CLIENT_ID", default="")
Expand Down
12 changes: 6 additions & 6 deletions config/settings/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
from sentry_sdk.integrations.redis import RedisIntegration

from .base import * # noqa
from .base import env
from .base import APP_VERSION, DATABASES, TEMPLATES, env

# DATABASES
# ------------------------------------------------------------------------------
DATABASES["default"] = env.db("DATABASE_URL") # noqa F405
DATABASES["default"]["ATOMIC_REQUESTS"] = True # noqa F405
DATABASES["default"]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=60) # noqa F405
DATABASES["default"] = env.db("DATABASE_URL")
DATABASES["default"]["ATOMIC_REQUESTS"] = True
DATABASES["default"]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=60)

# SECURITY
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -45,7 +45,7 @@
# TEMPLATES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
TEMPLATES[-1]["OPTIONS"]["loaders"] = [ # type: ignore[index] # noqa F405
TEMPLATES[-1]["OPTIONS"]["loaders"] = [ # type: ignore[index]
(
"django.template.loaders.cached.Loader",
[
Expand Down Expand Up @@ -98,7 +98,7 @@
if SENTRY_DSN := env("SENTRY_DSN", default=""):
sentry_sdk.init(
dsn=SENTRY_DSN,
release=env("APP_VERSION", default="unknown"),
release=APP_VERSION,
environment=env("SENTRY_ENVIRONMENT", default="deployment-unknown"),
traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", default=0),
profiles_sample_rate=env.float("SENTRY_PROFILES_SAMPLE_RATE", default=0),
Expand Down
3 changes: 2 additions & 1 deletion config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@
)

from .auth_views import AnnotatedTokenVerifyView, TokenObtainPairView, TokenRefreshView
from .views import home_view, ping
from .views import app_version, home_view, ping

urlpatterns = [
path("", home_view, name="home"),
path("ping/", ping, name="ping"),
path("app_version/", app_version, name="app_version"),
# Django Admin, use {% url 'admin:index' %}
path(settings.ADMIN_URL, admin.site.urls),
# Rest API
Expand Down
7 changes: 6 additions & 1 deletion config/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
from django.conf import settings
from django.http import JsonResponse
from django.shortcuts import render


def app_version(_):
return JsonResponse({"version": settings.APP_VERSION})


def home_view(request):
return render(request, "pages/home.html")


def ping(request):
def ping(_):
return JsonResponse({"status": "OK"})

0 comments on commit 369b9df

Please sign in to comment.