-
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.
organize code, add default get_secret func
- Loading branch information
1 parent
a9c72e4
commit 7de8f0f
Showing
7 changed files
with
38 additions
and
9 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
Empty file.
File renamed without changes.
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,25 @@ | ||
from prefeitura_rio.pipelines_utils.infisical import get_infisical_client | ||
from pipelines.utils.utils import normalize_keys | ||
|
||
|
||
def get_secret(secret_path:str='/', secret_name:str=None, environment:str='dev'): | ||
""" | ||
Fetches secrets from Infisical. If passing only `secret_path` and | ||
no `secret_name`, returns all secrets inside a folder. | ||
Args: | ||
secret_name (str, optional): _description_. Defaults to None. | ||
secret_path (str, optional): _description_. Defaults to '/'. | ||
environment (str, optional): _description_. Defaults to 'dev'. | ||
Returns: | ||
_type_: _description_ | ||
""" | ||
client = get_infisical_client() | ||
if not secret_path.startswith('/'): | ||
secret_path = f"/{secret_path}" | ||
if secret_path and not secret_name: | ||
secrets = client.get_all_secrets(path=secret_path) | ||
return normalize_keys({s.secret_name:s.secret_value for s in secrets}) | ||
secret = client.get_secret(secret_name=secret_name, path=secret_path, environment=environment) | ||
return {secret_name:secret.secret_value} |
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