Browse Source

Allow setting the tag independently

tags/v0.1.1
Chris Smith 7 years ago
parent
commit
8c9e665f21
3 changed files with 17 additions and 0 deletions
  1. 1
    0
      README.md
  2. 12
    0
      docker-rerun
  3. 4
    0
      test.py

+ 1
- 0
README.md View File

@@ -65,6 +65,7 @@ of the container's parameters.
65 65
       --pull                Docker pull the image before re-running the container
66 66
       --image IMAGE         Image to use in place of the original
67 67
       --port PORT, -p PORT  Additional port to expose
68
+      --tag TAG             Image tag (version) to use
68 69
 
69 70
 ## What's not done yet
70 71
 

+ 12
- 0
docker-rerun View File

@@ -228,6 +228,18 @@ def modify_port_add(parser=None, args=None, container=None):
228 228
         container.args.extend(['-p=%s' % port for port in args.port])
229 229
 
230 230
 
231
+def modify_tag(parser=None, args=None, container=None):
232
+    """Allows the tag (version) to be updated."""
233
+    if parser:
234
+        parser.add_argument('--tag',
235
+                            help='Image tag (version) to use')
236
+    elif args.tag:
237
+        # Get rid of any existing digest or tag
238
+        image = container.image.replace('@', ':')
239
+        image = image.split(':')[0]
240
+        container.image = '%s:%s' % (image, args.tag)
241
+
242
+
231 243
 def functions():
232 244
     """Lists all functions defined in this module.
233 245
 

+ 4
- 0
test.py View File

@@ -66,6 +66,10 @@ def test_modifiers():
66 66
            ['docker', 'run', '--name=test123', '-d', 'hello-world'],
67 67
            ['--port', '123:456', '-p', '80'],
68 68
            ['docker', 'run', '--name=test123', '-d', '-p=123:456', '-p=80', 'hello-world'])
69
+    yield (check,
70
+           ['docker', 'run', '--name=test123', '-d', 'hello-world'],
71
+           ['--tag', 'latest'],
72
+           ['docker', 'run', '--name=test123', '-d', 'hello-world:latest'])
69 73
 
70 74
 
71 75
 @with_setup(setup_each, teardown_each)

Loading…
Cancel
Save