mirror of
https://github.com/ansible/ansible.git
synced 2026-08-03 08:03:05 +02:00
Remove deprecated vars keyword syntax as a list of dictionaries, it is now required to be a single dictionary (#82980)
Update unit test
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
removed_features:
|
||||
- Removed support for setting the ``vars`` keyword to lists of dictionaries. It is now required to be a single dictionary.
|
||||
@@ -574,9 +574,7 @@ class FieldAttributeBase:
|
||||
|
||||
def _load_vars(self, attr, ds):
|
||||
'''
|
||||
Vars in a play can be specified either as a dictionary directly, or
|
||||
as a list of dictionaries. If the later, this method will turn the
|
||||
list into a single dictionary.
|
||||
Vars in a play must be specified as a dictionary.
|
||||
'''
|
||||
|
||||
def _validate_variable_keys(ds):
|
||||
@@ -588,21 +586,6 @@ class FieldAttributeBase:
|
||||
if isinstance(ds, dict):
|
||||
_validate_variable_keys(ds)
|
||||
return combine_vars(self.vars, ds)
|
||||
elif isinstance(ds, list):
|
||||
display.deprecated(
|
||||
(
|
||||
'Specifying a list of dictionaries for vars is deprecated in favor of '
|
||||
'specifying a dictionary.'
|
||||
),
|
||||
version='2.18'
|
||||
)
|
||||
all_vars = self.vars
|
||||
for item in ds:
|
||||
if not isinstance(item, dict):
|
||||
raise ValueError
|
||||
_validate_variable_keys(item)
|
||||
all_vars = combine_vars(all_vars, item)
|
||||
return all_vars
|
||||
elif ds is None:
|
||||
return {}
|
||||
else:
|
||||
|
||||
@@ -196,7 +196,6 @@ test/units/cli/test_data/role_skeleton/README.md pymarkdown:line-length
|
||||
test/integration/targets/find/files/hello_world.gbk no-smart-quotes
|
||||
test/integration/targets/find/files/hello_world.gbk no-unwanted-characters
|
||||
lib/ansible/galaxy/collection/__init__.py pylint:ansible-deprecated-version-comment # 2.18 deprecation
|
||||
lib/ansible/playbook/base.py pylint:ansible-deprecated-version # 2.18 deprecation
|
||||
lib/ansible/playbook/play.py pylint:ansible-deprecated-version # 2.18 deprecation
|
||||
lib/ansible/playbook/play_context.py pylint:ansible-deprecated-version # 2.18 deprecation
|
||||
lib/ansible/plugins/action/__init__.py pylint:ansible-deprecated-version # 2.18 deprecation
|
||||
|
||||
@@ -198,8 +198,7 @@ class TestBase(unittest.TestCase):
|
||||
'vars': [{'var_2_key': 'var_2_value'},
|
||||
{'var_1_key': 'var_1_value'}]
|
||||
}
|
||||
b = self._base_validate(ds)
|
||||
self.assertEqual(b.vars['var_1_key'], 'var_1_value')
|
||||
self.assertRaises(AnsibleParserError, self.b.load_data, ds)
|
||||
|
||||
def test_vars_not_dict_or_list(self):
|
||||
ds = {'environment': [],
|
||||
|
||||
Reference in New Issue
Block a user