From de35793125af66650568316c21b4a878b00ecb23 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Tue, 31 Oct 2017 18:52:27 +0900 Subject: _artifactcache/ostreecache.py: Allow explicit disabling of pushes This is used by the platform to disable pushing explicitly in the case that we're falling back to not using user namespaces, in which case we dont entirely trust the artifacts we create. --- buildstream/_artifactcache/ostreecache.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/buildstream/_artifactcache/ostreecache.py b/buildstream/_artifactcache/ostreecache.py index 079cf95cf..85ad3a4cf 100644 --- a/buildstream/_artifactcache/ostreecache.py +++ b/buildstream/_artifactcache/ostreecache.py @@ -53,11 +53,19 @@ def buildref(element, key): # Args: # context (Context): The BuildStream context # project (Project): The BuildStream project +# enable_push (bool): Whether pushing is allowed +# +# Pushing is explicitly disabled by the platform in some cases, +# like when we are falling back to functioning without using +# user namespaces. # class OSTreeCache(ArtifactCache): - def __init__(self, context, project): + + def __init__(self, context, project, enable_push): super().__init__(context, project) + self.enable_push = enable_push + ostreedir = os.path.join(context.artifactdir, 'ostree') self.repo = _ostree.ensure(ostreedir, False) @@ -66,6 +74,11 @@ class OSTreeCache(ArtifactCache): self._remote_refs = None + def can_push(self): + if self.enable_push: + return super().can_push() + return False + def preflight(self): if self.can_push() and not self.artifact_push.startswith("/"): try: -- cgit v1.2.1