Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nested key plus default bug, fix typo in README.md, bump version #39

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, does the self._get_config_for_key call here not return the default value ever? At least thats what i'm inferring from your additional logic on line 406.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem here is that it returns the default value at the first val, given 'test.foo' and a default, it will never return the value of 'test.foo' always the default.

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
Loading