tests/docker: add "fetch" sub-command
authorAlex Bennée <alex.bennee@linaro.org>
Wed, 12 May 2021 10:20:25 +0000 (11:20 +0100)
committerAlex Bennée <alex.bennee@linaro.org>
Tue, 18 May 2021 08:35:39 +0000 (09:35 +0100)
This simply wraps up fetching a build from the registry and tagging it
as the local build.

Reviewed-by: Willian Rampazzo <willianr@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210512102051.12134-6-alex.bennee@linaro.org>

tests/docker/docker.py

index 7a140588015f54e9eae76211ebe3d3d4b0f7e32e..4d9bb7c7ed24902290f8b1797fc05bf0d4e260d6 100755 (executable)
@@ -515,6 +515,23 @@ class BuildCommand(SubCommand):
 
         return 0
 
+class FetchCommand(SubCommand):
+    """ Fetch a docker image from the registry. Args: <tag> <registry>"""
+    name = "fetch"
+
+    def args(self, parser):
+        parser.add_argument("tag",
+                            help="Local tag for image")
+        parser.add_argument("registry",
+                            help="Docker registry")
+
+    def run(self, args, argv):
+        dkr = Docker()
+        dkr.command(cmd="pull", quiet=args.quiet,
+                    argv=["%s/%s" % (args.registry, args.tag)])
+        dkr.command(cmd="tag", quiet=args.quiet,
+                    argv=["%s/%s" % (args.registry, args.tag), args.tag])
+
 
 class UpdateCommand(SubCommand):
     """ Update a docker image. Args: <tag> <actions>"""