]> Frank Brehm's Git Trees - pixelpark/puppet-tools.git/commitdiff
Adding property pdk_version to class ModuleMetadata.
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 9 Feb 2023 16:08:43 +0000 (17:08 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 9 Feb 2023 16:08:43 +0000 (17:08 +0100)
lib/dpx_puppettools/module_metadata.py

index cfa1c0b0ef4cd9b38a5d5ef97f927494b621a506..ba91c2609039a61a59b7d252a809bb3e28378716 100644 (file)
@@ -28,7 +28,7 @@ from .errors import PuppetToolsError
 
 from .xlate import XLATOR
 
-__version__ = '0.6.0'
+__version__ = '0.6.1'
 
 LOG = logging.getLogger(__name__)
 
@@ -204,6 +204,7 @@ class ModuleMetadata(FbBaseObject):
         self._issues_url = None
         self.operatingsystem_support = []
         self.tags = []
+        self._pdk_version = None
 
         super(ModuleMetadata, self).__init__(
             appname=appname, verbose=verbose, version=version,
@@ -236,6 +237,19 @@ class ModuleMetadata(FbBaseObject):
             return
         self._version = to_str(value).strip()
 
+    # -------------------------------------------------------------------------
+    @property
+    def pdk_version(self):
+        """The used PDK version of the module."""
+        return self._pdk_version
+
+    @pdk_version.setter
+    def pdk_version(self, value):
+        if value is None:
+            self._pdk_version = None
+            return
+        self._pdk_version = to_str(value).strip()
+
     # -------------------------------------------------------------------------
     @property
     def author(self):
@@ -331,6 +345,7 @@ class ModuleMetadata(FbBaseObject):
 
         res['name'] = self.name
         res['version'] = self.version
+        res['pdk_version'] = self.pdk_version
         res['author'] = self.author
         res['license'] = self.license
         res['summary'] = self.summary
@@ -465,6 +480,9 @@ class ModuleMetadata(FbBaseObject):
                 if tg:
                     self.tags.append(tg)
 
+        if 'pdk-version' in json_data:
+            self.pdk_version = json_data['pdk-version']
+
         self.initialized = True
         if self.verbose > 3:
             LOG.debug("ModuleMetadata:\n{}".format(pp(self.as_dict())))
@@ -490,6 +508,7 @@ class ModuleMetadata(FbBaseObject):
             new.operatingsystem_support.append(copy.copy(supp))
         for tag in self.tags:
             new.tags.append(tag)
+        new.pdk_version = self.pdk_version
 
         new.initialized = True
 
@@ -524,6 +543,8 @@ class ModuleMetadata(FbBaseObject):
             data['tags'] = []
             for tag in self.tags:
                 data['tags'].append(tag)
+        if self.pdk_version:
+            data['pdk-version'] = self.pdk_version
 
         if self.verbose > 4:
             LOG.debug("ModuleMetadata:\n{}".format(pp(data)))