-
Notifications
You must be signed in to change notification settings - Fork 9
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 to find .env.vault #13
Conversation
1e5781c
to
43ed0d1
Compare
src/dotenv_vault/main.py
Outdated
@@ -11,6 +11,9 @@ | |||
import dotenv.main as dotenv | |||
|
|||
|
|||
DOTENV_VAULT_PATH = dotenv.find_dotenv(".env.vault") |
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.
change this to instead find the .env
file and then find the .env.vault
file right next to it.
That would then match user's expected behavior more closely. This is what the node lib does.
https://github.com/motdotla/dotenv/blob/master/lib/main.js#L152
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.
@motdotla , made a new change. It should look for .env first, and expect .env.vault to be in same directory. Else, it will scream at you
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.
5e2af23
to
1a0ce86
Compare
src/dotenv_vault/main.py
Outdated
return path | ||
path = os.path.dirname(path) | ||
if '.env.vault' not in os.listdir(path): | ||
raise FileNotFoundError('.env.vault is not in same directory as .env') |
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.
it shouldn't stacktrace fail.
on local development someone might be using this library and not have a .env.vault file. that's ok. it should fallback to dotenv.
this should have messaging like the dotenv lib:
https://github.com/motdotla/dotenv/blob/master/lib/main.js#L228
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.
@motdotla , okay it should default to .env
1a0ce86
to
35f3545
Compare
src/dotenv_vault/main.py
Outdated
path = os.path.dirname(path) | ||
if '.env.vault' not in os.listdir(path): | ||
# we fall back to .env | ||
logger.warning("No .env.vault file found. Falling back to .env") |
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.
Messaging should match the dotenv messaging.
https://github.com/motdotla/dotenv/blob/master/lib/main.js#L228C113-L228C113
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
48bb438
to
508d7e5
Compare
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.
one last change!
CHANGELOG.md
Outdated
|
||
### Changed | ||
|
||
- Allow to place .env.vault file anywhere in app [#13](https://github.com/dotenv-org/python-dotenv-vault/pull/13) |
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.
Update message to:
Look for .env.vault
file at same location as .env
file. Finds .env
file anywhere in app (just like original python lib)
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.
changed!
508d7e5
to
22c19c5
Compare
CHANGELOG.md
Outdated
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. See [standa | |||
|
|||
## [Unreleased](https://github.com/dotenv-org/python-dotenv-vault/compare/v0.5.1...master) | |||
|
|||
## 0.7.0 |
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.
This should be a 0.6.1
patch rather than a minor upgrade.
src/dotenv_vault/__init__.py
Outdated
@@ -1 +1 @@ | |||
from .main import load_dotenv | |||
from .main import load_dotenv, load_dotenv_vault |
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.
This shouldn't be exposed to the developer as a public method.
https://github.com/motdotla/dotenv/blob/master/lib/main.js#L167
usage for developer should not ever change. just load_dotenv
and it is smart enough to determine to load .env.vault or .env depending if DOTENV_KEY is set or not.
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 removed load_dotenvv_ault
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.
looks like it is still there?? in __int__.py
?
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.
Oops! Forgot to push 😎
4944f86
to
5d15763
Compare
5d15763
to
80361df
Compare
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.
just the change in __init__.py
and then this is ready to go
# we fall back to .env | ||
logger.warning(f"You set DOTENV_KEY but you are missing a .env.vault file at {path}. Did you forget to build it?") | ||
return f"{path}/.env" | ||
return f"{path}/.env.vault" |
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.
looks good here 👍
CHANGELOG.md
Outdated
|
||
### Changed | ||
|
||
- Look for .env.vault file at same location as .env file. Finds .env file anywhere in app (just like original python lib) [#13](https://github.com/dotenv-org/python-dotenv-vault/pull/13) |
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.
One more nitpick. This comment should be under 0.6.1
and the one above should be under 0.6.2
. Then this PR should be ready to go.
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.
okay, i switched this around @motdotla . It should be in correct place now
this allows to search for
.env.vault
anywhere in the app.