Skip to content

Commit

Permalink
Merge pull request #39 from SparkeyG/sparkeyg/issue-38/nested-key-def…
Browse files Browse the repository at this point in the history
…ault-fix

Fix nested key plus default bug, fix typo in README.md, bump version
  • Loading branch information
adisunw authored Oct 19, 2023
2 parents aa728e4 + fb2f0b9 commit db16f6f
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 138 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Note that all of these functions, in addition from being type hinted, also stron
To set a default configuration value programmatically:

```python
g.set_defualt_string('some.default.k', 'default value')
g.set_default_string('some.default.k', 'default value')
```

Defined by the function signature
Expand Down Expand Up @@ -352,4 +352,4 @@ Currently only dynamic secret support is generation of credentials for database.
to maintain ease of library.

To get a dynamic secret from the database, use the function `generate_database_dynamic_secret` which will raise Runtime exceptions if the proper setup is not done
otherwise update gestalt config map with the username and password
otherwise update gestalt config map with the username and password
5 changes: 4 additions & 1 deletion gestalt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,18 @@ def __get(
)
split_keys = key.split(self.__delim_char)
consider_keys = list()
config_val = None
for split_key in split_keys:
consider_keys.append(split_key)
joined_key = self.__delim_char.join(consider_keys)
config_val = self._get_config_for_key(key=key,
key_to_search=joined_key,
default=default,
object_type=t)
if config_val is not None:
if config_val is not None and config_val != default:
return config_val
if default is not None:
return default

raise ValueError(
f'Given key {key} is not in any configuration and no default is provided'
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def readme():
reqs_list = list(map(lambda x: x.rstrip(), reqs))

setup(name='gestalt-cfg',
version='3.3.3',
version='3.3.4',
description='A sensible configuration library for Python',
long_description=readme(),
long_description_content_type="text/markdown",
Expand Down
Loading

0 comments on commit db16f6f

Please sign in to comment.