-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
333 additions
and
176 deletions.
There are no files selected for viewing
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from up_cli import pm | ||
from up_ansible import image_for_prompt | ||
|
||
pm.register(image_for_prompt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from up_cli import hookimpl, match_prompt | ||
|
||
@hookimpl | ||
def image_for_prompt(prompt): | ||
return match_prompt(prompt, "ansible", "cytopia/ansible") |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
import pluggy | ||
from .containers import Containers | ||
|
||
hookimpl = pluggy.HookimplMarker("up") | ||
pm = pluggy.PluginManager("up") | ||
pm = pluggy.PluginManager("up") | ||
containers = Containers() | ||
|
||
def match_prompt(prompt, head, image): | ||
if not prompt: | ||
return None | ||
if prompt[0] == head: | ||
return image | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import logging as log | ||
from dataclasses import dataclass | ||
import docker | ||
|
||
@dataclass | ||
class ContainerRun: | ||
"""Specify the parameters for a container run""" | ||
image: str | ||
prompt: list[str] | ||
|
||
|
||
class DockerContainers: | ||
def run(self, run: ContainerRun): | ||
log.debug("Running container: %s", run) | ||
client = docker.from_env() | ||
image = run.image | ||
prompt = run.prompt | ||
#TODO: Catch errors, print properly | ||
result = client.containers.run( | ||
image=image, | ||
command=prompt, | ||
auto_remove=True) | ||
log.info("container result") | ||
log.info("%s", result) | ||
log.debug("Container run done") | ||
|
||
class Containers: | ||
delegate = DockerContainers() | ||
|
||
def run(self, run: ContainerRun): | ||
self.delegate.run(run) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
from up_cli import hookimpl | ||
|
||
@hookimpl | ||
|
||
def image_for_prompt(prompt): | ||
print("inside Plugin_1.myhook()") | ||
return "-".join(prompt) | ||
return "fedora:37" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
from up_cli import pm | ||
|
||
from up_splat import image_for_prompt | ||
|
||
print("-- Registering plugin 2 --") | ||
pm.register(image_for_prompt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
from up_cli import hookimpl | ||
from up_cli import hookimpl, match_prompt | ||
|
||
@hookimpl | ||
def image_for_prompt(prompt): | ||
print("inside Plugin_2.myhook()") | ||
return "*".join(prompt) | ||
return match_prompt(prompt, "splat", "fedora:38") |