From 03a073fd76f367ea54e09abf4313b153685be961 Mon Sep 17 00:00:00 2001 From: Rodrigo Queiro Date: Thu, 8 Mar 2018 05:54:56 +0100 Subject: [PATCH] Improve "not found" error message (#121) The current message: ``` The following image references were not found: [eu.gcr.io/robco-rodrigoq/move-endpoint:latest] ``` suggests to the untrained eye that they should check that image has not been found on the container registry, as the user may not know that the resolver is replacing image references inside the YAML file. This commit changes the message to: ``` ERROR: The following image references were not found in '/your/bazel/cache/dir/execroot/__main__bazel-out/k8-opt/bin/your/package/path/k8s.runfiles/__main__/your/package/path/deployment.yaml': eu.gcr.io/robco-rodrigoq/move-endpoint:latest ``` which is very long but hopefully clearer, as the user can look at that file to work out why the image reference is not found. --- k8s/resolver.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/k8s/resolver.py b/k8s/resolver.py index 19fb5b7c..761dbe08 100644 --- a/k8s/resolver.py +++ b/k8s/resolver.py @@ -188,9 +188,10 @@ def _StringToDigest(t): content = Resolve(inputs, _StringToDigest) if len(unseen_strings) > 0: - print('The following image references were not found: [%s]' % "\n".join([ - str(x) for x in unseen_strings - ]),file=sys.stderr) + print('ERROR: The following image references were not found in %r:' % + args.template, file=sys.stderr) + for ref in unseen_strings: + print(' %s' % ref, file=sys.stderr) sys.exit(1) print(content)