Skip to content
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

Switch primaryDatasource -> datasources #7678

Merged
merged 5 commits into from
Sep 18, 2024
Merged

Switch primaryDatasource -> datasources #7678

merged 5 commits into from
Sep 18, 2024

Conversation

joehan
Copy link
Contributor

@joehan joehan commented Sep 18, 2024

Description

Switching primaryDatasource -> datasources, as part of the move to v1beta apis.

Copy link
Contributor

@hlshen hlshen left a comment

Choose a reason for hiding this comment

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

super nit: should we make it a helper func? I know it's one line of code but could be findPrimaryDataSource(schema).postgresql....

LGTM either way

@@ -262,16 +262,17 @@ async function promptForService(
info.serviceId = serviceName.serviceId;
info.locationId = serviceName.location;
if (choice.schema) {
if (choice.schema.primaryDatasource.postgresql?.cloudSql.instance) {
const primaryDatasource = choice.schema.datasources.find((d) => d.postgresql);
Copy link
Member

Choose a reason for hiding this comment

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

nit: Can multiple datasources specify postgresql? Also given that the backend resource doesn't specify a "primary" datasource anymore -- is the "primary" datasource intended to just be the first in the list?

Maybe for now we can just pull the first datasource for now and verify it has a postgresql field?

Copy link
Contributor Author

@joehan joehan Sep 18, 2024

Choose a reason for hiding this comment

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

This is definitely a short sighted solution on my end, because we will definitely need a pretty major overhaul of the init code once we support multiple datasources. Find only grabs the first item in the list for which the function returns true, so right now this just grabs the first postgres datasource.

const databaseId = s.schema.primaryDatasource.postgresql?.database;
if (!instanceId || !databaseId) {
return Promise.resolve();
const primaryDatasource = s.schema.datasources.find((d) => d.postgresql);
Copy link
Member

Choose a reason for hiding this comment

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

nit: For future-proofing (since the "primary" datasource won't necessarily be the Postgres one) would it make more sense to name this postgresDatasource?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, will rename

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 20 lines in your changes missing coverage. Please review.

Project coverage is 56.84%. Comparing base (18e3189) to head (bdf82e2).
Report is 16 commits behind head on master.

Files with missing lines Patch % Lines
src/dataconnect/schemaMigration.ts 0.00% 9 Missing ⚠️
src/deploy/dataconnect/deploy.ts 0.00% 8 Missing ⚠️
src/init/features/dataconnect/index.ts 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7678      +/-   ##
==========================================
- Coverage   56.91%   56.84%   -0.08%     
==========================================
  Files         396      396              
  Lines       27599    27652      +53     
  Branches     5692     5709      +17     
==========================================
+ Hits        15708    15718      +10     
- Misses      11723    11765      +42     
- Partials      168      169       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joehan joehan enabled auto-merge (squash) September 18, 2024 19:19
@joehan joehan merged commit eb18f4b into master Sep 18, 2024
40 of 41 checks passed
@joehan joehan deleted the jh-primaryDS branch September 18, 2024 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants