summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Bridon <bochecha@daitauha.fr>2017-09-14 18:15:05 +0200
committerMathieu Bridon <bochecha@daitauha.fr>2017-09-19 09:34:00 +0200
commit00e08459c4ac0ee7d150b282d1228df1d60aff12 (patch)
treec2fbdecea70c03405a28253335d64a0c714613d1
parente1da62e4eccf94a11e60d972f87aa03b413ac350 (diff)
downloadbuildstream-00e08459c4ac0ee7d150b282d1228df1d60aff12.tar.gz
Let users override project artifacts options
A project can specify its artifacts cache sharing settings, and users can define a default artifacts cache to use as a fallback. With this change, users can also override the project configuration with their own. That means for a project named "libfoo", BuildStream will resolve the artifacts-related options in the following order: 1. the projects.libfoo.artifacts options from the user configuration; 2. if the above was not defined, then the artifacts options from the project configuration; 3. if the above was not defined, then the artifacts options from the user configuration; Fixes #87
-rw-r--r--buildstream/_artifactcache/artifactcache.py9
-rw-r--r--buildstream/_pipeline.py3
-rw-r--r--buildstream/context.py9
-rw-r--r--buildstream/data/userconfig.yaml17
4 files changed, 35 insertions, 3 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index 41625b655..2b779c95f 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -67,7 +67,14 @@ class ArtifactCache():
self.__pull_local = False
self.__push_local = False
- if any((project.artifact_pull, project.artifact_push)):
+ project_overrides = context.project_overrides.get(project.name, {}).get('artifacts', {})
+
+ if any((project_overrides.get('pull-url'), project_overrides.get('push-url'))):
+ self.artifact_pull = project_overrides.get('pull-url', '')
+ self.artifact_push = project_overrides.get('push-url', '')
+ self.artifact_push_port = project_overrides.get('push-port', 22)
+
+ elif 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
diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py
index 07f72bdc9..ba85c1147 100644
--- a/buildstream/_pipeline.py
+++ b/buildstream/_pipeline.py
@@ -133,7 +133,6 @@ class Pipeline():
cache_ticker=None):
self.context = context
self.project = project
- self.artifacts = ArtifactCache(self.context, self.project)
self.session_elements = 0
self.total_elements = 0
self.unused_workspaces = []
@@ -148,6 +147,8 @@ class Pipeline():
# Resolve project variant now that we've decided on one
project._resolve(loader.project_variant)
+ self.artifacts = ArtifactCache(self.context, self.project)
+
# Create the factories after resolving the project
pluginbase = PluginBase(package='buildstream.plugins')
self.element_factory = ElementFactory(pluginbase, project._plugin_element_paths)
diff --git a/buildstream/context.py b/buildstream/context.py
index 17503150f..6f378f700 100644
--- a/buildstream/context.py
+++ b/buildstream/context.py
@@ -118,6 +118,9 @@ class Context():
self.sched_error_action = 'continue'
"""What to do when a build fails in non interactive mode"""
+ self.project_overrides = {}
+ """Per-project overrides of project configurations"""
+
# Make sure the XDG vars are set in the environment before loading anything
self._init_xdg()
@@ -163,7 +166,8 @@ class Context():
'strict', 'sourcedir',
'builddir', 'artifactdir',
'logdir', 'scheduler',
- 'artifacts', 'logging'
+ 'artifacts', 'logging',
+ 'projects',
])
self.strict_build_plan = _yaml.node_get(defaults, bool, 'strict')
@@ -210,6 +214,9 @@ class Context():
self.sched_pushers = _yaml.node_get(scheduler, int, 'pushers')
self.sched_network_retries = _yaml.node_get(scheduler, int, 'network-retries')
+ # Load per-projects overrides
+ self.project_overrides = _yaml.node_get(defaults, Mapping, 'projects', default_value={})
+
profile_end(Topics.LOAD_CONTEXT, 'load')
valid_actions = ['continue', 'quit']
diff --git a/buildstream/data/userconfig.yaml b/buildstream/data/userconfig.yaml
index 1cce9fcd5..ce0812840 100644
--- a/buildstream/data/userconfig.yaml
+++ b/buildstream/data/userconfig.yaml
@@ -96,3 +96,20 @@ logging:
element-format: |
%{state: >12} %{key} %{name} %{variant} %{workspace-dirs}
+
+#
+# Per project overrides
+#
+# Some settings defined in the project configuration can be overridden by
+# the user configuration.
+#
+# projects:
+#
+# project1:
+# artifacts:
+# pull-url: https://artifacts.com
+# push-url: artifacts@artifacts.com:artifacts
+# push-port: 443
+#
+# project2:
+# ...