-
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 #15 from fictivekin/dynaconf-loader-identifier-cha…
…nges Handle loader identifier changes between Dynaconf 3.1->3.2
- Loading branch information
Showing
3 changed files
with
33 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,33 @@ | ||
""" | ||
Dynaconf Loader for AWS Secrets Manager | ||
""" | ||
import typing as t | ||
|
||
from importlib.metadata import version | ||
|
||
# Pull version from the package data; canonical source is pyproject.toml | ||
__version__ = version(__package__) | ||
|
||
# The loader identifier, which is used to identify the provenance of compiled | ||
# configuration key/value pairs in the resulting ``Settings`` object. | ||
IDENTIFIER = "aws-ssm" | ||
|
||
def generate_loader_identifier(path: str, env: str): | ||
""" | ||
The loader identifier, which is used to identify the provenance of compiled | ||
configuration key/value pairs in the resulting ``Settings`` object. | ||
:param path: String-based path to identify where the value has been sourced from | ||
:param env: String-based env name | ||
""" | ||
|
||
# Dynamic import here, due to the changes between Dynaconf 3.1 and 3.2 with | ||
# respect to loader identifiers. | ||
try: | ||
# Use the new-style source metadata loading for better introspection | ||
# of where values are sourced from. | ||
from dynaconf.loaders.base import SourceMetadata | ||
|
||
loader_identifier = SourceMetadata(loader="aws-ssm", identifier=path, env=env) | ||
except ImportError: # Dynaconf<=3.1, simply return a string. | ||
# Use the old-style string identifiers. | ||
loader_identifier = "aws-ssm" | ||
|
||
return loader_identifier |
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