abderrahim commented on code in PR #1890:
URL: https://github.com/apache/buildstream/pull/1890#discussion_r1523626484
##########
tests/frontend/mirror.py:
##########
@@ -807,3 +807,93 @@ def test_mirror_expand_project_and_toplevel_root(cli,
tmpdir):
# Success if the expanded %{project-root} is found
assert foo_str in contents
assert bar_str in contents
+
+
+# Test a simple SourceMirror implementation which reads
+# plugin configuration and behaves in the same way as default
+# mirrors but using data in the plugin configuration instead.
+#
[email protected](DATA_DIR)
[email protected]("datafiles")
+def test_source_mirror_plugin(cli, tmpdir):
+ output_file = os.path.join(str(tmpdir), "output.txt")
+ project_dir = str(tmpdir)
+ element_dir = os.path.join(project_dir, "elements")
+ os.makedirs(element_dir, exist_ok=True)
+ element_name = "test.bst"
+ element_path = os.path.join(element_dir, element_name)
+ element = generate_element(output_file)
+ _yaml.roundtrip_dump(element, element_path)
+
+ project_file = os.path.join(project_dir, "project.conf")
+ project = {
+ "name": "test",
+ "min-version": "2.0",
+ "element-path": "elements",
+ "aliases": {
+ "foo": "FOO/",
+ "bar": "BAR/",
+ },
+ "mirrors": [
+ {
+ "name": "middle-earth",
+ "kind": "mirror",
+ "aliases": {
+ "foo": ["<invalid>"],
Review Comment:
Just to make sure, did you see my other comment?
https://github.com/apache/buildstream/pull/1890#discussion_r1509989058. I feel
that you're answering in the wrong thread.
I agree with what you say here, but I want to change it before landing this.
> yes I am in favor of expanding this later in order to support more generic
application of SourceMirror
> no it will not possibly work without specifying aliases in the patch's
current state.
I'm afraid we can't reconcile these two statements. If we want to expand
this later, we shouldn't make such a hard requirement. We need to leave
ourselves some space to work with.
##########
src/buildstream/_project.py:
##########
@@ -211,14 +235,10 @@ def source_overrides(self):
# fully qualified urls based on the shorthand which is allowed
# to be specified in the YAML
def translate_url(self, url, *, first_pass=False):
- if first_pass:
- config = self.first_pass_config
- else:
- config = self.config
if url and utils._ALIAS_SEPARATOR in url:
url_alias, url_body = url.split(utils._ALIAS_SEPARATOR, 1)
- alias_url = config._aliases.get_str(url_alias, default=None)
+ alias_url = self.get_alias_url(url_alias)
Review Comment:
```suggestion
alias_url = self.get_alias_url(url_alias, first_pass=first_pass)
```
--
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]