-
Notifications
You must be signed in to change notification settings - Fork 3k
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(ingest): support for env variable in cli #3215
Merged
shirshanka
merged 8 commits into
datahub-project:master
from
aseembansal-gogo:cli_env_var_support
Sep 17, 2021
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dd5489b
feat(ingest): support for env variable in cli
aseembansal-gogo 89488a2
feat(ingest): add error on missing config, add a test
aseembansal-gogo 7851207
feat(ingest): fix docs
aseembansal-gogo cf14f77
feat(ingest): fix docs
aseembansal-gogo fa3e1b9
feat(ingest): fix formatting
aseembansal-gogo 5a53e0d
feat(ingest): extract env var name, add type annotations
aseembansal-gogo cc522da
feat(ingest): consistent names
aseembansal-gogo 12d3707
feat(ingest): code review comments
aseembansal-gogo 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 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
This file contains 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
This file contains 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,11 @@ | ||
from datahub.cli import cli_utils | ||
|
||
|
||
def test_first_non_null(): | ||
assert cli_utils.first_non_null([]) is None | ||
assert cli_utils.first_non_null([None]) is None | ||
assert cli_utils.first_non_null([None, "1"]) == "1" | ||
assert cli_utils.first_non_null([None, "1", "2"]) == "1" | ||
assert cli_utils.first_non_null(["3", "1", "2"]) == "3" | ||
assert cli_utils.first_non_null(["", "1", "2"]) == "1" | ||
assert cli_utils.first_non_null([" ", "1", "2"]) == "1" |
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.
seems like this would be simpler to model as a Dict[str, str] being returned with keys being
GMS_HOST
andGMS_TOKEN
.. then you don't need the first-non-null checks later on.. you can just pick the value of these variables from the Dict directly.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 would still need to use the
Optional[str]
inDict
because it is quite possible one of the variables was set and not the other. We cannot assume user will either provide both of the variables or none. The first non-null check is for that purpose.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'm generally not a fan of using Tuples .. because there is implied order here (first element is host, second element is token) and can lead to bugs later on if someone misunderstands the order ... with a dictionary like "host" -> value, and "token" -> value, it is harder to make those mistakes.
But I see that the rest of the code in this file has similar things. So I'll let this in and we can do a pass over these 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.
Good point on the implied order. Had not considered from that point.