gtristan commented on code in PR #1895:
URL: https://github.com/apache/buildstream/pull/1895#discussion_r1510843163


##########
src/buildstream/downloadablefilesource.py:
##########
@@ -145,7 +221,22 @@ class DownloadableFileSource(Source):
     def configure(self, node):
         self.original_url = node.get_str("url")
         self.ref = node.get_str("ref", None)
-        self.url = self.translate_url(self.original_url)
+
+        extra_data = {}
+        self.url = self.translate_url(self.original_url, extra_data=extra_data)
+        self.auth_header_format = extra_data.get("auth-header-format")
+
+        #
+        # Validate the auth header format for a `{password}` formatting 
identifier
+        #
+        if self.auth_header_format:
+            try:
+                self.auth_header_format.format(password="dummy")
+            except KeyError as e:
+                raise SourceError(
+                    "SourceMirror specified auth-header-format without a 
password", detail=self.auth_header_format
+                ) from e

Review Comment:
   Ah good catch, I presumed this was the other way around when trying this in 
the shell:
   
   ```
   >>> "foo {pizza}".format(password="cheese")
   KeyError
   ```
   But as you point out indeed:
   ```
   "foo".format(password="monkey")
   'foo'
   ```
   



-- 
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