Skip to content

Commit

Permalink
Rename env var prefix MITOPEN_ to MITOL_ (#1388)
Browse files Browse the repository at this point in the history
Rename local dev env variables

Feedback
  • Loading branch information
rhysyngsun authored Aug 13, 2024
1 parent dd2992a commit 46e5931
Show file tree
Hide file tree
Showing 39 changed files with 194 additions and 179 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,21 @@ jobs:
./scripts/test/python_tests.sh
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres # pragma: allowlist secret
MITOPEN_SECURE_SSL_REDIRECT: "False"
MITOPEN_DB_DISABLE_SSL: "True"
MITOPEN_FEATURES_DEFAULT: "True"
MITOL_SECURE_SSL_REDIRECT: "False"
MITOL_DB_DISABLE_SSL: "True"
MITOL_FEATURES_DEFAULT: "True"
OPENSEARCH_URL: localhost:9200
CELERY_TASK_ALWAYS_EAGER: "True"
CELERY_BROKER_URL: redis://localhost:6379/4
CELERY_RESULT_BACKEND: redis://localhost:6379/4
TIKA_CLIENT_ONLY: "True"
MITOPEN_APP_BASE_URL: http://localhost:8062/
MITOL_APP_BASE_URL: http://localhost:8062/
MAILGUN_KEY: fake_mailgun_key
MAILGUN_SENDER_DOMAIN: other.fake.site
OPENSEARCH_INDEX: testindex
INDEXING_API_USERNAME: mitodl
MITOPEN_COOKIE_DOMAIN: localhost
MITOPEN_COOKIE_NAME: cookie_monster
MITOL_COOKIE_DOMAIN: localhost
MITOL_COOKIE_NAME: cookie_monster

- name: Upload coverage to CodeCov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:
- name: Webpack build
run: yarn run build
env:
MITOPEN_API_BASE_URL: https://api.mitopen-test.odl.mit.edu
MITOL_API_BASE_URL: https://api.mitlearn-test.odl.mit.edu

- name: Lints
run: yarn run lint-check
Expand Down
6 changes: 3 additions & 3 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
release: bash scripts/heroku-release-phase.sh
web: bin/start-nginx bin/start-pgbouncer newrelic-admin run-program uwsgi uwsgi.ini
worker: bin/start-pgbouncer newrelic-admin run-program celery -A main.celery:app worker -E -Q default --concurrency=2 -B -l $MITOPEN_LOG_LEVEL
extra_worker_2x: bin/start-pgbouncer newrelic-admin run-program celery -A main.celery:app worker -E -Q edx_content,default --concurrency=2 -l $MITOPEN_LOG_LEVEL
extra_worker_performance: bin/start-pgbouncer newrelic-admin run-program celery -A main.celery:app worker -E -Q edx_content,default -l $MITOPEN_LOG_LEVEL
worker: bin/start-pgbouncer newrelic-admin run-program celery -A main.celery:app worker -E -Q default --concurrency=2 -B -l $MITOL_LOG_LEVEL
extra_worker_2x: bin/start-pgbouncer newrelic-admin run-program celery -A main.celery:app worker -E -Q edx_content,default --concurrency=2 -l $MITOL_LOG_LEVEL
extra_worker_performance: bin/start-pgbouncer newrelic-admin run-program celery -A main.celery:app worker -E -Q edx_content,default -l $MITOL_LOG_LEVEL
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Article posts give users the option to upload a cover image, and we show a thumb
image in post listings. We use Embedly to generate that thumbnail, so they will appear as
broken images unless you configure your app to upload to S3. Steps:

1. Set `MITOPEN_USE_S3=True` in `.env`
1. Set `MITOL_USE_S3=True` in `.env`
1. Also in `.env`, set these AWS variables: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`,
`AWS_STORAGE_BUCKET_NAME`

Expand Down Expand Up @@ -222,8 +222,8 @@ Once these are set (and you've restarted the app), you should see events flowing

A Javascript bundle of exported frontend components can be generated for use in external websites that have CORS allowance into a given instance of `mit-open`. There are a few settings you might want to change in order to get the expected results.

- `MITOPEN_AXIOS_WITH_CREDENTIALS` - This sets `withCredentials: true` when initializing the Axios API, which tells the end user's browser to send along any browser level cookies for the current domain when making CORS requests
- `MITOPEN_API_BASE_URL` - This sets the base url used for API requests, which will need to be set to a fully qualified url pointing to an instance of `mit-open` (i.e. https://learn.mit.edu) in order for requests from the external site to reach the proper destination
- `MITOL_AXIOS_WITH_CREDENTIALS` - This sets `withCredentials: true` when initializing the Axios API, which tells the end user's browser to send along any browser level cookies for the current domain when making CORS requests
- `MITOL_API_BASE_URL` - This sets the base url used for API requests, which will need to be set to a fully qualified url pointing to an instance of `mit-open` (i.e. https://learn.mit.edu) in order for requests from the external site to reach the proper destination
- `CORS_ALLOWED_ORIGINS`, `CSRF_TRUSTED_ORIGINS` - On the instance of `mit-open` that the externally hosted components will access via the API, the domains of any sites that need CORS access need to be here as a list of strings

To build the bundle of exported components, run:
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ Version 0.13.2 (Released June 13, 2024)
--------------

- Update education options and add to schema (#1069)
- local dev: Read `MITOPEN_AXIOS_BASE_PATH` from env (#1065)
- local dev: Read `MITOL_AXIOS_BASE_PATH` from env (#1065)
- Add featured courses carousel to unit channel page (#1059)
- Add ordering to testimonials, adjust view on homepage testimonial carousel (#1067)
- Change channel type and url from "offeror" to "unit" (#1031)
Expand Down
50 changes: 25 additions & 25 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,92 +285,92 @@
"description": "Base default URL for OLL courses",
"required": false
},
"MITOPEN_ADMIN_EMAIL": {
"MITOL_ADMIN_EMAIL": {
"description": "E-mail to send 500 reports to."
},
"MITOPEN_AUTHENTICATION_PLUGINS": {
"MITOL_AUTHENTICATION_PLUGINS": {
"description": "List of pluggy plugins to use for authentication",
"required": false
},
"MITOPEN_LEARNING_RESOURCES_PLUGINS": {
"MITOL_LEARNING_RESOURCES_PLUGINS": {
"description": "List of pluggy plugins to use for learning resources",
"required": false
},
"MITOPEN_APP_BASE_URL": {
"MITOL_APP_BASE_URL": {
"description": "Base url to create links to the app"
},
"MITOPEN_COOKIE_NAME": {
"MITOL_COOKIE_NAME": {
"description": "Name of the cookie for the JWT auth token"
},
"MITOPEN_COOKIE_DOMAIN": {
"MITOL_COOKIE_DOMAIN": {
"description": "Domain for the cookie for the JWT auth token"
},
"MITOPEN_DB_CONN_MAX_AGE": {
"MITOL_DB_CONN_MAX_AGE": {
"value": "0"
},
"MITOPEN_DB_DISABLE_SSL": {
"MITOL_DB_DISABLE_SSL": {
"value": "True"
},
"MITOPEN_DB_DISABLE_SS_CURSORS": {
"MITOL_DB_DISABLE_SS_CURSORS": {
"description": "Disable server-side cursors",
"required": false
},
"MITOPEN_EMAIL_HOST": {
"MITOL_EMAIL_HOST": {
"description": "Outgoing e-mail settings"
},
"MITOPEN_EMAIL_PASSWORD": {
"MITOL_EMAIL_PASSWORD": {
"description": "Outgoing e-mail settings"
},
"MITOPEN_EMAIL_PORT": {
"MITOL_EMAIL_PORT": {
"description": "Outgoing e-mail settings",
"value": "587"
},
"MITOPEN_EMAIL_TLS": {
"MITOL_EMAIL_TLS": {
"description": "Outgoing e-mail settings",
"value": "True"
},
"MITOPEN_EMAIL_USER": {
"MITOL_EMAIL_USER": {
"description": "Outgoing e-mail settings"
},
"MITOPEN_ENVIRONMENT": {
"MITOL_ENVIRONMENT": {
"description": "The execution environment that the app is in (e.g. dev, staging, prod)"
},
"MITOPEN_FROM_EMAIL": {
"MITOL_FROM_EMAIL": {
"description": "E-mail to use for the from field"
},
"MITOPEN_LOG_LEVEL": {
"MITOL_LOG_LEVEL": {
"description": "The log level for the application",
"required": true,
"value": "INFO"
},
"MITOPEN_NEW_USER_LOGIN_URL": {
"MITOL_NEW_USER_LOGIN_URL": {
"description": "Url to redirect new users to",
"required": false
},
"MITOPEN_JWT_SECRET": {
"MITOL_JWT_SECRET": {
"description": "Shared secret for JWT auth tokens",
"required": true
},
"MITOPEN_SECURE_SSL_REDIRECT": {
"MITOL_SECURE_SSL_REDIRECT": {
"description": "Application-level SSL redirect setting.",
"value": "True"
},
"MITOPEN_SIMILAR_RESOURCES_COUNT": {
"MITOL_SIMILAR_RESOURCES_COUNT": {
"description": "Number of similar resources to return",
"required": false
},
"MITOPEN_TITLE": {
"MITOL_TITLE": {
"description": "Title of the MIT Open site",
"required": false
},
"MITOPEN_SUPPORT_EMAIL": {
"MITOL_SUPPORT_EMAIL": {
"description": "Email address listed for customer support"
},
"MITOPEN_UNSUBSCRIBE_TOKEN_MAX_AGE_SECONDS": {
"MITOL_UNSUBSCRIBE_TOKEN_MAX_AGE_SECONDS": {
"description": "Maximum age of unsubscribe tokens in seconds",
"required": false
},
"MITOPEN_USE_S3": {
"MITOL_USE_S3": {
"description": "Use S3 for storage backend (required on Heroku)",
"value": "False"
},
Expand Down
2 changes: 1 addition & 1 deletion authentication/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_plugin_manager():
"""Return the plugin manager for authentication hooks"""
pm = pluggy.PluginManager(app_config.name)
pm.add_hookspecs(AuthenticationHooks)
for module in settings.MITOPEN_AUTHENTICATION_PLUGINS.split(","):
for module in settings.MITOL_AUTHENTICATION_PLUGINS.split(","):
if module:
plugin_cls = import_string(module)
pm.register(plugin_cls())
Expand Down
6 changes: 3 additions & 3 deletions docker-compose-notebook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ x-environment: &py-environment
DEV_ENV: "True" # necessary to have nginx connect to web container
NODE_ENV: "production"
DATABASE_URL: postgres://postgres:postgres@db:5432/postgres # pragma: allowlist secret
MITOPEN_SECURE_SSL_REDIRECT: "False"
MITOPEN_DB_DISABLE_SSL: "True"
MITOPEN_FEATURES_DEFAULT: "True"
MITOL_SECURE_SSL_REDIRECT: "False"
MITOL_DB_DISABLE_SSL: "True"
MITOL_FEATURES_DEFAULT: "True"
OPENSEARCH_URL: elastic:9200
CELERY_TASK_ALWAYS_EAGER: "False"
CELERY_BROKER_URL: redis://redis:6379/4
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ services:
command: >
/bin/bash -c '
sleep 3;
celery -A main.celery:app worker -Q default -B -l ${MITOPEN_LOG_LEVEL:-INFO} &
celery -A main.celery:app worker -Q edx_content,default -l ${MITOPEN_LOG_LEVEL:-INFO}'
celery -A main.celery:app worker -Q default -B -l ${MITOL_LOG_LEVEL:-INFO} &
celery -A main.celery:app worker -Q edx_content,default -l ${MITOL_LOG_LEVEL:-INFO}'
links:
- db
- opensearch-node-mitopen
Expand Down
10 changes: 5 additions & 5 deletions env/backend.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ CORS_ALLOWED_ORIGINS='["http://open.odl.local:8062"]'
CSRF_TRUSTED_ORIGINS='["http://open.odl.local:8062", "http://api.open.odl.local:8063"]'
CSRF_COOKIE_DOMAIN=open.odl.local
CSRF_COOKIE_SECURE=False
MITOPEN_COOKIE_DOMAIN=open.odl.local
MITOPEN_COOKIE_NAME=discussions
MITOL_COOKIE_DOMAIN=open.odl.local
MITOL_COOKIE_NAME=discussions


DEBUG=True
Expand All @@ -18,9 +18,9 @@ DEV_ENV=true

DATABASE_URL=postgres://postgres:postgres@db:5432/postgres

MITOPEN_DB_DISABLE_SSL=True
MITOPEN_FEATURES_DEFAULT=True
MITOPEN_SECURE_SSL_REDIRECT=False
MITOL_DB_DISABLE_SSL=True
MITOL_FEATURES_DEFAULT=True
MITOL_SECURE_SSL_REDIRECT=False

OPENSEARCH_URL=opensearch-node-mitopen:9200
OPENSEARCH_INDEX=discussions_local
Expand Down
4 changes: 2 additions & 2 deletions env/backend.local.example.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MITOPEN_JWT_SECRET=
# MITOPEN_USE_S3=True
# MITOL_JWT_SECRET=
# MITOL_USE_S3=True
# MAILGUN_SENDER_DOMAIN=
# MAILGUN_KEY=
# MAILGUN_RECIPIENT_OVERRIDE=
Expand Down
12 changes: 6 additions & 6 deletions env/ci.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
NODE_ENV=production
DEV_ENV=True
DATABASE_URL=postgres://postgres:postgres@db:5432/e2e_postgres # pragma: allowlist secret
MITOPEN_SECURE_SSL_REDIRECT=False
MITOPEN_DB_DISABLE_SSL=True
MITOPEN_FEATURES_DEFAULT=True
MITOL_SECURE_SSL_REDIRECT=False
MITOL_DB_DISABLE_SSL=True
MITOL_FEATURES_DEFAULT=True
OPENSEARCH_URL=opensearch-node-mitopen:9200
CELERY_TASK_ALWAYS_EAGER=False
CELERY_BROKER_URL=redis://redis:6379/4
CELERY_RESULT_BACKEND=redis://redis:6379/4
TIKA_CLIENT_ONLY=True
MITOPEN_APP_BASE_URL=http://localhost:8063/
MITOL_APP_BASE_URL=http://localhost:8063/
MAILGUN_KEY=fake_mailgun_key
MAILGUN_SENDER_DOMAIN=other.fake.site
OPENSEARCH_INDEX=testindex
MITOPEN_COOKIE_DOMAIN=localhost
MITOPEN_COOKIE_NAME=cookie_monster
MITOL_COOKIE_DOMAIN=localhost
MITOL_COOKIE_NAME=cookie_monster
2 changes: 1 addition & 1 deletion env/frontend.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NODE_ENV=development
PORT=8062
MITOPEN_AXIOS_WITH_CREDENTIALS=true
MITOL_AXIOS_WITH_CREDENTIALS=true
6 changes: 3 additions & 3 deletions env/shared.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MITOPEN_API_BASE_URL=http://api.open.odl.local:8063
MITOPEN_APP_BASE_URL=http://open.odl.local:8062
MITOPEN_SUPPORT_EMAIL=support@localhost
MITOL_API_BASE_URL=http://api.open.odl.local:8063
MITOL_APP_BASE_URL=http://open.odl.local:8062
MITOL_SUPPORT_EMAIL=support@localhost

POSTHOG_TIMEOUT_MS=1500
4 changes: 2 additions & 2 deletions env/shared.local.example.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MITOPEN_API_BASE_URL=http://api.open.odl.local:8063
# MITOPEN_APP_BASE_URL=http://open.odl.local:8063
# MITOL_API_BASE_URL=http://api.open.odl.local:8063
# MITOL_APP_BASE_URL=http://open.odl.local:8063
# POSTHOG_PROJECT_API_KEY=
# POSTHOG_TIMEOUT_MS=1500
# EMBEDLY_KEY=
4 changes: 2 additions & 2 deletions fixtures/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def jwt_token(db, user, client, rf, settings): # noqa: ARG001
jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
payload = jwt_payload_handler(user)
token = jwt_encode_handler(payload)
client.cookies[settings.MITOPEN_COOKIE_NAME] = token
rf.cookies.load({settings.MITOPEN_COOKIE_NAME: token})
client.cookies[settings.MITOL_COOKIE_NAME] = token
rf.cookies.load({settings.MITOL_COOKIE_NAME: token})
return token


Expand Down
4 changes: 2 additions & 2 deletions frontends/api/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const config: Config.InitialOptions = {
],
globals: {
APP_SETTINGS: {
MITOPEN_AXIOS_WITH_CREDENTIALS: false,
MITOPEN_API_BASE_URL: "https://api.test.learn.mit.edu",
MITOL_AXIOS_WITH_CREDENTIALS: false,
MITOL_API_BASE_URL: "https://api.test.learn.mit.edu",
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const instance = axios.create({
xsrfCookieName: "csrftoken",
xsrfHeaderName: "X-CSRFToken",
withXSRFToken: true,
withCredentials: APP_SETTINGS.MITOPEN_AXIOS_WITH_CREDENTIALS,
withCredentials: APP_SETTINGS.MITOL_AXIOS_WITH_CREDENTIALS,
})

export default instance
4 changes: 2 additions & 2 deletions frontends/api/src/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import {

import axiosInstance from "./axios"

const { MITOPEN_API_BASE_URL } = APP_SETTINGS
const { MITOL_API_BASE_URL } = APP_SETTINGS

const BASE_PATH = MITOPEN_API_BASE_URL?.replace(/\/+$/, "") ?? ""
const BASE_PATH = MITOL_API_BASE_URL?.replace(/\/+$/, "") ?? ""

const learningResourcesApi = new LearningResourcesApi(
undefined,
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/test-utils/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type {
import type { BaseAPI } from "../generated/v1/base"
import type { BaseAPI as BaseAPIv0 } from "../generated/v0/base"

const { MITOPEN_API_BASE_URL: API_BASE_URL } = APP_SETTINGS
const { MITOL_API_BASE_URL: API_BASE_URL } = APP_SETTINGS

// OpenAPI Generator declares parameters using interfaces, which makes passing
// them to functions a little annoying.
Expand Down
4 changes: 2 additions & 2 deletions frontends/api/src/types/settings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export declare global {
const APP_SETTINGS: {
MITOPEN_AXIOS_WITH_CREDENTIALS?: boolean
MITOPEN_API_BASE_URL?: string
MITOL_AXIOS_WITH_CREDENTIALS?: boolean
MITOL_API_BASE_URL?: string
}
}
2 changes: 1 addition & 1 deletion frontends/mit-open/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const config: Config.InitialOptions = {
globals: {
APP_SETTINGS: {
EMBEDLY_KEY: "embedly_key",
MITOPEN_API_BASE_URL: "https://api.test.learn.mit.edu",
MITOL_API_BASE_URL: "https://api.test.learn.mit.edu",
PUBLIC_URL: "",
SITE_NAME: "MIT Open",
},
Expand Down
Loading

0 comments on commit 46e5931

Please sign in to comment.