From e1da62e4eccf94a11e60d972f87aa03b413ac350 Mon Sep 17 00:00:00 2001 From: Mathieu Bridon Date: Sat, 9 Sep 2017 11:57:23 +0200 Subject: 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 --- buildstream/_artifactcache/artifactcache.py | 15 +++++++++++---- buildstream/_pipeline.py | 2 +- buildstream/data/projectconfig.yaml | 16 ++++++++++++++++ buildstream/project.py | 8 ++++++++ 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(): -- cgit v1.2.1