Skip to content

Conversation

Berlioz
Copy link
Contributor

@Berlioz Berlioz commented Sep 9, 2022

Based on bugbash feedback from @taeold and @colerogers.

We repurpose the .secret field of ParamValue (which wasn't being used anyway after we washed our hands of handling Secrets ourselves) to be .internal, which designates a param that we generated which shouldn't be written to disk or the runtime process.env.

We make the fields of FirebaseConfig--project id, RTDB URL, and storage bucket--available as internal params to the resolution process.

In order for this to do anything useful, the SDK will have to export corresponding special Expressions that users can use in their Functions; these Expressions will not add anything to the manifest (since they'll be generated by this code anyway) but will have to have their .value() function special cased to read from process.env.firebase_config instead.

@Berlioz Berlioz requested review from colerogers and taeold September 9, 2022 23:43
@Berlioz Berlioz self-assigned this Sep 9, 2022
@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2022

Codecov Report

Base: 56.93% // Head: 56.96% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (634c36a) compared to base (208e8c4).
Patch coverage: 75.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4970      +/-   ##
==========================================
+ Coverage   56.93%   56.96%   +0.03%     
==========================================
  Files         292      292              
  Lines       19476    19483       +7     
  Branches     3898     3900       +2     
==========================================
+ Hits        11088    11098      +10     
+ Misses       7451     7450       -1     
+ Partials      937      935       -2     
Impacted Files Coverage Δ
src/deploy/functions/build.ts 56.28% <0.00%> (-0.27%) ⬇️
src/deploy/functions/prepare.ts 30.05% <ø> (ø)
src/emulator/functionsEmulator.ts 6.65% <0.00%> (-0.02%) ⬇️
src/deploy/functions/params.ts 38.20% <92.30%> (+3.08%) ⬆️
src/emulator/auth/state.ts 85.35% <0.00%> (+0.56%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@taeold taeold left a comment

Choose a reason for hiding this comment

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

Super nice. 1 comment.

Comment on lines 337 to 355
defaultParams["DATABASE_URL"] = new ParamValue(config.databaseURL, true, {
string: true,
boolean: false,
number: false,
});
defaultParams["PROJECT_ID"] = new ParamValue(config.projectId, true, {
string: true,
boolean: false,
number: false,
});
defaultParams["GCLOUD_PROJECT"] = new ParamValue(config.projectId, true, {
string: true,
boolean: false,
number: false,
});
defaultParams["STORAGE_BUCKET"] = new ParamValue(config.storageBucket, true, {
string: true,
boolean: false,
number: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure our type for FirebaseConfig is wrong. databaseURL and storageBucket may be empty for a project that didn't initialize neither of these products. Should we instead conditionally setup those parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so, yeah.

Comment on lines 108 to 110
/**
*
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

add documentation or remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

boolean: false,
number: false,
});
}
defaultParams["PROJECT_ID"] = new ParamValue(config.projectId, true, {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit* I wonder if we need PROJECT_ID. We reserve GCLOUD_PROJECT and not PROJECT_ID - what would happen if user had defined PROJECT_ID in the dotenv file 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The user's definition wins. I added a test case to make this clear.

Copy link
Contributor

@colerogers colerogers left a comment

Choose a reason for hiding this comment

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

lgtm

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