feat: Add Cloudflare Environment Variable and Secret support#41
feat: Add Cloudflare Environment Variable and Secret support#41gja merged 3 commits intogja:masterfrom
Conversation
941eda9 to
5fddacf
Compare
5fddacf to
4ed4c73
Compare
gja
left a comment
There was a problem hiding this comment.
This is AWESOME!
Quick favor. Would you also mind updating the deploy scripts so that they happen via wrangler? I’ve had this on my todo for a long time.
Let me know, I’ll merge it in either way.
|
Actually, I think I misunderstood this PR. It looks like you are replicating the wrangler functionality. Ok, that’s interesting. Let me think about this. Do you have any thoughts on doing it this way v/s just including wrangler? This project is older than wrangler, and adding wrangler for config and deploys has been on my task list |
|
Wrangler has no means to change its target API endpoint so I don't think we can use wrangler to deploy. |
…secrets � Conflicts: � README.md � app/__tests__/server_spec.js � package-lock.json � package.json � start.js
|
I should add, I am using the wrangler.toml file to store the environment variables and secrets because Workers users will likely already have this file written. It made more sense to just reuse the file schema rather than come up with our own way of persisting configuration of the server. I was thinking of taking this a step further and moving all server config into the wrangler.toml file rather than having a mix of command line arguments, environment variables, and config file. |
|
Yes, I think that is a good idea. But how would you manage multiple environments? Like a staging and a production setup of the same worker.
…On Sat, Mar 21 2020 at 12:44 AM, Nolan Woods < ***@***.*** > wrote:
I should add, I am using the wrangler.toml file to store the environment
variables and secrets because Workers users will likely already have this
file written. It made more sense to just reuse the file schema rather than
come up with our own way of persisting configuration of the server.
I was thinking of taking this a step further and moving all server config
into the wrangler.toml file rather than having a mix of command line
arguments, environment variables, and config file.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub (
#41 (comment)
) , or unsubscribe (
https://github.com/notifications/unsubscribe-auth/AAAIPOQBHZRTMHPMKQFPNALRIO6ABANCNFSM4LO4YKPA
).
|
|
this commit allows you to specify the target environment on the command line. The wrangler.toml spec already specifies a way of having different environments. |
CloudFlare Environment Variables and Secrets
Support for CloudFlare Environment Variables and Secrets is provided via a wrangler.toml file.
See the wrangler documentation for more information on the file schema.
To load the wrangler.toml, specify it on the command line:
Optionally, the desired environment specified within the wrangler.toml can be loaded:
Secrets are specified under the 'secrets' root key in the document. See the wrangler.toml
for an example of the supported structures.
Two features are provided while loading the wrangler.toml:
A placeholder path is resolved using lodash.get and has the context of the root of the config document.
A placeholder can not refer to a value defined later in the document that also has placeholders.
This allows you to inject complex data into a script by JSON decoding the variable value.
Additionally, any 'kv-namespaces' in the wrangler.toml will be appended to the list of namespaces
provided by KV_NAMESPACES.