mirror of https://github.com/ansible/ansible.git
Yolo (#77554)
* Revert "Revert "Config, ensure templating happens at functions (#77483)""
This reverts commit 94c9106153
.
* removed update configdata, which is unused
* removed test for action we don't perform anymore
* removed unused configdata
pull/76639/head^2
parent
191d9a771a
commit
abdd237de7
@ -0,0 +1,3 @@
|
||||
minor_changes:
|
||||
- config manager, move templating into main query function in config instead of constants
|
||||
- config manager, remove updates to configdata as it is mostly unused
|
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- config, ensure that pulling values from configmanager are templated if possible.
|
@ -1,43 +0,0 @@
|
||||
# Copyright: (c) 2017, Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
class ConfigData(object):
|
||||
|
||||
def __init__(self):
|
||||
self._global_settings = {}
|
||||
self._plugins = {}
|
||||
|
||||
def get_setting(self, name, plugin=None):
|
||||
|
||||
setting = None
|
||||
if plugin is None:
|
||||
setting = self._global_settings.get(name)
|
||||
elif plugin.type in self._plugins and plugin.name in self._plugins[plugin.type]:
|
||||
setting = self._plugins[plugin.type][plugin.name].get(name)
|
||||
|
||||
return setting
|
||||
|
||||
def get_settings(self, plugin=None):
|
||||
|
||||
settings = []
|
||||
if plugin is None:
|
||||
settings = [self._global_settings[k] for k in self._global_settings]
|
||||
elif plugin.type in self._plugins and plugin.name in self._plugins[plugin.type]:
|
||||
settings = [self._plugins[plugin.type][plugin.name][k] for k in self._plugins[plugin.type][plugin.name]]
|
||||
|
||||
return settings
|
||||
|
||||
def update_setting(self, setting, plugin=None):
|
||||
|
||||
if plugin is None:
|
||||
self._global_settings[setting.name] = setting
|
||||
else:
|
||||
if plugin.type not in self._plugins:
|
||||
self._plugins[plugin.type] = {}
|
||||
if plugin.name not in self._plugins[plugin.type]:
|
||||
self._plugins[plugin.type][plugin.name] = {}
|
||||
self._plugins[plugin.type][plugin.name][setting.name] = setting
|
@ -1,41 +0,0 @@
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from units.compat import unittest
|
||||
|
||||
from ansible.config.data import ConfigData
|
||||
from ansible.config.manager import Setting
|
||||
|
||||
|
||||
mykey = Setting('mykey', 'myvalue', 'test', 'string')
|
||||
mykey2 = Setting('mykey2', 'myvalue2', ['test', 'test2'], 'list')
|
||||
mykey3 = Setting('mykey3', 'myvalue3', 11111111111, 'integer')
|
||||
|
||||
|
||||
class TestConfigData(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.cdata = ConfigData()
|
||||
|
||||
def tearDown(self):
|
||||
self.cdata = None
|
||||
|
||||
def test_update_setting(self):
|
||||
for setting in [mykey, mykey2, mykey3]:
|
||||
self.cdata.update_setting(setting)
|
||||
self.assertEqual(setting, self.cdata._global_settings.get(setting.name))
|
||||
|
||||
def test_update_setting_with_plugin(self):
|
||||
pass
|
||||
|
||||
def test_get_setting(self):
|
||||
self.cdata._global_settings = {'mykey': mykey}
|
||||
self.assertEqual(mykey, self.cdata.get_setting('mykey'))
|
||||
|
||||
def test_get_settings(self):
|
||||
all_settings = {'mykey': mykey, 'mykey2': mykey2}
|
||||
self.cdata._global_settings = all_settings
|
||||
|
||||
for setting in self.cdata.get_settings():
|
||||
self.assertEqual(all_settings[setting.name], setting)
|
Loading…
Reference in New Issue