Skip to content
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

Allow empty lines in env keys. #59

Merged
merged 2 commits into from
Feb 18, 2024
Merged

Allow empty lines in env keys. #59

merged 2 commits into from
Feb 18, 2024

Conversation

gbradley
Copy link

In a large application its visually useful to separate env variables into sections with empty lines e.g.

SERVICE_FOO_CLIENT_ID=123
SERVICE_FOO_SECRET_KEY=xy

SERVICE_BAR_ETC_ETC=987

but currently veyoze requires every line in the env file to contain a valid key/pair. Otherwise, no env keys are merged in at all (due to a return statement inside the parsing loop).

Becasue of this, it took me a while to figure out why my provisioned site contained no env keys.

This PR keeps existing behaviour of returning no env keys when an invalid key/pair is found, but allows & ignores empty lines.

Graham Bradley and others added 2 commits February 15, 2024 15:59
- This commit modifies the TextToArray action to ensure that it returns valid key/value pairs even when there are invalid keys present in the array. The action now processes the array robustly, filtering out invalid keys and returning only the valid pairs. This improvement enhances the overall reliability of the TextToArray functionality.
@mehrancodes
Copy link
Owner

Hi Graham.

I've built upon your awesome work and added a new test, and made a tweak to the TextToArray action. Now, even if there are invalid keys hanging around in the FORGE_ENV_KEYS, it returns only valid keys instead of returning an empty array

@mehrancodes
Copy link
Owner

While testing the new changes, I found out the new lines were still being removed from the projects' '.env' by Veyoze, so I found another way to merge variables from FORGE_ENV_VARIABLE into the source environment, making sure the structure stays the same, and the new variables get added to the end. I would provide the new on a new PR soon.

FYI Here is what currently .env looks like after provision:

Before Provision:

APP_NAME=Laravel
APP_DEBUG=false
APP_KEY=
APP_URL="http://pr-7.veyoze.veyoze.com"

LOG_CHANNEL=stack

GOOGLE_API=MY_API_KEY

After provision:

APP_NAME=Laravel
APP_DEBUG=false
APP_URL="http://pr-7.veyoze.veyoze.com"
LOG_CHANNEL=stack
GOOGLE_API=MY_API_KEY
APP_KEY=base64:Y9jKvZ4wgb2YJuRG0ZdL1psYUiUHUTds+8TLxgsUqAw=

@mehrancodes mehrancodes merged commit f8ca17c into mehrancodes:main Feb 18, 2024
@mehrancodes
Copy link
Owner

new PR here to address this issue: #60

I have tested it out with a Forge server, but trying to add more test assertions to make sure it covers all possible cases :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants