Add --label command line option

pull/1097/head
Timo Rothenpieler 2021-11-23 20:37:37 +01:00
rodzic fa512e76bd
commit 86df151414
2 zmienionych plików z 28 dodań i 0 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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: