Skip to content

Lookup environment variables instead of checking if the value is empty#440

Merged
bep merged 3 commits intospf13:masterfrom
sagikazarmark:lookup_env
Nov 6, 2018
Merged

Lookup environment variables instead of checking if the value is empty#440
bep merged 3 commits intospf13:masterfrom
sagikazarmark:lookup_env

Conversation

@sagikazarmark
Copy link
Copy Markdown
Collaborator

Empty environment variables are perfectly valid values.
Fortunately Go provides a way to check whether an env var
is empty or not set.

Fixes #317

Resubmitted #429

Empty environment variables are perfectly valid values.
Fortunately Go provides a way to check whether an env var
is empty or not set.

Fixes #317
@sagikazarmark
Copy link
Copy Markdown
Collaborator Author

@tsl0922 test cases provided in this PR

@dcormier
Copy link
Copy Markdown

Sure would be nice to see this working. I'd like to be able to use empty environment variables.

@sagikazarmark
Copy link
Copy Markdown
Collaborator Author

Can someone restart the build please? Tests passed for me locally.

@tsl0922
Copy link
Copy Markdown

tsl0922 commented Feb 5, 2018

@sagikazarmark you can do a force push to trigger it.

@sagikazarmark
Copy link
Copy Markdown
Collaborator Author

Ping

@b1v1r
Copy link
Copy Markdown

b1v1r commented Oct 17, 2018

Any ETA on this being merged (or rejected)? Looks like @tsl0922 reviewed this as #429, but then it stalled when it was resubmitted.

@sagikazarmark
Copy link
Copy Markdown
Collaborator Author

@bep @andrewstuart can you help us out here?

@andrewstuart
Copy link
Copy Markdown
Collaborator

So my main concern here is that this has the potential to be considered a breaking change if are using empty environment variables in place of unsetting.

I'd be a lot more comfortable merging this if it was behind a default-off option.

@bep
Copy link
Copy Markdown
Collaborator

bep commented Nov 6, 2018

So my main concern here is that this has the potential to be considered a breaking change if are using empty environment variables in place of unsetting.

On one side, I think the map lookups follow the v, ok := pattern, which would be similar, but I agree -- we cannot change this as the default behavior. That this is OS env vars, something "invisible", will create some very subtle bugs around. But an option (default off) would be good.

@sagikazarmark
Copy link
Copy Markdown
Collaborator Author

@andrewstuart @bep Thanks for your comments.

I added an AllowEmptyEnv method with tests and some documentation in the readme. By default this feature is turned off.

@sagikazarmark
Copy link
Copy Markdown
Collaborator Author

Breaking tests seem to be unrelated

@bep bep merged commit b7a3b95 into spf13:master Nov 6, 2018
@sagikazarmark sagikazarmark deleted the lookup_env branch November 6, 2018 21:58
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.

6 participants