Debian Codegraph @

ansible_collections/community/dns/plugins/plugin_utils/_templated_options.py

raw
1 # Copyright (c) 2022 Felix Fontein
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4
5 # Note that this plugin util is **PRIVATE** to the collection. It can have breaking changes at any time.
6 # Do not use this from other collections or standalone plugins/modules!
7
8 from __future__ import annotations
9
10 import typing as t
11
12 from ansible.template import Templar
13
14
15 class TemplatedOptionProvider:
16 def __init__(self, plugin: t.Any, templar: Templar) -> None:
17 self.plugin = plugin
18 self.templar = templar
19
20 def get_option(self, option: str) -> t.Any:
21 value = self.plugin.get_option(option)
22 if self.templar.is_template(value):
23 value = self.templar.template(variable=value)
24 return value