From f6f0c7130ed09400138325b92e86dd686f34d83d Mon Sep 17 00:00:00 2001 From: Eric Ball Date: Wed, 12 Dec 2018 18:06:48 -0800 Subject: [PATCH] Only print docker image list if not empty Issue: RELENG-1595 Change-Id: I516f5e6cedbe1e1bbf25f687e473ca3534c0b683 Signed-off-by: Eric Ball --- lftools/cli/nexus.py | 3 ++- lftools/nexus/cmd.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lftools/cli/nexus.py b/lftools/cli/nexus.py index 5576cf5e..34e7ef1d 100644 --- a/lftools/cli/nexus.py +++ b/lftools/cli/nexus.py @@ -97,7 +97,8 @@ def list_images(ctx, settings, server, repo, pattern, csv): if not server and 'NEXUS_URL_ENV' in environ: server = environ['NEXUS_URL_ENV'] images = nexuscmd.search(settings, server, repo, pattern) - nexuscmd.output_images(images, csv) + if images: + nexuscmd.output_images(images, csv) @docker.command(name="delete") diff --git a/lftools/nexus/cmd.py b/lftools/nexus/cmd.py index 5e149ece..9195112c 100644 --- a/lftools/nexus/cmd.py +++ b/lftools/nexus/cmd.py @@ -233,14 +233,16 @@ def search(settings_file, url, repo, pattern): def output_images(images, csv_path=None): """Output a list of images to stdout, or a provided file path. + This method expects a list of dicts with, at a minimum, "name", "version", + and "id" fields defined in each. :arg list images: Images to output. :arg str csv_path: Path to write out csv file of matching images. """ - count = len(images) - if not count: + if not images: log.warning("{}.{} called with empty images list".format( __name__, sys._getframe().f_code.co_name)) return + count = len(images) included_keys = images[0].keys() if csv_path: -- 2.16.6