From 30b41959646e9076f45e21089216a27c1088cdb1 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Tue, 18 Sep 2018 18:14:37 +0900 Subject: _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 --- buildstream/_artifactcache/artifactcache.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py index b5c27a165..f4157c7ef 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) -- cgit v1.2.1