Skip to content

Commit ad89bb3

Browse files
committed
support custom environments
1 parent 9aea23d commit ad89bb3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/dotenv_vault/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__title__ = "python-dotenv-vault"
22
__description__ = "Decrypt .env.vault file."
33
__url__ = "https://github.com/dotenv-org/python-dotenv-vault"
4-
__version__ = "0.1.1"
4+
__version__ = "0.1.2"
55
__author__ = "dotenv"
66
__author_email__ = "[email protected]"
77
__license__ = "MIT"

src/dotenv_vault/vault.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ def parsed_vault(self) -> bytes:
3838
key = uri.password
3939
# Get environment from query params.
4040
params = dict(parse_qsl(uri.query))
41-
vault_environment = params.get('environment').upper()
41+
vault_environment = params.get('environment')
4242

43-
if vault_environment is None or vault_environment not in ['PRODUCTION', 'DEVELOPMENT', 'CI', 'STAGING']:
44-
raise DotEnvVaultError('Incorrect Vault Environment. It is: {vault_environment}')
43+
if not vault_environment:
44+
raise DotEnvVaultError('INVALID_DOTENV_KEY: Missing environment part')
4545

4646
# Getting ciphertext from correct environment in .env.vault
47-
environment_key = f'DOTENV_VAULT_{vault_environment}'
47+
environment_key = f'DOTENV_VAULT_{vault_environment.upper()}'
4848

4949
# use python-dotenv library class.
5050
dotenv = DotEnv(dotenv_path=env_vault_path)
5151
ciphertext = dotenv.dict().get(environment_key)
5252

5353
if not ciphertext:
54-
raise DotEnvVaultError('Environment Key is not found. Run `npx dotenv-vault build`.')
54+
raise DotEnvVaultError(f"NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment {environment_key} in your .env.vault file. Run 'npx dotenv-vault build' to include it.")
5555

5656
keys.append({
5757
'encrypted_key': key,

0 commit comments

Comments
 (0)