diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-10-31 18:52:27 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-10-31 20:16:37 +0900 |
commit | de35793125af66650568316c21b4a878b00ecb23 (patch) | |
tree | 6982378bc35c787b1e3091e5f3f58310adb12e6e | |
parent | b539ef4664179ae26f4f9b9931b7b428560937ad (diff) | |
download | buildstream-user-namespace-fallback.tar.gz |
_artifactcache/ostreecache.py: Allow explicit disabling of pushesuser-namespace-fallback
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.
-rw-r--r-- | buildstream/_artifactcache/ostreecache.py | 15 |
1 files changed, 14 insertions, 1 deletions
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: |