Add --label command line option
MODIFY
repo2docker/__main__.py
repo2docker/__main__.py
@@ -204,6 +204,14 @@ def get_argparser():
argparser.add_argument("--appendix", type=str, help=Repo2Docker.appendix.help)
+ argparser.add_argument(
+ "--label",
+ dest="labels",
+ action="append",
+ help="Extra label to set on the image, in form name=value",
+ default=[],
+ )
+
argparser.add_argument("--subdir", type=str, help=Repo2Docker.subdir.help)
argparser.add_argument(
@@ -246,6 +254,13 @@ def make_r2d(argv=None):
if args.appendix:
r2d.appendix = args.appendix
+ for l in args.labels:
+ if "=" in l:
+ key, val = l.split("=", 1)
+ r2d.labels[key] = val
+ else:
+ r2d.labels[l] = ""
+
r2d.repo = args.repo
r2d.ref = args.ref

MODIFY
repo2docker/app.py
repo2docker/app.py
@@ -237,6 +237,17 @@ class Repo2Docker(Application):
""",
)
+ labels = Dict(
+ {},
+ help="""
+ Extra labels to set on the final image.
+
+ Each Label is a key-value pair, with the key being the name of the label
+ and the value its value.
+ """,
+ config=True,
+ )
+
json_logs = Bool(
False,
help="""
@@ -747,6 +758,8 @@ class Repo2Docker(Application):
picked_buildpack.labels["repo2docker.repo"] = repo_label
picked_buildpack.labels["repo2docker.ref"] = self.ref
+ picked_buildpack.labels.update(self.labels)
+
if self.dry_run:
print(picked_buildpack.render())
else:

Add --label command line option