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

Able to assign host and port for emualtor #35

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

hn12404988
Copy link

Beside setting the host and port. The useEmulator function is still functioning the same.

@CLAassistant
Copy link

CLAassistant commented Jun 7, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ rrousselGit
❌ willie-chang
You have signed the CLA already but the status is still pending? Let us recheck it.

@codekeyz codekeyz self-requested a review June 7, 2024 10:48
@Ehesp
Copy link
Member

Ehesp commented Jun 7, 2024

Hey thanks for this contribution.

The admin SDKs don't set the host/port directly like the client SDKs, instead they read from a environment variable, see https://firebase.google.com/docs/emulator-suite/connect_auth#admin_sdks

We should probably instead parse this value if it exists and pass it through.

@hn12404988
Copy link
Author

Hey, thanks for the doc. I didn't know that because I am using glcoud to start firestore emulatpr which doesn't require the firebase env. I notice you has the "do_not_use_environment" lint rule set. In order to follow this, I just enhanced the [Emulator] class that it can be initiated from envString like this.

final emulator = Emulator.fromEnvString(String.fromEnvironment('FIREBASE_AUTH_EMULATOR_HOST'));

for my gcloud use case, I do this,

final emulator = Emulator('127.0.0.1', 9090);

What do you think about this?

@rrousselGit
Copy link
Collaborator

I notice you has the "do_not_use_environment" lint rule set.

That's not the same "enrivonment". We're talking about using Platform.environment. Using String.fromEnvironment is completely unrelated.

Also, this would need testing :)

Copy link
Collaborator

@rrousselGit rrousselGit left a comment

Choose a reason for hiding this comment

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

Cf above

@hn12404988
Copy link
Author

Hi @rrousselGit , thanks for the feedback.
I tried to fix the point you mentioned and implemented the tests. Let me know if any issue.
Thanks for the review!

return const Emulator._defaultAuth();
} else {
return Emulator.fromEnvString(
Platform.environment['FIREBASE_AUTH_EMULATOR_HOST']!,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you remove this !?

This is possible by doing something like:

final env = Platform.environment['FIREBASE_AUTH_EMULATOR_HOST'];
if (env != null) {...}
else {...}

return const Emulator._defaultFirestore();
} else {
return Emulator.fromEnvString(
Platform.environment['FIRESTORE_EMULATOR_HOST']!,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

Comment on lines +36 to +38
void useAuthEmulator({
Emulator? emulator
}) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't a simpler API be this?

void useAuthEmulator([Uri? uri])

We can then remove that Emulator class.

Emulator? emulator
}) {
_isUsingAuthEmulator = true;
emulator ??= Emulator.auth();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rather have the environment logic directly in here, instead of a constructor inside a separate Emulator class.

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.

5 participants