mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-12-13 22:48:20 +00:00
336cb79fa8
I stumbled upon a bug that should have been detected by the type checking. Turns out, considering that config is of type Dict[str, Any] means that we can use just any method on all config values -- which is terrible. I discovered this after I set `config["PLUGINS"] = None`: this triggered a crash when I enabled a plugin. We resolve this by making the Config type more explicit. We also take the opportunity to remove a few cast statements.
23 lines
584 B
Python
23 lines
584 B
Python
from . import fmt, utils
|
|
from .types import Config, get_typed
|
|
|
|
|
|
def get_tag(config: Config, name: str) -> str:
|
|
key = "DOCKER_IMAGE_" + name.upper().replace("-", "_")
|
|
return get_typed(config, key, str)
|
|
|
|
|
|
def build(path: str, tag: str, *args: str) -> None:
|
|
fmt.echo_info("Building image {}".format(tag))
|
|
utils.docker("build", "-t", tag, *args, path)
|
|
|
|
|
|
def pull(tag: str) -> None:
|
|
fmt.echo_info("Pulling image {}".format(tag))
|
|
utils.docker("pull", tag)
|
|
|
|
|
|
def push(tag: str) -> None:
|
|
fmt.echo_info("Pushing image {}".format(tag))
|
|
utils.docker("push", tag)
|