I think we should either store of the output of self.config.get(template) (which is dict) and later get values from that later (fast solution), or we could create dataclasses that represent each section of config (+root) and populate them using this dictionary. The second, bit more complex, solution would provide more unified interface to the config along with type hinting.
Currently we are using
Confuse
config library but I think we are doing it bit wrong. We parse config using template here https://github.com/canonical/prometheus-juju-exporter/blob/5b6ec18f807b02830eff55994b7d3324681d248a/prometheus_juju_exporter/config.py#L66-L69But we don't use store the result. Essentially we are just validating that config matches the template. This forces use to reuse
Confuse
functions again when we want to get the value https://github.com/canonical/prometheus-juju-exporter/blob/5b6ec18f807b02830eff55994b7d3324681d248a/prometheus_juju_exporter/collector.py#L29I think we should either store of the output of
self.config.get(template)
(which is dict) and later get values from that later (fast solution), or we could createdataclasses
that represent each section of config (+root) and populate them using this dictionary. The second, bit more complex, solution would provide more unified interface to the config along with type hinting.