7
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-06-07 00:20:49 +00:00

Merge branch 'master' into nightly

This commit is contained in:
Régis Behmo 2021-12-02 10:33:02 +01:00
commit c152578783
2 changed files with 42 additions and 6 deletions

View File

@ -3,6 +3,8 @@
Note: Breaking changes between versions are indicated by "💥".
## Unreleased
- 💥[Improvement] Fail on incorrect image name argument in `images build/pull/push/printtag` commands.
- [Bugfix] Remove trailing slashes in docker-compose files for [compatibility with docker-compose v2 in WSL](https://github.com/docker/compose/issues/8558).
- [Improvement] `settheme` now works with preview domain.
- [Feature] Allow specifying extra pip packages through config.yml.

View File

@ -108,35 +108,64 @@ def push(context: Context, image_names: List[str]) -> None:
def printtag(context: Context, image_names: List[str]) -> None:
config = tutor_config.load(context.root)
for image in image_names:
to_print = []
for _img, tag in iter_images(config, image, BASE_IMAGE_NAMES):
print(tag)
to_print.append(tag)
for _plugin, _img, tag in iter_plugin_images(config, image, "build-image"):
to_print.append(tag)
if not to_print:
raise ImageNotFoundError(image)
for tag in to_print:
print(tag)
def build_image(root: str, config: Config, image: str, *args: str) -> None:
to_build = []
# Build base images
for img, tag in iter_images(config, image, BASE_IMAGE_NAMES):
images.build(tutor_env.pathjoin(root, "build", img), tag, *args)
to_build.append((tutor_env.pathjoin(root, "build", img), tag, args))
# Build plugin images
for plugin, img, tag in iter_plugin_images(config, image, "build-image"):
images.build(
tutor_env.pathjoin(root, "plugins", plugin, "build", img), tag, *args
to_build.append(
(tutor_env.pathjoin(root, "plugins", plugin, "build", img), tag, args)
)
if not to_build:
raise ImageNotFoundError(image)
for path, tag, build_args in to_build:
images.build(path, tag, *args)
def pull_image(config: Config, image: str) -> None:
to_pull = []
for _img, tag in iter_images(config, image, all_image_names(config)):
images.pull(tag)
to_pull.append(tag)
for _plugin, _img, tag in iter_plugin_images(config, image, "remote-image"):
to_pull.append(tag)
if not to_pull:
raise ImageNotFoundError(image)
for tag in to_pull:
images.pull(tag)
def push_image(config: Config, image: str) -> None:
to_push = []
for _img, tag in iter_images(config, image, BASE_IMAGE_NAMES):
images.push(tag)
to_push.append(tag)
for _plugin, _img, tag in iter_plugin_images(config, image, "remote-image"):
to_push.append(tag)
if not to_push:
raise ImageNotFoundError(image)
for tag in to_push:
images.push(tag)
@ -177,6 +206,11 @@ def vendor_image_names(config: Config) -> List[str]:
return vendor_images
class ImageNotFoundError(exceptions.TutorError):
def __init__(self, image_name: str):
super().__init__("Image '{}' could not be found".format(image_name))
images_command.add_command(build)
images_command.add_command(pull)
images_command.add_command(push)