Skip to content

Commit 2f169bc

Browse files
committed
allow override of vault file. use cwd to find_dotenv()
1 parent 9a12595 commit 2f169bc

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/dotenv_vault/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
__title__ = "python-dotenv-vault"
88
__description__ = "Syncing your .env to the cloud."
99
__url__ = "https://github.com/dotenv-org/dotenv-vault-python"
10-
__version__ = "0.0.8"
10+
__version__ = "0.0.9"
1111
__author__ = "dotenv"
1212
__author_email__ = "[email protected]"
1313
__license__ = "MIT"

src/dotenv_vault/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def load_dotenv(
2626
if dotenv_vault.dotenv_key:
2727
logger.info('Getting .env from vault.')
2828
vault_stream = dotenv_vault.parsed_vault()
29-
return load_dotenv_file(stream=vault_stream)
29+
# we're going to override the .vault to any existing keys in local
30+
return load_dotenv_file(stream=vault_stream, override=True)
3031
else:
3132
logger.info('Getting .env from local.')
3233
return load_dotenv_file()

src/dotenv_vault/vault.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def parsed_vault(self) -> bytes:
3333
if self.dotenv_key is None: raise DotEnvVaultError("NOT_FOUND_DOTENV_KEY: Cannot find ENV['DOTENV_KEY']")
3434

3535
# .env.vault needs to be present.
36-
env_vault_path = find_dotenv(filename='.env.vault')
36+
env_vault_path = find_dotenv(filename='.env.vault', usecwd=True)
3737
if env_vault_path == '':
3838
raise DotEnvVaultError("ENV_VAULT_NOT_FOUND: .env.vault is not present.")
3939

@@ -56,6 +56,9 @@ def parsed_vault(self) -> bytes:
5656
dotenv = DotEnv(dotenv_path=env_vault_path)
5757
ciphertext = dotenv.dict().get(environment_key)
5858

59+
if not ciphertext:
60+
raise DotEnvVaultError('Environment Key is not found. Run `npx dotenv-vault build`.')
61+
5962
decrypted = self._decrypt(ciphertext=ciphertext, key=key)
6063
return self._to_text_stream(decrypted)
6164

0 commit comments

Comments
 (0)