-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add matrix to compare envvar usage across components
issue: open-zaak/open-zaak#1629
- Loading branch information
Showing
2 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import csv | ||
import re | ||
from collections import defaultdict | ||
from pathlib import Path | ||
|
||
import requests | ||
|
||
SETTINGS_PATHS = [ | ||
"https://raw.githubusercontent.com/open-zaak/open-zaak/main/src/openzaak/conf", | ||
"https://raw.githubusercontent.com/open-zaak/open-notificaties/main/src/nrc/conf", | ||
"https://raw.githubusercontent.com/maykinmedia/objects-api/master/src/objects/conf", | ||
"https://raw.githubusercontent.com/maykinmedia/objecttypes-api/master/src/objecttypes/conf", # noqa | ||
"https://raw.githubusercontent.com/maykinmedia/open-klant/master/src/openklant/conf", # noqa | ||
] | ||
SETTINGS_FILES = [ | ||
"api.py", | ||
"base.py", | ||
"ci.py", | ||
"dev.py", | ||
"docker.py", | ||
"production.py", | ||
"staging.py", | ||
"test.py", | ||
] | ||
|
||
ENVVAR_REGEX = re.compile( | ||
r'config\((?:(?:\"|\')|[\s#A-z0-9:\/-]*")([A-z0-9-_]+)(?:\"|\')' | ||
) | ||
|
||
|
||
def parse_settings_for_repo(repository_link, settings_file): | ||
url = f"{repository_link}/{settings_file}" | ||
if ( | ||
"openzaak" in repository_link or "nrc" in repository_link | ||
) and settings_file in ["base.py", "api.py"]: | ||
url = f"{repository_link}/includes/{settings_file}" | ||
|
||
file_data = requests.get(url).text | ||
|
||
return ENVVAR_REGEX.findall(file_data) | ||
|
||
|
||
def parse_all(): | ||
results = defaultdict(list) | ||
for base_dir in SETTINGS_PATHS: | ||
project_name = base_dir.split("/")[-5] | ||
for settings_file in SETTINGS_FILES: | ||
envvar_names = parse_settings_for_repo(base_dir, settings_file) | ||
for name in envvar_names: | ||
results[name].append(project_name) | ||
return results | ||
|
||
|
||
def export_csv(data): | ||
Path("reports").mkdir(parents=True, exist_ok=True) | ||
with open("reports/envvar_matrix.csv", "w") as f: | ||
writer = csv.writer(f) | ||
all_components = sorted( | ||
list(set(component for values in data.values() for component in values)) | ||
) | ||
export = [["var name"] + all_components] | ||
for var_name, components in data.items(): | ||
export.append( | ||
[var_name] | ||
+ [ | ||
"true" if component in components else "false" | ||
for component in all_components | ||
] | ||
) | ||
writer.writerows(export) | ||
|
||
|
||
data = parse_all() | ||
export_csv(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
var name,objects-api,objecttypes-api,open-klant,open-notificaties,open-zaak | ||
SITE_ID,true,true,true,true,true | ||
SECRET_KEY,true,true,true,true,true | ||
DEBUG,true,true,true,true,true | ||
ALLOWED_HOSTS,true,true,true,true,true | ||
USE_X_FORWARDED_HOST,true,true,false,false,true | ||
IS_HTTPS,true,true,true,true,true | ||
DB_NAME,true,true,true,true,true | ||
DB_USER,true,true,true,true,true | ||
DB_PASSWORD,true,true,true,true,true | ||
DB_HOST,true,true,true,true,true | ||
DB_PORT,true,true,true,true,true | ||
GEOS_LIBRARY_PATH,false,false,false,false,true | ||
GDAL_LIBRARY_PATH,false,false,false,false,true | ||
CACHE_DEFAULT,true,false,true,true,true | ||
CACHE_AXES,true,false,true,true,true | ||
EMAIL_HOST,true,true,true,true,true | ||
EMAIL_PORT,true,true,true,true,true | ||
EMAIL_HOST_USER,true,true,true,true,true | ||
EMAIL_HOST_PASSWORD,true,true,true,true,true | ||
EMAIL_USE_TLS,true,true,true,true,true | ||
LOG_STDOUT,false,false,true,false,true | ||
LOG_LEVEL,false,false,false,false,true | ||
LOG_QUERIES,false,false,false,false,true | ||
LOG_REQUESTS,true,false,true,true,true | ||
OPENZAAK_DOMAIN,false,false,false,false,true | ||
OPENZAAK_REWRITE_HOST,false,false,false,false,true | ||
ENVIRONMENT,true,true,true,false,true | ||
MIN_UPLOAD_SIZE,false,false,false,false,true | ||
DOCUMENTEN_UPLOAD_CHUNK_SIZE,false,false,false,false,true | ||
DOCUMENTEN_UPLOAD_READ_CHUNK,false,false,false,false,true | ||
SUBPATH,true,true,true,true,true | ||
GIT_SHA,false,false,true,true,true | ||
RELEASE,false,false,true,true,true | ||
NUM_PROXIES,false,false,true,true,true | ||
CORS_ALLOW_ALL_ORIGINS,false,false,false,true,true | ||
CORS_ALLOWED_ORIGINS,false,false,false,true,true | ||
CORS_ALLOWED_ORIGIN_REGEXES,false,false,false,true,true | ||
CORS_EXTRA_ALLOW_HEADERS,false,false,false,true,true | ||
CSRF_TRUSTED_ORIGINS,false,false,false,false,true | ||
SENDFILE_BACKEND,false,false,false,false,true | ||
NOTIFICATIONS_DISABLED,true,false,true,false,true | ||
LOOSE_FK_LOCAL_BASE_URLS,false,false,false,false,true | ||
SENTRY_DSN,true,true,true,true,true | ||
CELERY_RESULT_BACKEND,true,false,false,true,true | ||
ELASTIC_APM_SERVER_URL,true,true,false,true,true | ||
ELASTIC_APM_SECRET_TOKEN,true,true,true,true,true | ||
LOG_OUTGOING_REQUESTS_DB_SAVE,true,false,true,true,true | ||
JWT_EXPIRY,false,false,false,false,true | ||
JWT_LEEWAY,false,false,false,false,true | ||
CMIS_ENABLED,false,false,false,false,true | ||
CMIS_MAPPER_FILE,false,false,false,false,true | ||
CMIS_URL_MAPPING_ENABLED,false,false,false,false,true | ||
IMPORT_REQUESTS_CACHE_NAME,false,false,false,false,true | ||
ZAAK_EIGENSCHAP_WAARDE_VALIDATION,false,false,false,false,true | ||
SITES_CONFIG_ENABLE,true,true,false,true,true | ||
OPENZAAK_ORGANIZATION,false,false,false,false,true | ||
NOTIF_OPENZAAK_CONFIG_ENABLE,false,false,false,false,true | ||
NOTIF_OPENZAAK_CLIENT_ID,false,false,false,true,true | ||
NOTIF_OPENZAAK_SECRET,false,false,false,true,true | ||
OPENZAAK_NOTIF_CONFIG_ENABLE,false,false,false,true,true | ||
NOTIF_API_ROOT,false,false,false,false,true | ||
NOTIF_API_OAS,false,false,false,false,true | ||
OPENZAAK_NOTIF_CLIENT_ID,false,false,false,true,true | ||
OPENZAAK_NOTIF_SECRET,false,false,false,true,true | ||
OPENZAAK_SELECTIELIJST_CONFIG_ENABLE,false,false,false,false,true | ||
SELECTIELIJST_API_ROOT,false,false,false,false,true | ||
SELECTIELIJST_API_OAS,false,false,false,false,true | ||
SELECTIELIJST_ALLOWED_YEARS,false,false,false,false,true | ||
SELECTIELIJST_DEFAULT_YEAR,false,false,false,false,true | ||
DEMO_CONFIG_ENABLE,true,true,false,false,true | ||
DEMO_CLIENT_ID,false,false,false,false,true | ||
DEMO_SECRET,false,false,false,false,true | ||
PROFILE,false,false,false,false,true | ||
DISABLE_APM_IN_DEV,false,false,false,true,true | ||
DB_CONN_MAX_AGE,false,false,false,false,true | ||
LOG_OUTGOING_REQUESTS_DB_SAVE_BODY,false,false,false,true,false | ||
LOG_OUTGOING_REQUESTS_EMIT_BODY,false,false,false,true,false | ||
LOG_NOTIFICATIONS_IN_DB,false,false,false,true,false | ||
PUBLISH_BROKER_URL,false,false,false,true,false | ||
CELERY_BROKER_URL,true,false,false,true,false | ||
NOTIFICATION_NUMBER_OF_DAYS_RETAINED,false,false,false,true,false | ||
ELASTIC_APM_TRANSACTION_SAMPLE_RATE,false,false,false,true,false | ||
OPENNOTIFICATIES_DOMAIN,false,false,false,true,false | ||
OPENNOTIFICATIES_ORGANIZATION,false,false,false,true,false | ||
AUTHORIZATION_CONFIG_ENABLE,false,false,false,true,false | ||
AUTORISATIES_API_ROOT,false,false,false,true,false | ||
NOTIFICATION_RETRY_CONFIG_ENABLE,false,false,false,true,false | ||
NOTIFICATION_DELIVERY_MAX_RETRIES,false,false,false,true,false | ||
NOTIFICATION_DELIVERY_RETRY_BACKOFF,false,false,false,true,false | ||
NOTIFICATION_DELIVERY_RETRY_BACKOFF_MAX,false,false,false,true,false | ||
CACHE_OIDC,true,false,false,false,false | ||
DEFAULT_FROM_EMAIL,true,true,false,false,false | ||
VERSION_TAG,true,true,false,false,false | ||
ELASTIC_APM_SERVICE_NAME,true,true,false,false,false | ||
DISABLE_2FA,true,true,false,false,false | ||
CELERY_TASK_HARD_TIME_LIMIT,true,false,false,false,false | ||
CELERY_TASK_SOFT_TIME_LIMIT,true,false,false,false,false | ||
OBJECTS_DOMAIN,true,false,false,false,false | ||
OBJECTS_ORGANIZATION,true,false,false,false,false | ||
OBJECTS_OBJECTTYPES_CONFIG_ENABLE,true,true,false,false,false | ||
OBJECTTYPES_API_ROOT,true,false,false,false,false | ||
OBJECTTYPES_API_OAS,true,false,false,false,false | ||
OBJECTS_OBJECTTYPES_TOKEN,true,true,false,false,false | ||
DEMO_TOKEN,true,true,false,false,false | ||
DEMO_PERSON,true,true,false,false,false | ||
DEMO_EMAIL,true,true,false,false,false | ||
OBJECTTYPES_DOMAIN,false,true,false,false,false | ||
OBJECTTYPES_ORGANIZATION,false,true,false,false,false | ||
OBJECTS_OBJECTTYPES_PERSON,false,true,false,false,false | ||
OBJECTS_OBJECTTYPES_EMAIL,false,true,false,false,false | ||
SESSION_COOKIE_SECURE,false,true,false,false,false | ||
SESSION_COOKIE_HTTPONLY,false,true,false,false,false | ||
CSRF_COOKIE_SECURE,false,true,false,false,false | ||
DB_ENGINE,false,false,true,false,false | ||
LOG_OUTGOING_REQUESTS_MAX_AGE,false,false,true,false,false |