Skip to content

Commit

Permalink
fix "up ansible --version"
Browse files Browse the repository at this point in the history
  • Loading branch information
faermanj committed Nov 20, 2023
1 parent b1b4ad0 commit bae952a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
13 changes: 7 additions & 6 deletions uplib/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion uplib/uplib/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -57,14 +58,17 @@ 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)]
log.debug("$: %s", run)
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}")
Expand Down
6 changes: 4 additions & 2 deletions uplib/uplib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down

0 comments on commit bae952a

Please sign in to comment.