-
Notifications
You must be signed in to change notification settings - Fork 72
feat: custom delimiters for environment variables #137
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
feat: custom delimiters for environment variables #137
Conversation
@averikitsch looks like I'm failing the lint check, I'll update this PR. I'm also not entirely sure if the regex is the right way to go about this or if there's some simpler way. |
You can run |
@averikitsch I think another way could be to allow users to specify the an alternate delimiter (defaulting to |
@bharathkkb I do like the consistency with gcloud, but that might be over engineering for what most people need. Ignoring commas in quotes seems like an easy solution, but do we anticipate it breaking in any way? Does JSON break this ie KEY="{"key1":"value1","key2":"value2"}"? |
Yes agreed, but with a default to deploy-cloud-functions/src/cloudFunction.ts Lines 166 to 180 in 5b0cfcc
|
- moves envVar parsing function to util - reorganizes unit test cases
c66c212
to
4255373
Compare
@bharathkkb @averikitsch I've refactored this a bit, will try and summarize the changes here
|
@karthikb351 any thoughts on #137 (comment) |
Not sure if this is overkill. The most common issue with requiring a different delimiter is because |
@karthikb351 after some thinking I think we should go with the adding an optional
|
@bharathkkb fair points, especially with edge cases like If you use a custom delimiter, you are going to end up with a similar problem because the delimiter could exist inside the value. You'll have to build some way to allow for escaping the delimiter. This entire pipeline is so complicated, ideally you'd want github actions to support env_vars:
- KEY1=VAL1
- KEY2=VAL2 But GitHub Actions core doesn't support this because they parse every input as a single env var, so they will have a similar issue of having to join the array into a string and split it again. Maybe a completely different approach would be to do something like env_vars: |
KEY1=VAL1
KEY2=VAL2 and then split on newline? This is how GitHub's |
@karthikb351 I am proposing we expose the We can also evaluate switching to |
Makes sense. I'll update the PR. |
@bharathkkb @averikitsch Added the Any other pointers in the meantime? |
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.
Thanks @karthikb351 this is looking good!
sourceDir?: string; | ||
envVars?: string; | ||
envVarsFile?: string; | ||
envVarsDelimiter?: string; |
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.
envVarsDelimiter?: string; | |
envVarsDelimiter:string = ','; |
@karthikb351 gentle ping if you are still planning to wrap this up. |
@bharathkkb yup! Will get around to it this weekend, been a busy few days. |
Adds support for custom delimiters for environment variables.
Currently we are naively just splitting the string on
,
viastr.split(",")
, which also splits commas that might be inside quotes.For example
gets split as
This PR adds the option to set a custom delimiter via the
env_vars_delimiter
key.Added a test cases for a common example of where this would be useful - passing JSON stringified objects as environmental variables.