-
Notifications
You must be signed in to change notification settings - Fork 67
refactor: use environment variables to communicate gcs.Storage config
#186
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
demolaf
merged 12 commits into
invertase:next
from
brianquinlan:next_google_cloud_storage
Mar 16, 2026
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
73510c6
Make server work with google_cloud_storage
brianquinlan fb66998
Use pub version
brianquinlan a4bb424
Update storage.dart
brianquinlan 5390e35
Env var
brianquinlan 279d5cb
Reverts
brianquinlan f666755
Update storage.dart
brianquinlan b47370d
Merge branch 'next' into next_google_cloud_storage
brianquinlan 1e300d2
Update storage.dart
brianquinlan 168b235
Fix diff a bit
brianquinlan 7051748
Update pubspec.yaml
brianquinlan 3622cda
Merge branch 'next' into next_google_cloud_storage
demolaf e2501e6
Merge branch 'next' into next_google_cloud_storage
demolaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/dart_firebase_admin/lib/src/utils/native_environment.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import 'dart:ffi'; | ||
| import 'dart:io'; | ||
|
|
||
| import 'package:ffi/ffi.dart'; | ||
| import 'package:meta/meta.dart'; | ||
|
|
||
| import '../../dart_firebase_admin.dart'; | ||
|
|
||
| final int Function(Pointer<Utf8>, Pointer<Utf8>, int) _setenv = | ||
| DynamicLibrary.process().lookupFunction< | ||
| Int32 Function(Pointer<Utf8>, Pointer<Utf8>, Int32), | ||
| int Function(Pointer<Utf8>, Pointer<Utf8>, int) | ||
| >('setenv'); | ||
|
|
||
| final int Function(Pointer<Utf16>, Pointer<Utf16>) _setEnvironmentVariableW = | ||
| DynamicLibrary.open('kernel32.dll').lookupFunction< | ||
| Int32 Function(Pointer<Utf16>, Pointer<Utf16>), | ||
| int Function(Pointer<Utf16>, Pointer<Utf16>) | ||
| >('SetEnvironmentVariableW'); | ||
|
|
||
| @internal | ||
| void setNativeEnvironmentVariable(String name, String value) { | ||
| if (Platform.isWindows) { | ||
| using((arena) { | ||
| final namePtr = name.toNativeUtf16(allocator: arena); | ||
| final valuePtr = value.toNativeUtf16(allocator: arena); | ||
| if (_setEnvironmentVariableW(namePtr, valuePtr) == 0) { | ||
| throw FirebaseAppException( | ||
| AppErrorCode.internalError, | ||
| 'Failed to set native environment variable: $name', | ||
| ); | ||
| } | ||
| }); | ||
| } else { | ||
| using((arena) { | ||
| final namePtr = name.toNativeUtf8(allocator: arena); | ||
| final valuePtr = value.toNativeUtf8(allocator: arena); | ||
| if (_setenv(namePtr, valuePtr, 1) == -1) { | ||
| throw FirebaseAppException( | ||
| AppErrorCode.internalError, | ||
| 'Failed to set native environment variable: $name', | ||
| ); | ||
| } | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the version constraint here with the idea that there are only three things that
package:google_cloud_storagehas to keep stable:Storageconstructor that call be called without argumentsStorageinferring the emulator settings from environment variablesStorage.bucketcreating aBucketwhen called with a single argumentIf we use more of the API surface than that, then maybe we need to pin the major version.