-
Notifications
You must be signed in to change notification settings - Fork 73
fix deploy
and upload
commands not taking into account environment variables
#818
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
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,5 @@ | ||
--- | ||
"@opennextjs/cloudflare": patch | ||
--- | ||
|
||
fix `deploy` command not taking into account environment variables |
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.
upload.ts
should be updated as well.May be we could add a
includeProcessEnv: Boolean
togetEnvFromPlatformProxy
so that we could document the purpose on the JSDoc of that functon.I'm wondering if it should
{ ...platformProxyEnvVars, ...process.env }
or{ ...process.env, ...platformProxyEnvVars}
- I would tend to prefer the latest as proxy vars are more specific as they could change with the environment but I don't have a very strong opinion on that. What do you think?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.
Actually I'm wondering if we should rather update
opennextjs-cloudflare/packages/cloudflare/src/cli/commands/skew-protection.ts
Lines 68 to 86 in c46eeee
to read from either
process.env
ofenvVars
.That would be a more targeted change.
What are your thoughts?
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.
Updated 👍
What about renaming the function
getEnvironmentVariables
and have it always include values from bothplatformProxy
andprocess.env
? would there be an issue with that?I purposely put
...process.env
as last since I think system environment variables should have precedence over those in the config files, for example if I run something line:$ CF_ACCOUNT_ID="123" npm run deploy
I would personally expect that "123" would override a potential
CF_ACCOUNT_ID
value present in the config file.I do think that this is the common behavior for this sort of things. Having the system environment variables also adds more flexibility to users, that could for example very easily deploy their worker onto different accounts (silly example):
What would the benefits in having the
platformProxy
have precedence overprocess.env
be?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 think that generally it would make more sense to get the environment variables from both
getPlatformProxy
andprocess.env
, actually generallyprocess.env
makes more sense to me if we're talking about build time variables, since the variables ingetPlatformProxy
are, in my opinion, runtime variables.But if you prefer I'll update the code to limit the change to the skew protection logic.
Uh oh!
There was an error while loading. Please reload this page.
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.
From the discussion, I think
getEnvFromPlatformProxy
and have it returns only the the env. This is the original use case and what we usually want - i.e. when we access the cache at build time, we want to use the config that will be used at runtime.So I think what we want is to pass the
getEnvFromPlatformProxy()
andgetDeployementMapping()
(i.e. no change from what we do today).Inside this function you could add
env = {...envVars, ...process.env};
with a comment that process.env has priority for those variables (agreed thatprocess.env
should have priority)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.
done, hopefully this is what you had in mind: 945f849