juergbi commented on code in PR #2098:
URL: https://github.com/apache/buildstream/pull/2098#discussion_r2614168559


##########
src/buildstream/types.py:
##########
@@ -164,6 +164,65 @@ class OverlapAction(FastEnum):
     """
 
 
+# SourceProvenance()
+#
+# A simple object describing user provided source provenance information
+#
+# Args:
+#    homepage: The source's homepage URL
+#    issue_tracker: The source's issue reporting URL
+#
+class SourceProvenance:
+    def __init__(
+        self,
+        homepage: Optional[str],
+        issue_tracker: Optional[str],
+    ):
+        self.homepage: Optional[str] = homepage
+        self.issue_tracker: Optional[str] = issue_tracker
+
+    # new_from_node():
+    #
+    # Creates a SourceProvenance() from a YAML loaded node.
+    #
+    # Args:
+    #    node: The configuration node describing the spec.
+    #
+    # Returns:
+    #    The described SourceProvenance instance.
+    #
+    # Raises:
+    #    LoadError: If the node is malformed.
+    #
+    @classmethod
+    def new_from_node(cls, node: MappingNode) -> "SourceProvenance":
+        node.validate_keys(
+            [
+                "homepage",
+                "issue-tracker",
+            ]
+        )
+
+        homepage: Optional[str] = node.get_str("homepage", None)
+        issue_tracker: Optional[str] = node.get_str("issue-tracker", None)
+
+        return cls(
+            homepage,
+            issue_tracker,
+        )
+
+    def serialize(self) -> Dict[str, str]:
+        provenance = {}
+
+        if self.homepage is not None:
+            provenance["homepage"] = self.homepage
+
+        if self.issue_tracker is not None:
+            provenance["issue-tracker"] = self.homepage

Review Comment:
   ```suggestion
               provenance["issue-tracker"] = self.issue_tracker
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to