-
Notifications
You must be signed in to change notification settings - Fork 903
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
Add command to export firebase config as environment variables #3690
Conversation
} | ||
|
||
interface ConfigToEnvResult { | ||
success: EnvMap[]; |
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 like that you're using Required
below. You could theoretically also have this be an Omit<EnvMap, 'err'>[]
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.
Love the utility types! Do you think there's a reason to prefer one over the other?
5c72c3d
to
5f235ed
Compare
…ase#3690) To make it easy for users to transition from functions config to environment variables, `functions:config:export` commands steps through the process for reading configuration values stored in Runtime Config API for projects associated with the project directory and exporting them as local .env files in a valid dotenv file format. ``` $ cat .firebaserc { "projects": { "default": "p0, "dev": "p0", "prod": "p1", "local": "p2" }, } $ firebase functions:config:export ⚠ Project alias (local) is reserved for internal use. Saving exported config in .env.p2 instead. i Importing functions configs from projects [p0, p1] ⚠ The following configs keys could not be exported as environment variables: ⚠ p1 (prod): 1foo.a => 1FOO_A (Key 1FOO_A must start with an uppercase ASCII letter or underscore, and then consist of uppercase ASCII letters, digits, and underscores.) x.google.foo.a => X_GOOGLE_FOO_A (Key X_GOOGLE_FOO_A starts with a reserved prefix (X_GOOGLE_ or FIREBASE_)) k.service => K_SERVICE (Key K_SERVICE is reserved for internal use.) ? Enter a PREFIX to rename invalid environment variable keys: CONFIG_ ? /Users/danielylee/google/cf3-env-vars/functions/.env.prod already exists. Overwrite file? Yes ? /Users/danielylee/google/cf3-env-vars/functions/.env.staging already exists. Overwrite file? Yes ? /Users/danielylee/google/cf3-env-vars/functions/.env.dev already exists. Overwrite file? Yes ? /Users/danielylee/google/cf3-env-vars/functions/.env.local already exists. Overwrite file? Yes ? /Users/danielylee/google/cf3-env-vars/functions/.env already exists. Overwrite file? Yes ✔ Wrote files: /Users/danielylee/google/cf3-env-vars/functions/.env.prod /Users/danielylee/google/cf3-env-vars/functions/.env.staging /Users/danielylee/google/cf3-env-vars/functions/.env.local /Users/danielylee/google/cf3-env-vars/functions/.env $ cat functions/.env.prod # Exported firebase functions:config:export command on 8/18/2021 SOMESERVICE_KEY="THE API KEY" # from someservice.key SOMESERVICE_FOO_BAR="car" # from someservice.foo.bar ABC_D="efg" # from abc.d SOME_OTHER_SERVICE_A="hey ohhh" # from some-other-service.a CONFIG_K_SERVICE="hey ohhh" # from k.service SLACK_USER="NewSlackUser\"" # from slack.user FOO_BAR_TEST="12" # from foo.bar.test FOO_BAR_CAR="\"{\"test\":\"12\",\"next\":45}\"" # from foo.bar.car CONFIG_1FOO_A="hey ohhh" # from 1foo.a TEST_VAR="abc" # from test.var A_B="hello\nworld" # from a.b APP_NAME="foobar" # from app.name CONFIG_X_GOOGLE_FOO_A="hey ohhh" # from x.google.foo.a NEW_LINE="hello\nworld" # from new.line ```
To make it easy for users to transition from functions config to environment variables,
functions:config:export
commands steps through the process for reading configuration values stored in Runtime Config API for projects associated with the project directory and exporting them as local .env files in a valid dotenv file format.