Skip to content

Commit

Permalink
Add command which was run to the markdown piece
Browse files Browse the repository at this point in the history
  • Loading branch information
mathbunnyru committed Nov 5, 2023
1 parent 2401290 commit 641e13e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 5 additions & 3 deletions tagging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,14 @@ from tagging.manifests import ManifestInterface, quoted_output
class AptPackagesManifest(ManifestInterface):
@staticmethod
def markdown_piece(container) -> str:
return "\n".join(
["## Apt Packages", "", quoted_output(container, "apt list --installed")]
)
return f"""\
## Apt Packages
{quoted_output(container, "apt list --installed")}"""
```

- `quoted_output` simply runs the command inside a container using `DockerRunner.run_simple_command` and wraps it to triple quotes to create a valid markdown piece.
It also adds the command which was run to the markdown piece.
- `manifests.py` contains all the manifests.
- `write_manifest.py` is a python executable which is used to create the build manifest and history line for an image.

Expand Down
8 changes: 2 additions & 6 deletions tagging/manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def quoted_output(container: Container, cmd: str) -> str:
# For example, R packages list contains trailing backspaces
cmd_output = "\n".join(line.rstrip() for line in cmd_output.split("\n"))
return f"""\
`{cmd}`:
```text
{cmd_output}
```"""
Expand Down Expand Up @@ -74,12 +76,8 @@ def markdown_piece(container: Container) -> str:
{DockerRunner.run_simple_command(container, "python --version")}
`mamba info --quiet`:
{quoted_output(container, "mamba info --quiet")}
`mamba list`:
{quoted_output(container, "mamba list")}"""


Expand All @@ -89,8 +87,6 @@ def markdown_piece(container: Container) -> str:
return f"""\
## Apt Packages
`apt list --installed`:
{quoted_output(container, "apt list --installed")}"""


Expand Down

0 comments on commit 641e13e

Please sign in to comment.