Coverage for webapp/config.py: 94%
36 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-15 22:43 +0000
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-15 22:43 +0000
1import os
2from canonicalwebteam.flask_base.env import load_plain_env_variables
5class ConfigurationError(Exception):
6 pass
9# Load the prefixed FLASK_* env vars into env vars without the prefix. We have
10# to do this explicitly here because otherwise the config module is imported
11# by other files before the FlaskBase app gets initialized and does this by
12# itself, meaning that the variables below are not set correctly
13load_plain_env_variables()
15SECRET_KEY = os.getenv("SECRET_KEY")
16LOGIN_URL = os.getenv("LOGIN_URL", "https://login.ubuntu.com")
17BSI_URL = os.getenv("BSI_URL", "https://build.snapcraft.io")
18ENVIRONMENT = os.getenv("ENVIRONMENT", "devel")
19IS_DEVELOPMENT = ENVIRONMENT == "devel"
20COMMIT_ID = os.getenv("COMMIT_ID", "commit_id")
21SENTRY_DSN = os.getenv("SENTRY_DSN", "").strip()
22SENTRY_CONFIG = {"release": COMMIT_ID, "environment": ENVIRONMENT}
23DNS_VERIFICATION_SALT = os.getenv("DNS_VERIFICATION_SALT")
25# Vite integration config values
26VITE_MODE = "development" if IS_DEVELOPMENT else "production"
27VITE_PORT = os.getenv("VITE_PORT", 5173)
28VITE_OUTDIR = os.getenv("VITE_OUTDIR", "static/js/dist/vite")
29VITE_INLINE_JS = os.getenv("VITE_INLINE_JS", "true").lower() == "true"
30# VITE_REACT controls whether React hot module reload scripts are injected when
31# running in dev mode; the setting has no effect in prod mode
32VITE_REACT = True
34if ENVIRONMENT != "devel":
35 SESSION_COOKIE_SAMESITE = "None"
36 SESSION_COOKIE_SECURE = True
38WEBAPP_CONFIG = {"LAYOUT": "_layout.html", "STORE_NAME": "Snap store"}
40WEBAPP_EXTRA_HEADERS = {}
42# Ten years default cache time on static files
43SEND_FILE_MAX_AGE_DEFAULT = 10 * 365 * 24 * 60 * 60
45CONTENT_DIRECTORY = {"PUBLISHER_PAGES": "store/content/publishers/"}
47# Docs search
48SEARCH_API_KEY = os.getenv("SEARCH_API_KEY")
49SEARCH_API_URL = "https://www.googleapis.com/customsearch/v1"
50SEARCH_CUSTOM_ID = "009048213575199080868:i3zoqdwqk8o"
52APP_NAME = "snapcraft"
53ANALYTICS_ENDPOINT = os.getenv("ANALYTICS_ENDPOINT", "").strip()
55# Fallback icon shown when a snap has no icon of its own
56DEFAULT_ICON_URL = (
57 "https://assets.ubuntu.com/v1/be6eb412-snapcraft-missing-icon.svg"
58)
60REPORT_SHEET_URL = os.getenv("REPORT_SHEET_URL", "").strip()
61TURNSTILE_SITE_KEY = os.getenv("TURNSTILE_SITE_KEY", "").strip()
62TURNSTILE_SECRET_KEY = os.getenv("TURNSTILE_SECRET_KEY", "").strip()
63TURNSTILE_VERIFY_URL = os.getenv(
64 "TURNSTILE_VERIFY_URL",
65 "https://challenges.cloudflare.com/turnstile/v0/siteverify",
66).strip()