Skip to content

Add Environment Variable Config Support #2378

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

Merged
merged 4 commits into from
Jul 7, 2023

Conversation

sweep-ai[bot]
Copy link
Contributor

@sweep-ai sweep-ai bot commented Jul 5, 2023

This PR adds support for loading server application configuration settings from environment variables. This feature provides an additional method of configuration, particularly useful in containerized or CI/CD environments where setting environment variables is often more convenient or secure than using configuration files.

The changes involve:

  • Adding a new case in the loadConfig function in packages/server/src/config.ts to handle the "env" option.
  • Implementing a new function loadEnvConfig that loads the configuration from environment variables.
  • Adding a new test case in packages/server/src/config.test.ts to verify that the "env" option in the loadConfig function works correctly.

The environment variables are expected to follow a specific naming convention. They should always use the MEDPLUM_ prefix and convert the camelCase name to CAPITALIZED_UNDERSCORE name. For nested objects, such as database and redis, an additional name component is added. For example, database.host would be MEDPLUM_DATABASE_HOST.

Fixes #2377.

To checkout this PR branch, run the following command in your terminal:

git checkout sweep/env-var-config-support

@sweep-ai sweep-ai bot requested a review from a team as a code owner July 5, 2023 20:26
@vercel
Copy link

vercel bot commented Jul 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
medplum-storybook ⬜️ Ignored (Inspect) Jul 5, 2023 11:49pm
medplum-www ⬜️ Ignored (Inspect) Jul 5, 2023 11:49pm

Copy link
Contributor Author

@sweep-ai sweep-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes required. The added code for loading configuration from environment variables in both packages/server/src/config.test.ts and packages/server/src/config.ts is well-written and doesn't contain any apparent logic errors or issues. Good job!

@coveralls
Copy link

coveralls commented Jul 5, 2023

Coverage Status

coverage: 94.252% (-0.006%) from 94.258% when pulling da66ab1 on sweep/env-var-config-support into 64f7362 on main.

@reshmakh reshmakh added the self-host Features and fixes related to self hosting label Jul 5, 2023
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

84.9% 84.9% Coverage
0.0% 0.0% Duplication

@codyebberson codyebberson added this pull request to the merge queue Jul 7, 2023
Merged via the queue into main with commit 4a2384a Jul 7, 2023
@codyebberson codyebberson deleted the sweep/env-var-config-support branch July 11, 2023 22:33
codyebberson added a commit that referenced this pull request Jul 13, 2023
Use eslint-config in examples (#2456)
Add bundle to resource array in MedplumClient (#2445)
Add server config for logLevel (#2437)
Allow `/email` path in CORS (#2455)
Add clientId as optional prop to RegisterForm (#2452)
Instructions on setting up new patient registration (#2453)
Enable sourcemaps in server docker image (#2449)
Automatically restart redis docker container on local dev (#2446)
Fixes #2439 - clarify node 18+ required (#2442)
Fix json bug in access controls docs (#2440)
Use user repo in project admin tools (#2435)
Preliminary article on auth integration patterns (#2422)
Move medplum-demo-bots to /examples (#2403)
Fixes #2431 - handle client_id in /auth/newuser (#2434)
Fix localStorage infinite loop bug (#2436)
Change SearchControl to default to accurate (#2432)
Updated title (#2433)
Add DocumentReference resource type to ServiceRequest timeline (#2428)
Added jwt bearer token auth to MedplumClient (#2408)
Update packages/core/src/typeschema/validation.test.ts (#2430)
Create sweep.yaml config file (#2427)
Update bot-basics.md (#2424)
Adding tests to confirm hidden fields behavior (#2425)
Fix validation log condition (#2421)
Clarify Mutations documentaiton (#2417)
Constraint validation  (#2321)
Document basic functionality of the Medplum App (#2405)
Fix code complexity warning in search param details (#2415)
Ignore graphiql in sonar analysis (#2414)
Fixed more sonar warnings (#2416)
Validate Medplum resource profiles (#2404)
Update manual mock to use aws-sdk-client-mock (#2407)
Fix sonar code smells (#2413)
Update packages/app/src/HomePage.tsx (#2412)
Update packages/app/src/FormPage.tsx (#2411)
Updating broken links found during demo (#2391)
Fixes #2396 - block reset password with external auth (#2399)
Added docs on $resend operation (#2394)
Updated homepage (#2243)
Add `~` to SearchControl count to indicate estimated counts (#2380)
Add Environment Variable Config Support (#2378)
Add merge group CI triggers (#2393)
Fixes regression in string array filters (#2392)
Perf improvement to getTypedPropertyValue (#2389)
Fix merge conflict in validation test (#2390)
Cut over to new validation logic (#2382)
Add test for profile walking into base type schema (#2388)
Adding documentation and examples for CLI optional params to connect to other fhir servers (#2303)
Update client-sesv2 manual mock to use aws-sdk-client-mock (#2381)
#1314 Add an API Collection for Postman, as well as an env template a… (#2325)
Document `_total` search param (#2379)
Fixes #2374 - updated jest babel config (#2375)
Implement slice validation (#2337)
Fix sonar warnings in repo.ts and search.ts (#2373)
Fixed build break (#2372)
Split repo.ts and search.ts (#2361)
Implement Alphabetical Sorting Using localeCompare (#2365)
Update lib-storage.ts manual mock to use aws-sdk-client-mock (#2358)
Fixes #2052 - Config option to save audit events (#2357)
Fixes #2304 - ProjectMembership access-policy search param (#2360)
Fixes #2333 - added $versions operation (#2359)
ImpliesAtom (#2352)
Update client-lambda manual mock to use aws-sdk-client-mock (#2347)
Deploy sourcemaps (#2356)
Fixes #2354 - always use normalizeOperationOutcome (#2355)
Fixes #2350 - estimated count filtering on human name (#2351)
Dependency upgrades (#2348)
Fixes #2343: Update project operation $expunge everything to use AsyncJob (#2345)
update CLI docs on bulk target-directory (#2344)
Fixes #2311 - better expression parsing in getSearchParameterDetails (#2324)
github-merge-queue bot pushed a commit that referenced this pull request Jul 13, 2023
Use eslint-config in examples (#2456)
Add bundle to resource array in MedplumClient (#2445)
Add server config for logLevel (#2437)
Allow `/email` path in CORS (#2455)
Add clientId as optional prop to RegisterForm (#2452)
Instructions on setting up new patient registration (#2453)
Enable sourcemaps in server docker image (#2449)
Automatically restart redis docker container on local dev (#2446)
Fixes #2439 - clarify node 18+ required (#2442)
Fix json bug in access controls docs (#2440)
Use user repo in project admin tools (#2435)
Preliminary article on auth integration patterns (#2422)
Move medplum-demo-bots to /examples (#2403)
Fixes #2431 - handle client_id in /auth/newuser (#2434)
Fix localStorage infinite loop bug (#2436)
Change SearchControl to default to accurate (#2432)
Updated title (#2433)
Add DocumentReference resource type to ServiceRequest timeline (#2428)
Added jwt bearer token auth to MedplumClient (#2408)
Update packages/core/src/typeschema/validation.test.ts (#2430)
Create sweep.yaml config file (#2427)
Update bot-basics.md (#2424)
Adding tests to confirm hidden fields behavior (#2425)
Fix validation log condition (#2421)
Clarify Mutations documentaiton (#2417)
Constraint validation  (#2321)
Document basic functionality of the Medplum App (#2405)
Fix code complexity warning in search param details (#2415)
Ignore graphiql in sonar analysis (#2414)
Fixed more sonar warnings (#2416)
Validate Medplum resource profiles (#2404)
Update manual mock to use aws-sdk-client-mock (#2407)
Fix sonar code smells (#2413)
Update packages/app/src/HomePage.tsx (#2412)
Update packages/app/src/FormPage.tsx (#2411)
Updating broken links found during demo (#2391)
Fixes #2396 - block reset password with external auth (#2399)
Added docs on $resend operation (#2394)
Updated homepage (#2243)
Add `~` to SearchControl count to indicate estimated counts (#2380)
Add Environment Variable Config Support (#2378)
Add merge group CI triggers (#2393)
Fixes regression in string array filters (#2392)
Perf improvement to getTypedPropertyValue (#2389)
Fix merge conflict in validation test (#2390)
Cut over to new validation logic (#2382)
Add test for profile walking into base type schema (#2388)
Adding documentation and examples for CLI optional params to connect to other fhir servers (#2303)
Update client-sesv2 manual mock to use aws-sdk-client-mock (#2381)
#1314 Add an API Collection for Postman, as well as an env template a… (#2325)
Document `_total` search param (#2379)
Fixes #2374 - updated jest babel config (#2375)
Implement slice validation (#2337)
Fix sonar warnings in repo.ts and search.ts (#2373)
Fixed build break (#2372)
Split repo.ts and search.ts (#2361)
Implement Alphabetical Sorting Using localeCompare (#2365)
Update lib-storage.ts manual mock to use aws-sdk-client-mock (#2358)
Fixes #2052 - Config option to save audit events (#2357)
Fixes #2304 - ProjectMembership access-policy search param (#2360)
Fixes #2333 - added $versions operation (#2359)
ImpliesAtom (#2352)
Update client-lambda manual mock to use aws-sdk-client-mock (#2347)
Deploy sourcemaps (#2356)
Fixes #2354 - always use normalizeOperationOutcome (#2355)
Fixes #2350 - estimated count filtering on human name (#2351)
Dependency upgrades (#2348)
Fixes #2343: Update project operation $expunge everything to use AsyncJob (#2345)
update CLI docs on bulk target-directory (#2344)
Fixes #2311 - better expression parsing in getSearchParameterDetails (#2324)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
self-host Features and fixes related to self hosting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sweep: Add support for env var config settings in packages/server/src/config.ts
3 participants