diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-09-18 18:14:37 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-09-18 18:56:45 +0900 |
commit | 30b41959646e9076f45e21089216a27c1088cdb1 (patch) | |
tree | 5a87fc5a7d5855a2775b1c1e07def930cfb568aa | |
parent | b587579f76f2e47aa9f24a9c00075f79428be818 (diff) | |
download | buildstream-30b41959646e9076f45e21089216a27c1088cdb1.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.py | 12 |
1 files changed, 11 insertions, 1 deletions
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) |