6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-11-04 20:37:52 +00:00

Add images printtag command

This commit is contained in:
Régis Behmo 2020-10-02 00:25:03 +02:00
parent baa06f27a7
commit ccee481dd0
2 changed files with 25 additions and 11 deletions

View File

@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥".
## Unreleased
- [Feature] Add ``images printtag`` command
- [Improvement] Make it possible to override individual contact email addresses with plugins
- [Bugfix] Replace "no-reply@LMS_BASE" email address by regular contact email address
- [Bugfix] Disable learner records globally by default

View File

@ -20,7 +20,7 @@ def images_command():
short_help="Build docker images",
help="Build the docker images necessary for an Open edX platform.",
)
@click.argument("image", nargs=-1)
@click.argument("image_names", metavar="image", nargs=-1)
@click.option(
"--no-cache", is_flag=True, help="Do not use cache when building the image"
)
@ -38,7 +38,7 @@ def images_command():
help="Set a custom host-to-IP mapping (host:ip).",
)
@click.pass_obj
def build(context, image, no_cache, build_args, add_hosts):
def build(context, image_names, no_cache, build_args, add_hosts):
config = tutor_config.load(context.root)
command_args = []
if no_cache:
@ -47,26 +47,38 @@ def build(context, image, no_cache, build_args, add_hosts):
command_args += ["--build-arg", build_arg]
for add_host in add_hosts:
command_args += ["--add-host", add_host]
for i in image:
build_image(context.root, config, i, *command_args)
for image in image_names:
build_image(context.root, config, image, *command_args)
@click.command(short_help="Pull images from the Docker registry")
@click.argument("image", nargs=-1)
@click.argument("image_names", metavar="image", nargs=-1)
@click.pass_obj
def pull(context, image):
def pull(context, image_names):
config = tutor_config.load(context.root)
for i in image:
for image in image_names:
pull_image(config, i)
@click.command(short_help="Push images to the Docker registry")
@click.argument("image", nargs=-1)
@click.argument("image_names", metavar="image", nargs=-1)
@click.pass_obj
def push(context, image):
def push(context, image_names):
config = tutor_config.load(context.root)
for i in image:
push_image(config, i)
for image in image_names:
push_image(config, image)
@click.command(short_help="Print tag associated to a Docker image")
@click.argument("image_names", metavar="image", nargs=-1)
@click.pass_obj
def printtag(context, image_names):
config = tutor_config.load(context.root)
for image in image_names:
for _img, tag in iter_images(config, image, BASE_IMAGE_NAMES):
print(tag)
for _img, tag in iter_plugin_images(config, image, "build-image"):
print(tag)
def build_image(root, config, image, *args):
@ -139,3 +151,4 @@ def vendor_image_names(config):
images_command.add_command(build)
images_command.add_command(pull)
images_command.add_command(push)
images_command.add_command(printtag)