summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-09-18 18:14:37 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-09-18 18:56:21 +0900
commitcdd9a58678b54155c47821899fd3ccf89b895280 (patch)
tree788af297cd2ec25b650f3f01eb9411bd9c88f23d
parentc8c51231481d2c881e5cffc2b400a95bb43184fa (diff)
downloadbuildstream-cdd9a58678b54155c47821899fd3ccf89b895280.tar.gz
_artifactcache/artifactcache.py: Error out gracefully when push remote is mal-specified
When configuring a push remote and specifying either the client-cert or the client-key, then both must be specified. This ensures we get an informative error instead of a stack trace and BUG. Fixes issue #625
-rw-r--r--buildstream/_artifactcache/artifactcache.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index aa11d92a9..b0cb4f353 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -51,7 +51,7 @@ class ArtifactCacheSpec(namedtuple('ArtifactCacheSpec', 'url push server_cert cl
url = _yaml.node_get(spec_node, str, 'url')
push = _yaml.node_get(spec_node, bool, 'push', default_value=False)
if not url:
- provenance = _yaml.node_get_provenance(spec_node)
+ provenance = _yaml.node_get_provenance(spec_node, 'url')
raise LoadError(LoadErrorReason.INVALID_DATA,
"{}: empty artifact cache URL".format(provenance))
@@ -67,6 +67,16 @@ class ArtifactCacheSpec(namedtuple('ArtifactCacheSpec', 'url push server_cert cl
if client_cert and basedir:
client_cert = os.path.join(basedir, client_cert)
+ if client_key and not client_cert:
+ provenance = _yaml.node_get_provenance(spec_node, 'client-key')
+ raise LoadError(LoadErrorReason.INVALID_DATA,
+ "{}: 'client-key' was specified without 'client-cert'".format(provenance))
+
+ if client_cert and not client_key:
+ provenance = _yaml.node_get_provenance(spec_node, 'client-cert')
+ raise LoadError(LoadErrorReason.INVALID_DATA,
+ "{}: 'client-cert' was specified without 'client-key'".format(provenance))
+
return ArtifactCacheSpec(url, push, server_cert, client_key, client_cert)