Skip to content

Commit 5cd990f

Browse files
authored
Merge pull request #125 from pouwerkerk/master
Add flag for disabling labels from the output
2 parents 8acb541 + da0e9cc commit 5cd990f

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

runlike/inspector.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ def die(message):
1111

1212
class Inspector(object):
1313

14-
def __init__(self, container=None, no_name=None, use_volume_id=None, pretty=None):
14+
def __init__(self, container=None, no_name=None, use_volume_id=None, pretty=None, no_labels=None):
1515
self.container = container
1616
self.no_name = no_name
17+
self.no_labels = no_labels
1718
self.use_volume_id = use_volume_id
1819
self.pretty = pretty
1920
self.container_facts = None
@@ -287,7 +288,8 @@ def format_cli(self):
287288
self.parse_links()
288289
self.parse_restart()
289290
self.parse_devices()
290-
self.parse_labels()
291+
if not self.no_labels:
292+
self.parse_labels()
291293
self.parse_log()
292294
self.parse_extra_hosts()
293295
self.parse_runtime()

runlike/runlike.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
help="Keep the automatically assigned volume id")
2323
@click.option("-p", "--pretty", is_flag=True)
2424
@click.option("-s", "--stdin", is_flag=True)
25-
def cli(container, no_name, use_volume_id, pretty, stdin):
25+
@click.option("-l", "--no-labels", is_flag=True, help="Do not include labels in output")
26+
27+
def cli(container, no_name, use_volume_id, pretty, stdin, no_labels):
2628

2729
# TODO: -i, -t, -d as added options that override the inspection
2830
if container or stdin:
29-
ins = Inspector(container, no_name, use_volume_id, pretty)
31+
ins = Inspector(container, no_name, use_volume_id, pretty, no_labels)
3032
if container:
3133
ins.inspect()
3234
elif stdin:

test_runlike.py

+8
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,11 @@ def setUpClass(cls):
217217

218218
def test_no_name(self):
219219
self.dont_expect_substr("--name")
220+
221+
class TestRunlikeNoLabels(BaseTest):
222+
@classmethod
223+
def setUpClass(cls):
224+
cls.start_runlike(["--no-labels"])
225+
226+
def test_no_labels(self):
227+
self.dont_expect_substr("--label")

0 commit comments

Comments
 (0)