mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 18:50:21 -07:00
* Fix linode inventory filtering
There was a regression introduced in the addition of caching. The
`_consume_options` method was added and provided the `config_data`
dictionary. This `pop`s every entry, resulting in an empty `config_data`
dict, which was then reused and expected to be populated.
After reviewing, `_consume_data` doesn't need to be called. Also, once
the ``_read_config_data` method has been called, we no longer need the
config_data dict, and can instead use the `get_option` method throughout.
Once those were removed, the filtering function seemed a bit odd, since
we were no longer using the file. I used that opportunity to move the
filter calls into the populate function directly.
* Remove tests that target removed methods
This removes tests that targeted some custom methods on configuration
file handling. These are no longer necessary since they are now handled
by the BaseInventoryPlugin `_read_config_data` method.
* Add changelog entry for linode inventory bugfix
* Revert filters back to their own method
This moves filters back into their own method, but now uses the
get_option calls to pull filter configuration items.
(cherry picked from commit 386bb4bdd5
)
Co-authored-by: steven jacobs <stjacobs@fastmail.fm>
This commit is contained in:
parent
7fb44b0643
commit
4d74aa05a8
3 changed files with 11 additions and 83 deletions
|
@ -48,35 +48,6 @@ def test_missing_access_token_lookup(inventory):
|
|||
assert 'Could not retrieve Linode access token' in error_message
|
||||
|
||||
|
||||
def test_validate_option(inventory):
|
||||
assert ['eu-west'] == inventory._validate_option('regions', list, 'eu-west')
|
||||
assert ['eu-west'] == inventory._validate_option('regions', list, ['eu-west'])
|
||||
assert 'api' == inventory._validate_option('ip_style', str, 'api')
|
||||
|
||||
|
||||
def test_validation_option_bad_option(inventory):
|
||||
with pytest.raises(AnsibleParserError) as error_message:
|
||||
inventory._validate_option('regions', dict, [])
|
||||
assert "The option filters ([]) must be a <class 'dict'>" == error_message
|
||||
|
||||
|
||||
def test_empty_config_query_options(inventory):
|
||||
regions, types, tags = inventory._get_query_options({})
|
||||
assert regions == types == tags == []
|
||||
|
||||
|
||||
def test_config_query_options(inventory):
|
||||
regions, types, tags = inventory._get_query_options({
|
||||
'regions': ['eu-west', 'us-east'],
|
||||
'types': ['g5-standard-2', 'g6-standard-2'],
|
||||
'tags': ['web-server'],
|
||||
})
|
||||
|
||||
assert regions == ['eu-west', 'us-east']
|
||||
assert types == ['g5-standard-2', 'g6-standard-2']
|
||||
assert tags == ['web-server']
|
||||
|
||||
|
||||
def test_verify_file(tmp_path, inventory):
|
||||
file = tmp_path / "foobar.linode.yml"
|
||||
file.touch()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue