-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from Start-Out/feature/env-enhancements
FEATURE: Env Enhancements
- Loading branch information
Showing
34 changed files
with
1,534 additions
and
640 deletions.
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,47 @@ | ||
import os | ||
|
||
from typing import Tuple | ||
|
||
from startout.util import is_potentially_sensitive_key_value | ||
|
||
|
||
class EnvironmentVariableManager: | ||
def __init__(self): | ||
self.initial_vars = {k: v for k, v in os.environ.items()} | ||
|
||
self.final_vars = {} | ||
|
||
def capture_final_env(self): | ||
current_vars = {key: value for key, value in os.environ.items()} | ||
new_vars = { | ||
key: value | ||
for key, value in current_vars.items() | ||
if key not in self.initial_vars | ||
} | ||
self.final_vars.update(new_vars) | ||
|
||
return self.final_vars | ||
|
||
def get_captured_vars(self) -> Tuple[dict, dict]: | ||
""" | ||
Returns two dictionaries: one containing the not potentially sensitive variables and their values, and the other | ||
containing the potentially sensitive variables and their values. | ||
**Returns:** | ||
- `not_potentially_sensitive` (dict): A dictionary containing the not potentially sensitive variables and their values. | ||
- `potentially_sensitive` (dict): A dictionary containing the potentially sensitive variables and their values. | ||
""" | ||
|
||
potentially_sensitive = { | ||
key: value | ||
for key, value in self.final_vars.items() | ||
if is_potentially_sensitive_key_value(key, value) | ||
} | ||
not_potentially_sensitive = { | ||
key: value | ||
for key, value in self.final_vars.items() | ||
if not is_potentially_sensitive_key_value(key, value) | ||
} | ||
return not_potentially_sensitive, potentially_sensitive |
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
Oops, something went wrong.