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

fix(website): replace confusing utils.is_prod() function #2898

Merged
merged 2 commits into from
Nov 26, 2024
Merged
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
2 changes: 1 addition & 1 deletion gcp/website/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import utils

if utils.is_prod():
if utils.is_cloud_run():
instance = flask_caching.Cache(
config={
'CACHE_TYPE': 'RedisCache',
Expand Down
12 changes: 3 additions & 9 deletions gcp/website/frontend_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class VulnerabilityNotImported(VulnerabilityNotFound):
"""Plumb the vulnerability ID with import findings to the error handler."""


if utils.is_prod():
if utils.is_cloud_run():
redis_host = os.environ.get('REDISHOST', 'localhost')
redis_port = int(os.environ.get('REDISPORT', 6379))
limiter = rate_limiter.RateLimiter(
Expand Down Expand Up @@ -250,10 +250,7 @@ def vulnerability(vuln_id):
"""Vulnerability page."""
vuln = osv_get_by_id(vuln_id)

if utils.is_prod():
api_url = 'api.osv.dev'
else:
api_url = 'api.test.osv.dev'
api_url = utils.api_url()

return render_template(
'vulnerability.html', vulnerability=vuln, api_url=api_url)
Expand Down Expand Up @@ -287,10 +284,7 @@ def vulnerability_json_redirector(potential_vuln_id):
# This calls abort() on failed retrievals.
bug = osv_get_by_id(potential_vuln_id)

if utils.is_prod():
api_url = 'api.osv.dev'
else:
api_url = 'api.test.osv.dev'
api_url = utils.api_url()
return redirect(f'https://{api_url}/v1/vulns/{bug["id"]}')


Expand Down
2 changes: 1 addition & 1 deletion gcp/website/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def middleware(environ, start_response):

def create_app():
"""Create flask app."""
if utils.is_prod():
if utils.is_cloud_run():
logging_client = google.cloud.logging.Client()
logging_client.setup_logging()

Expand Down
Loading
Loading