diff options
author | Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk> | 2019-03-07 14:49:02 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-03-25 11:46:44 +0000 |
commit | bcd1a3b766dc311d3e809c6f5176990c73b9c481 (patch) | |
tree | 197d39a9c056759e364e1cf4878bec3bf4f7ed36 | |
parent | e5c6ad839b8ad1dc90f4df3f71af9cf9ac881f57 (diff) | |
download | buildstream-bcd1a3b766dc311d3e809c6f5176990c73b9c481.tar.gz |
_sourcecache.py: Add push method
Part of #440
-rw-r--r-- | buildstream/_artifactcache.py | 2 | ||||
-rw-r--r-- | buildstream/_sourcecache.py | 35 |
2 files changed, 36 insertions, 1 deletions
diff --git a/buildstream/_artifactcache.py b/buildstream/_artifactcache.py index 4504db299..3ca6c6e60 100644 --- a/buildstream/_artifactcache.py +++ b/buildstream/_artifactcache.py @@ -295,7 +295,7 @@ class ArtifactCache(BaseCache): element.info("Pushed artifact {} -> {}".format(display_key, remote.spec.url)) pushed = True else: - element.info("Remote ({}) already has {} cached".format( + element.info("Remote ({}) already has artifact {} cached".format( remote.spec.url, element._get_brief_display_key() )) diff --git a/buildstream/_sourcecache.py b/buildstream/_sourcecache.py index 760412d88..219ecb1e9 100644 --- a/buildstream/_sourcecache.py +++ b/buildstream/_sourcecache.py @@ -176,3 +176,38 @@ class SourceCache(BaseCache): raise SourceCacheError("Failed to pull source {}: {}".format( display_key, e)) from e return False + + # push() + # + # Push a source to configured remote source caches + # + # Args: + # source (Source): source to push + # + # Returns: + # (Bool): whether it pushed to a remote source cache + # + def push(self, source): + ref = source._get_source_name() + project = source._get_project() + + # find configured push remotes for this source + if self._has_push_remotes: + push_remotes = [r for r in self._remotes[project] if r.spec.push] + else: + push_remotes = [] + + pushed = False + + display_key = source._get_brief_display_key() + for remote in push_remotes: + remote.init() + source.status("Pushing source {} -> {}".format(display_key, remote.spec.url)) + if self.cas.push([ref], remote): + source.info("Pushed source {} -> {}".format(display_key, remote.spec.url)) + pushed = True + else: + source.info("Remote ({}) already has source {} cached" + .format(remote.spec.url, display_key)) + + return pushed |