From c5e57c0aefe71030a31234bf6e5b15aacb2ee3e8 Mon Sep 17 00:00:00 2001 From: Samuel Pilla Date: Fri, 6 Apr 2018 12:49:52 -0500 Subject: [PATCH] ConfigurationSource base class Creates and abstract base class for configuration sources to be implemented off of. Change-Id: I238930df61749a77b0a0aa4f033375972a159931 Blueprint: oslo-config-drivers --- oslo_config/sources/__init__.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/oslo_config/sources/__init__.py b/oslo_config/sources/__init__.py index 0fe4454e..fb30a35a 100644 --- a/oslo_config/sources/__init__.py +++ b/oslo_config/sources/__init__.py @@ -40,3 +40,29 @@ class ConfigurationSourceDriver(object): :type group_name: str :returns: an instance of a subclass of ConfigurationSource """ + + +@six.add_metaclass(abc.ABCMeta) +class ConfigurationSource(object): + """A configuration source option for oslo.config. + + A configuration source is able to fetch configuration values based on + a (group, option) key from an external source that supports key-value + mapping such as INI files, key-value stores, secret stores, and so on. + + """ + + @abc.abstractmethod + def get(self, group_name, option_name, opt): + """Return the value of the option from the group. + + :param group_name: Name of the group. + :type group_name: str + :param option_name: Name of the option. + :type option_name: str + :param opt: The option definition. + :type opt: Opt + :returns: A tuple (value, location) where value is the option value + or oslo_config.sources._NoValue if the (group, option) is + not present in the source, and location is a LocationInfo. + """