[docker] Add option to force the latest tag

This patch adds a `--force-latest` that allows users to force
using the simple `latest` tag even when the default base OS
is not used. This is useful because the latest tag is often
used to retrieve the last relevant build and is commonly used
when a user just wants to test or use their latest build.

For example if a user wants to test the quickstart with CentOS 7
they can build with `--force-latest` and run normally as opposed
to manually editing the quickstart.yml file.

This is also useful for CI/CD pipelines that always want to publish
the last build image as `latest`.

Change-Id: I13ff38683d3f923577f8728fdf30a4b3e09bc943
Reviewed-on: http://gerrit.cloudera.org:8080/17574
Tested-by: Kudu Jenkins
Reviewed-by: Alexey Serbin <aserbin@cloudera.com>
diff --git a/docker/docker-build.py b/docker/docker-build.py
index dc7ee9e..6f66d22 100755
--- a/docker/docker-build.py
+++ b/docker/docker-build.py
@@ -114,9 +114,12 @@
                            'images to docker so they can be used locally. "push" will push the '
                            'images to the registry.')
 
+  parser.add_argument('--force-latest', action='store_true',
+                      help='If passed, forces adding the simple `latest` tag even though the base '
+                           'image is not the default OS')
   parser.add_argument('--skip-latest', action='store_true',
                       help='If passed, skips adding a tag using `-latest` along with the '
-                      'versioned tag')
+                      'versioned tag. Note: This overrides the --force-latest tag above.')
   parser.add_argument('--tag-hash', action='store_true',
                       help='If passed, keeps the tags using the short git hash as the version '
                       'for non-release builds. Leaving this as false ensures the tags '
@@ -281,7 +284,7 @@
     latest_tag = get_full_tag(opts.repository, target, 'latest', os_tag)
     tags.append(latest_tag)
     # Add the default OS tag.
-    if base == DEFAULT_OS:
+    if base == DEFAULT_OS or opts.force_latest:
       latest_default_os_tag = get_full_tag(opts.repository, target, 'latest', '')
       tags.append(latest_default_os_tag)