From bae952a0f9bb048dab0d7c8e4f289110982ce398 Mon Sep 17 00:00:00 2001 From: Julio Faerman <356476+faermanj@users.noreply.github.com> Date: Mon, 20 Nov 2023 18:52:45 +0000 Subject: [PATCH] fix "up ansible --version" --- uplib/poetry.lock | 13 +++++++------ uplib/uplib/containers.py | 6 +++++- uplib/uplib/main.py | 6 ++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/uplib/poetry.lock b/uplib/poetry.lock index e9723e0..ac4bb9c 100644 --- a/uplib/poetry.lock +++ b/uplib/poetry.lock @@ -30,13 +30,13 @@ tests-no-zope = ["cloudpickle", "hypothesis", "mypy (>=1.1.1)", "pympler", "pyte [[package]] name = "certifi" -version = "2023.7.22" +version = "2023.11.17" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2023.7.22-py3-none-any.whl", hash = "sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9"}, - {file = "certifi-2023.7.22.tar.gz", hash = "sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082"}, + {file = "certifi-2023.11.17-py3-none-any.whl", hash = "sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474"}, + {file = "certifi-2023.11.17.tar.gz", hash = "sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1"}, ] [[package]] @@ -324,17 +324,18 @@ files = [ [[package]] name = "pygments" -version = "2.16.1" +version = "2.17.1" description = "Pygments is a syntax highlighting package written in Python." optional = false python-versions = ">=3.7" files = [ - {file = "Pygments-2.16.1-py3-none-any.whl", hash = "sha256:13fc09fa63bc8d8671a6d247e1eb303c4b343eaee81d861f3404db2935653692"}, - {file = "Pygments-2.16.1.tar.gz", hash = "sha256:1daff0494820c69bc8941e407aa20f577374ee88364ee10a98fdbe0aece96e29"}, + {file = "pygments-2.17.1-py3-none-any.whl", hash = "sha256:1b37f1b1e1bff2af52ecaf28cc601e2ef7077000b227a0675da25aef85784bc4"}, + {file = "pygments-2.17.1.tar.gz", hash = "sha256:e45a0e74bf9c530f564ca81b8952343be986a29f6afe7f5ad95c5f06b7bdf5e8"}, ] [package.extras] plugins = ["importlib-metadata"] +windows-terminal = ["colorama (>=0.4.6)"] [[package]] name = "pytest" diff --git a/uplib/uplib/containers.py b/uplib/uplib/containers.py index b14c8a6..d39b6c2 100644 --- a/uplib/uplib/containers.py +++ b/uplib/uplib/containers.py @@ -23,6 +23,7 @@ class ContainerRun: volumes: dict[str, str] = field(kw_only=True, default_factory=dict) auto_remove: bool = field(kw_only=True, default=True) network_mode: str = field(kw_only=True, default="host") + user: str = field(kw_only=True, default="") # TODO: user working_dir: str = field(kw_only=True, default="/") # Feature Flags @@ -57,6 +58,7 @@ def run(self, run: ContainerRun): #TODO: Catch errors, print properly, pass all params #TODO: Locate bash properly #TODO: Consider if every command should be auto-wrapped in bash (perhaops detect if contains pipes or redirects) + command = run.command if (run.bash_wrap): command = ["sh", "-c", subprocess.list2cmdline(command)] @@ -64,7 +66,9 @@ def run(self, run: ContainerRun): name = run.name if run.name else generate_container_name(run) volumes = DockerContainers.volumes_of(run) ports = settings_maps.get("ports") - user = "up_user" + # TODO only pass user when sure (or defined by plugin) + # user = "up_user" + user = run.user working_dir = run.working_dir console = Console() console.log(f"Running container: {name}") diff --git a/uplib/uplib/main.py b/uplib/uplib/main.py index cb69409..669df9d 100644 --- a/uplib/uplib/main.py +++ b/uplib/uplib/main.py @@ -21,6 +21,7 @@ def up_main(context: Context, prompt: Prompt): if not container_runs: log.error("No containers found, using defaults") container_runs = [default_container(prompt)] + log.warning("==> DEBUG (%s) :\n %s", str(type(container_runs)), container_runs) for container_run in container_runs: containers.run(container_run) @@ -32,8 +33,9 @@ def default_container(prompt): def containers_for_prompt(prompt) -> list[ContainerRun]: - from_plugins = containers_from_plugins(prompt) - return from_plugins + lists = containers_from_plugins(prompt) + flat = [item for sublist in lists for item in sublist] + return flat def containers_from_plugins(prompt: list[str]) -> list[ContainerRun]: result = pm.hook.containers_for_prompt(prompt=prompt)