Change option_defaults to being a plain dict rather than a method.
authorCarl Hetherington <cth@carlh.net>
Thu, 2 Apr 2020 13:25:35 +0000 (15:25 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 2 Apr 2020 13:25:35 +0000 (15:25 +0200)
cdist

diff --git a/cdist b/cdist
index 39568d64f154ce068aa73afa5949cd551e8d447b..9ce04b4ce260a1d76cea035cb5cc21fd2e64f3d9 100755 (executable)
--- a/cdist
+++ b/cdist
@@ -934,7 +934,13 @@ class Tree(object):
     def add_defaults(self, options):
         """Add the defaults from this into a dict options"""
         if 'option_defaults' in self.cscript:
-            for k, v in self.cscript['option_defaults']().items():
+            from_cscript = self.cscript['option_defaults']
+            if isinstance(from_cscript, dict):
+                defaults_dict = from_cscript
+            else:
+                log("Deprecated cscript option_defaults method; replace with a dict")
+                defaults_dict = from_cscript()
+            for k, v in default_dict.items():
                 if not k in options:
                     options[k] = v