Skip to content

Commit

Permalink
chore: Use DT_LATEST_DRAFT_URL from ENV and set it to an internal hos…
Browse files Browse the repository at this point in the history
…tname (#564)

* chore: Refactor at/__init__.py

* chore: Use DT_LATEST_DRAFT_URL from ENV and set it to an internal hostname
  • Loading branch information
kesara authored Jan 21, 2025
1 parent 7f3f5e2 commit 75b1dc8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
48 changes: 25 additions & 23 deletions at/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,40 @@ def create_app(config=None):
CORS(app)

if config is None:
app.logger.info('Using configuration settings from at/config.py')
app.config.from_object('at.config')
app.logger.info("Using configuration settings from at/config.py")
app.config.from_object("at.config")
else:
app.logger.info('Using configuration settings from {}'.format(
str(config)))
app.logger.info(f"Using configuration settings from {str(config)}")
app.config.from_mapping(config)

from . import api
app.register_blueprint(api.bp)

SENTRY_DSN = getenv('SENTRY_DSN')
app.register_blueprint(api.bp)

if site_url := getenv('SITE_URL'):
app.logger.info('Using SITE_URL from ENV.')
app.config['SITE_URL'] = site_url
elif 'SITE_URL' not in app.config.keys():
app.logger.info('SITE_URL not set. Using default.')
app.config['SITE_URL'] = 'http://localhost'
if site_url := getenv("SITE_URL"):
app.logger.info("Using SITE_URL from ENV.")
app.config["SITE_URL"] = site_url
elif "SITE_URL" not in app.config.keys():
app.logger.info("SITE_URL not set. Using default.")
app.config["SITE_URL"] = "http://localhost"
app.logger.info(f"SITE_URL: {app.config['SITE_URL']}")

app.logger.info('SITE_URL: {}'.format(app.config['SITE_URL']))
if dt_latest_draft_url := getenv("DT_LATEST_DRAFT_URL"):
app.logger.info(
f"Using DT_LATEST_DRAFT_URL from ENV: {dt_latest_draft_url}")
app.config["DT_LATEST_DRAFT_URL"] = dt_latest_draft_url

if SENTRY_DSN:
if sentry_dsn := getenv("SENTRY_DSN"):
sentry_init(
dsn=SENTRY_DSN,
integrations=[
FlaskIntegration(),
LoggingIntegration(
level=LOG_ERROR,
event_level=LOG_ERROR)],
traces_sample_rate=1.0)
app.logger.info('Sentry is enabled.')
dsn=sentry_dsn,
integrations=[
FlaskIntegration(),
LoggingIntegration(level=LOG_ERROR, event_level=LOG_ERROR),
],
traces_sample_rate=1.0,
)
app.logger.info("Sentry is enabled.")
else:
app.logger.info('Sentry is disabled.')
app.logger.info("Sentry is disabled.")

return app
1 change: 1 addition & 0 deletions k8s/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ type: Opaque
stringData:
GUNICORN_WORKERS: "2"
SITE_URL: "https://author-tools.ietf.org"
DT_LATEST_DRAFT_URL: "http://dt-datatracker.datatracker.svc/api/rfcdiff-latest-json"
# SENTRY_DSN: "" secret from vault

0 comments on commit 75b1dc8

Please sign in to comment.