Browse Source

Basic work on supporting labels.

Very naïveimplementation of support for labels.  Issue #1
pull/2/head
Greg Holmes 7 years ago
parent
commit
3304fb1fc1
2 changed files with 21 additions and 0 deletions
  1. 9
    0
      docker_rerun.py
  2. 12
    0
      test.py

+ 9
- 0
docker_rerun.py View File

219
         container.image = args.image
219
         container.image = args.image
220
 
220
 
221
 
221
 
222
+def modify_labels(parser=None, args=None, container=None):
223
+    """Allows labels on the container to be modified."""
224
+    if parser:
225
+        parser.add_argument('--label', '-l', action='append',
226
+                            help='The new label to add to the container.')
227
+    elif args.label:
228
+        container.args.extend(['--label %s' % label for label in args.label])
229
+
230
+
222
 def modify_network(parser=None, args=None, container=None):
231
 def modify_network(parser=None, args=None, container=None):
223
     """Allows the network to be modified."""
232
     """Allows the network to be modified."""
224
     if parser:
233
     if parser:

+ 12
- 0
test.py View File

81
            ['docker', 'run', '--name=test123', '--network=host', '-d', 'hello-world'],
81
            ['docker', 'run', '--name=test123', '--network=host', '-d', 'hello-world'],
82
            ['--network', 'none'],
82
            ['--network', 'none'],
83
            ['docker', 'run', '--name=test123', '--network=none', '-d', 'hello-world'])
83
            ['docker', 'run', '--name=test123', '--network=none', '-d', 'hello-world'])
84
+    yield (check,
85
+           ['docker', 'run', '--name=test123', '-d', 'hello-world'],
86
+           ['--label', 'testLabel'],
87
+           ['docker', 'run', '--label=testLabel', '--name=test123', '-d', 'hello-world'])
88
+    yield (check,
89
+           ['docker', 'run', '--label=test', '--name=test123', '-d', 'hello-world'],
90
+           ['--label', 'test2'],
91
+           ['docker', 'run', '--label=test', '--label=test2', '--name=test123', '-d', 'hello-world'])
92
+    yield (check,
93
+           ['docker', 'run', '--label test=1', '--name=test123', '-d', 'hello-world'],
94
+           ['--label', 'test=2'],
95
+           ['docker', 'run', '--label test=2', '--name=test123', '-d', 'hello-world'])
84
 
96
 
85
 
97
 
86
 @with_setup(setup_each, teardown_each)
98
 @with_setup(setup_each, teardown_each)

Loading…
Cancel
Save