summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Bridon <bochecha@daitauha.fr>2017-09-09 11:57:23 +0200
committerMathieu Bridon <bochecha@daitauha.fr>2017-09-19 09:34:00 +0200
commite1da62e4eccf94a11e60d972f87aa03b413ac350 (patch)
tree44258786fdfdfc419d30a678b8bf67718442dfb4
parent606ce8fa46f7d5bc45763388fa721a8a633759f5 (diff)
downloadbuildstream-e1da62e4eccf94a11e60d972f87aa03b413ac350.tar.gz
Let projects configure their artifacts pull/push options
With this commit, we first look at the artifacts options in the project configuration, then fall back on the user configuration if necessary. Relates to #87
-rw-r--r--buildstream/_artifactcache/artifactcache.py15
-rw-r--r--buildstream/_pipeline.py2
-rw-r--r--buildstream/data/projectconfig.yaml16
-rw-r--r--buildstream/project.py8
4 files changed, 36 insertions, 5 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index 1f643ca45..41625b655 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -52,9 +52,10 @@ def buildref(element, key):
#
# Args:
# context (Context): The BuildStream context
+# project (Project): The BuildStream project
#
class ArtifactCache():
- def __init__(self, context):
+ def __init__(self, context, project):
self.context = context
@@ -66,9 +67,15 @@ class ArtifactCache():
self.__pull_local = False
self.__push_local = False
- self.artifact_pull = context.artifact_pull
- self.artifact_push = context.artifact_push
- self.artifact_push_port = context.artifact_push_port
+ if any((project.artifact_pull, project.artifact_push)):
+ self.artifact_pull = project.artifact_pull
+ self.artifact_push = project.artifact_push
+ self.artifact_push_port = project.artifact_push_port
+
+ else:
+ self.artifact_pull = context.artifact_pull
+ self.artifact_push = context.artifact_push
+ self.artifact_push_port = context.artifact_push_port
if self.artifact_push:
if self.artifact_push.startswith("/") or \
diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py
index 6359f1012..07f72bdc9 100644
--- a/buildstream/_pipeline.py
+++ b/buildstream/_pipeline.py
@@ -133,7 +133,7 @@ class Pipeline():
cache_ticker=None):
self.context = context
self.project = project
- self.artifacts = ArtifactCache(self.context)
+ self.artifacts = ArtifactCache(self.context, self.project)
self.session_elements = 0
self.total_elements = 0
self.unused_workspaces = []
diff --git a/buildstream/data/projectconfig.yaml b/buildstream/data/projectconfig.yaml
index aa9605358..6406f1609 100644
--- a/buildstream/data/projectconfig.yaml
+++ b/buildstream/data/projectconfig.yaml
@@ -229,6 +229,22 @@ split-rules:
- |
%{datadir}/zoneinfo/**
+#
+# Artifacts
+#
+artifacts:
+
+ # A url from which to download prebuilt artifacts
+ pull-url: ''
+
+ # A url to upload built artifacts to
+ # (must point to the same repository as pull-url)
+ push-url: ''
+
+ # Specify the port number for pushing artifacts, if it's
+ # not the default port 22
+ push-port: 22
+
# Element Overrides
#
# Base attributes declared by element default yaml files
diff --git a/buildstream/project.py b/buildstream/project.py
index a1e111e52..f44ca4605 100644
--- a/buildstream/project.py
+++ b/buildstream/project.py
@@ -165,6 +165,7 @@ class Project():
'split-rules', 'elements', 'plugins',
'aliases', 'name',
'arches', 'host-arches',
+ 'artifacts',
])
# Resolve arches keyword, project may have arch conditionals
@@ -195,6 +196,13 @@ class Project():
# Workspace configurations
self.__workspaces = self._load_workspace_config()
+ # Load artifacts pull/push configuration for this project
+ artifacts = _yaml.node_get(config, Mapping, 'artifacts')
+ _yaml.validate_node(artifacts, ['pull-url', 'push-url', 'push-port'])
+ self.artifact_pull = _yaml.node_get(artifacts, str, 'pull-url', default_value='') or None
+ self.artifact_push = _yaml.node_get(artifacts, str, 'push-url', default_value='') or None
+ self.artifact_push_port = _yaml.node_get(artifacts, int, 'push-port', default_value=22)
+
return config
# _resolve():