feat: Support pre-aggregation-specific data source credentials (CORE-…#10587
feat: Support pre-aggregation-specific data source credentials (CORE-…#10587
Conversation
9ab1520 to
141cdad
Compare
141cdad to
05bc016
Compare
| if (preAggregations) { | ||
| const dsMatch = key.match(/^(CUBEJS_DS_[A-Z0-9_]+?_)(DB_|JDBC_|AWS_|DATABASE|FIREBOLT_)(.*)/); | ||
| if (dsMatch) { | ||
| return `${dsMatch[1]}PRE_AGGREGATIONS_${dsMatch[2]}${dsMatch[3]}`; | ||
| } | ||
|
|
||
| if (key.startsWith('CUBEJS_')) { | ||
| return key.replace(/^CUBEJS_/, 'CUBEJS_PRE_AGGREGATIONS_'); | ||
| } | ||
| } |
There was a problem hiding this comment.
Suggestion: Consider adding a unit test for edge cases in the regex. The regex ^(CUBEJS_DS_[A-Z0-9_]+?_)(DB_|JDBC_|AWS_|DATABASE|FIREBOLT_)(.*) uses a non-greedy match for the DS name which could behave unexpectedly with certain datasource names.
For example, a datasource named db would produce the key CUBEJS_DS_DB_DB_HOST. The non-greedy [A-Z0-9_]+?_ would match CUBEJS_DS_D first, then try B_DB_HOST against the alternation — B_ doesn't match DB_, so it extends to CUBEJS_DS_DB_ and then matches DB_HOST. This works, but edge cases like datasource names containing DB, AWS, JDBC, etc. as substrings should be tested.
Also, DATABASE in the alternation doesn't have a trailing underscore. For CUBEJS_DS_FOO_DATABASE_SECRET_ARN, group 2 captures DATABASE and group 3 captures _SECRET_ARN (including the leading underscore). This produces CUBEJS_DS_FOO_PRE_AGGREGATIONS_DATABASE_SECRET_ARN which is correct, but the asymmetry with other alternatives (which have trailing _) is subtle.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #10587 +/- ##
===========================================
- Coverage 83.40% 57.94% -25.47%
===========================================
Files 250 215 -35
Lines 75261 16639 -58622
Branches 0 3345 +3345
===========================================
- Hits 62775 9641 -53134
+ Misses 12486 6509 -5977
- Partials 0 489 +489
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…123) refactor: Replace envVar helper with getVar in env.ts refactor: Remove getVar helper, inline get(keyByDataSource(...)) directly
d5e3ae5 to
60acd28
Compare
35f1f5a to
7d19fce
Compare
No description provided.