Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions podman/domain/images_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def build(self, **kwargs) -> tuple[Image, Iterator[bytes]]:
manifest (str) - add the image to the specified manifest list.
Creates manifest list if it does not exist.
secrets (list[str]) - Secret files/envs to expose to the build
ssh (list[str]) - SSH agent socket or keys to expose to the build.
Format is the same as ``podman build --ssh``, e.g.
``["default"]`` or ``["src=/path/to/key"]``.

Returns:
first item is the podman.domain.images.Image built
Expand Down Expand Up @@ -216,5 +219,8 @@ def _render_params(kwargs) -> dict[str, list[Any]]:
if "secrets" in kwargs:
params["secrets"] = json.dumps(kwargs.get("secrets"))

if "ssh" in kwargs and kwargs.get("ssh") != []:
params["ssh"] = json.dumps(kwargs["ssh"])

# Remove any unset parameters
return dict(filter(lambda i: i[1] is not None, params.items()))
7 changes: 5 additions & 2 deletions podman/tests/unit/test_build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import io
import requests
import json
import unittest

import requests

try:
# Python >= 3.10
from collections.abc import Iterable
Expand Down Expand Up @@ -71,7 +72,8 @@ def test_build(self, mock_prepare_containerfile, mock_create_tar):
"&extrahosts=%7B%22database%22%3A+%22127.0.0.1%22%7D"
"&labels=%7B%22Unittest%22%3A+%22true%22%7D"
"&manifest=example%3Av1.2.3"
"&secrets=%5B%22id%3Dexample%2Csrc%3Dpodman-build-secret123%22%5D",
"&secrets=%5B%22id%3Dexample%2Csrc%3Dpodman-build-secret123%22%5D"
"&ssh=%5B%22default%22%5D",
text=buffer.getvalue(),
)
mock.get(
Expand Down Expand Up @@ -105,6 +107,7 @@ def test_build(self, mock_prepare_containerfile, mock_create_tar):
labels={"Unittest": "true"},
manifest="example:v1.2.3",
secrets=["id=example,src=podman-build-secret123"],
ssh=["default"],
)
self.assertIsInstance(image, Image)
self.assertEqual(image.id, good_image_id)
Expand Down
Loading