From 784dcfb0ccb1d49603b60379881ab432812d595e Mon Sep 17 00:00:00 2001 From: Pieter Ouwerkerk Date: Tue, 21 Jan 2025 16:37:04 -0500 Subject: [PATCH 1/3] Add flag for disabling labels from the output --- runlike/inspector.py | 6 ++++-- runlike/runlike.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/runlike/inspector.py b/runlike/inspector.py index 8ebe3a6..9d34100 100644 --- a/runlike/inspector.py +++ b/runlike/inspector.py @@ -11,9 +11,10 @@ def die(message): class Inspector(object): - def __init__(self, container=None, no_name=None, use_volume_id=None, pretty=None): + def __init__(self, container=None, no_name=None, use_volume_id=None, pretty=None, no_labels=None): self.container = container self.no_name = no_name + self.no_labels = no_labels self.use_volume_id = use_volume_id self.pretty = pretty self.container_facts = None @@ -287,7 +288,8 @@ def format_cli(self): self.parse_links() self.parse_restart() self.parse_devices() - self.parse_labels() + if not self.no_labels: + self.parse_labels() self.parse_log() self.parse_extra_hosts() self.parse_runtime() diff --git a/runlike/runlike.py b/runlike/runlike.py index 243c631..bc1e70f 100755 --- a/runlike/runlike.py +++ b/runlike/runlike.py @@ -22,11 +22,13 @@ help="Keep the automatically assigned volume id") @click.option("-p", "--pretty", is_flag=True) @click.option("-s", "--stdin", is_flag=True) -def cli(container, no_name, use_volume_id, pretty, stdin): +@click.option("-l", "--no-labels", is_flag=True) + +def cli(container, no_name, use_volume_id, pretty, stdin, no_labels): # TODO: -i, -t, -d as added options that override the inspection if container or stdin: - ins = Inspector(container, no_name, use_volume_id, pretty) + ins = Inspector(container, no_name, use_volume_id, pretty, no_labels) if container: ins.inspect() elif stdin: From 69564df1b222e007e5aeadada1d04460db3c2221 Mon Sep 17 00:00:00 2001 From: Pieter Ouwerkerk Date: Tue, 21 Jan 2025 16:37:52 -0500 Subject: [PATCH 2/3] Add help message --- runlike/runlike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runlike/runlike.py b/runlike/runlike.py index bc1e70f..f85091b 100755 --- a/runlike/runlike.py +++ b/runlike/runlike.py @@ -22,7 +22,7 @@ help="Keep the automatically assigned volume id") @click.option("-p", "--pretty", is_flag=True) @click.option("-s", "--stdin", is_flag=True) -@click.option("-l", "--no-labels", is_flag=True) +@click.option("-l", "--no-labels", is_flag=True, help="Do not include labels in output") def cli(container, no_name, use_volume_id, pretty, stdin, no_labels): From da0e9cccf3a42c86d88d73bbee73f00429d616f0 Mon Sep 17 00:00:00 2001 From: Pieter Ouwerkerk Date: Tue, 21 Jan 2025 16:43:18 -0500 Subject: [PATCH 3/3] Add test for --no-labels flag --- test_runlike.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test_runlike.py b/test_runlike.py index 204bf85..a4b2334 100644 --- a/test_runlike.py +++ b/test_runlike.py @@ -217,3 +217,11 @@ def setUpClass(cls): def test_no_name(self): self.dont_expect_substr("--name") + +class TestRunlikeNoLabels(BaseTest): + @classmethod + def setUpClass(cls): + cls.start_runlike(["--no-labels"]) + + def test_no_labels(self): + self.dont_expect_substr("--label")