-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1931 from apache/tristan/junction-source-mirrors
Implement `pip` and `junction` origin loading for SourceMirror plugins
- Loading branch information
Showing
10 changed files
with
211 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
36 changes: 36 additions & 0 deletions
36
tests/plugins/sample-plugins/src/sample_plugins/sourcemirrors/mirror.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import Optional, Dict, Any | ||
|
||
from buildstream import SourceMirror, MappingNode | ||
|
||
|
||
# This mirror plugin basically implements the default behavior | ||
# by loading the alias definitions as custom "config" configuration | ||
# instead, and implementing the translate_url method. | ||
# | ||
class Sample(SourceMirror): | ||
def configure(self, node): | ||
node.validate_keys(["aliases"]) | ||
|
||
self.aliases = {} | ||
|
||
aliases = node.get_mapping("aliases") | ||
for alias_name, url_list in aliases.items(): | ||
self.aliases[alias_name] = url_list.as_str_list() | ||
|
||
self.set_supported_aliases(self.aliases.keys()) | ||
|
||
def translate_url( | ||
self, | ||
*, | ||
alias: str, | ||
alias_url: str, | ||
source_url: str, | ||
extra_data: Optional[Dict[str, Any]], | ||
) -> str: | ||
return self.aliases[alias][0] + source_url | ||
|
||
|
||
# Plugin entry point | ||
def setup(): | ||
|
||
return Sample |