-
Notifications
You must be signed in to change notification settings - Fork 28
Extension to migrate data from functions.config() to params #67
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
Draft
inlined
wants to merge
1
commit into
functions-migrations
Choose a base branch
from
inlined.params-data-migration
base: functions-migrations
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+63
−1
Draft
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| --- | ||
| name: firebase-functions-params-data-migration | ||
| description: Migrate data from functions.config() to Firebase Functions Params (.env files and Cloud Secret Manager) | ||
| version: 0.0.1 | ||
| --- | ||
|
|
||
| # Firebase Functions Params Data Migration | ||
|
|
||
| ## Context | ||
| The user wants to move their configuration data from the deprecated `functions.config()` (Runtime Config) to the modern `firebase-functions/params` storage mechanisms (e.g., `.env` files, Cloud Secret Manager). | ||
| This skill should be run after `firebase-functions-params-refactor` or whenever someone says they want to move their data from `functions.config()` to params. | ||
|
|
||
| ## Triggers | ||
| Activate this skill when: | ||
| 1. The user asks to "move data from config", "migrate functions config values", or "setup .env files for params". | ||
| 2. Offered as a completion step to `firebase-functions-params-refactor`. | ||
|
|
||
| ## Prerequisites | ||
| - All `functions.config()` calls must be removed from the codebase. | ||
| - If this is not done, suggest running `firebase-functions-params-refactor` first to rewrite their code to use params. | ||
|
|
||
| ## Steps | ||
|
|
||
| ### 1. Extract Existing Configuration | ||
| Print out all of the current `functions.config()` storage with: | ||
| ```bash | ||
| firebase functions:config:get --project [projectId] | ||
| ``` | ||
|
|
||
| Review the JSON output and map the keys to the new functions params defined in the codebase. | ||
|
|
||
| ### 2. Secret Mapping | ||
| For any config value that maps to a `defineSecret()` param: | ||
|
|
||
| 1. Check to see whether the secret exists with the same value by accessing it: | ||
| ```bash | ||
| firebase functions:secrets:access [SECRET_NAME] | ||
| ``` | ||
| 2. If the secret does not exist, set the secret environment variable: | ||
| ```bash | ||
| firebase functions:secrets:set [SECRET_NAME] | ||
| ``` | ||
| 3. If it exists with the same value, continue. | ||
| 4. If it exists with a different value, prompt the user how to continue. | ||
|
|
||
| ### 3. Determine Config Scope | ||
| Figure out whether the customer wants project-specific or global configs. | ||
| Customers can specify that some config is global and some is project-specific. | ||
|
|
||
| ### 4. Populate Environment Files | ||
| Based on the scope determined in Step 3: | ||
|
|
||
| - For any **global** config, put the value in a `.env` file. | ||
| - For any **project-specific** config, put it in `.env.[projectId]`. | ||
|
|
||
| ### 5. Emulator Support (Local Config) | ||
| If the Firebase Emulator Suite is installed, help the user set up local configuration. | ||
|
|
||
| 1. Ask the user what values they want for either secrets or project-specific config in the local environment. | ||
| 2. **Non-secret values** should be placed in `.env.local`. These can be checked into source control. | ||
| 3. Any **sensitive/secret values** should be placed in `.secrets.local`. | ||
| 4. **IMPORTANT**: Ensure that `.secrets.local` is added to `.gitignore`. | ||
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
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.
The
.env.localfile is intended for local environment overrides and should not be committed to version control. Additionally, Firebase does not natively recognize a.secrets.localfile; local secrets for the emulator should also be placed in.env.local, which must be ignored via.gitignore.