...
 
Commits (5)
    https://gitcode.net/awesome-mirrors/containers/podman-compose/-/commit/1ffd24dcf92e4867671156a8d6bab42b0669618b Python version support: sync verified and advertised versions 2023-05-06T00:28:13+03:00 Cleber Rosa crosa@redhat.com There are differences with regards to the versions of Python that are verified (somehow) through Pylint, and the ones that are advertised. Given that there's no pinning of Pylint versions, it shouldn't be possible to use it on Python versions such as 3.5 and 3.6 (latest Pylint doesn't support those). With that, let's cover all the currently supported Python versions. Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:crosa@redhat.com" title="crosa@redhat.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg6" style="text-decoration: none">N</a><a href="mailto:crosa@redhat.com" title="crosa@redhat.com">Cleber Rosa</a> &lt;<a href="mailto:crosa@redhat.com" title="crosa@redhat.com">crosa@redhat.com</a>&gt;</span> https://gitcode.net/awesome-mirrors/containers/podman-compose/-/commit/517aeba330002d7816d6973026b110368b051612 Allow config to merge strings and lists in command and entrypoint 2023-05-06T10:42:44+03:00 Sergei Biriukov svbiriukov@gmail.com Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:svbiriukov@gmail.com" title="svbiriukov@gmail.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:svbiriukov@gmail.com" title="svbiriukov@gmail.com">Sergei Biriukov</a> &lt;<a href="mailto:svbiriukov@gmail.com" title="svbiriukov@gmail.com">svbiriukov@gmail.com</a>&gt;</span> https://gitcode.net/awesome-mirrors/containers/podman-compose/-/commit/9011e9faa1d8718459c2c90d0f677998c7e09a3b add tests, dry up code, use shlex.split instead of str.split 2023-05-06T10:42:44+03:00 Sergei Biriukov svbiriukov@gmail.com Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:svbiriukov@gmail.com" title="svbiriukov@gmail.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg1" style="text-decoration: none">N</a><a href="mailto:svbiriukov@gmail.com" title="svbiriukov@gmail.com">Sergei Biriukov</a> &lt;<a href="mailto:svbiriukov@gmail.com" title="svbiriukov@gmail.com">svbiriukov@gmail.com</a>&gt;</span> https://gitcode.net/awesome-mirrors/containers/podman-compose/-/commit/d1509468c3ba21f8ee4c39c6f84387e5a43dc750 allow empty list to be a command/entrypoint 2023-05-06T10:42:44+03:00 Sergei Biriukov svbiriukov@gmail.com Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:svbiriukov@gmail.com" title="svbiriukov@gmail.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:svbiriukov@gmail.com" title="svbiriukov@gmail.com">Sergei Biriukov</a> &lt;<a href="mailto:svbiriukov@gmail.com" title="svbiriukov@gmail.com">svbiriukov@gmail.com</a>&gt;</span> https://gitcode.net/awesome-mirrors/containers/podman-compose/-/commit/79bfad103c27ab2f7af26b7016ff7265806e777e move logic from rec_merge to normalize_service 2023-05-06T10:42:44+03:00 Sergei Biriukov svbiriukov@gmail.com Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:svbiriukov@gmail.com" title="svbiriukov@gmail.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg1" style="text-decoration: none">N</a><a href="mailto:svbiriukov@gmail.com" title="svbiriukov@gmail.com">Sergei Biriukov</a> &lt;<a href="mailto:svbiriukov@gmail.com" title="svbiriukov@gmail.com">svbiriukov@gmail.com</a>&gt;</span>
......@@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
......
......@@ -1255,6 +1255,10 @@ def normalize_service(service, sub_dir=""):
service["build"] = context
else:
service["build"]["context"] = context
for key in ("command", "entrypoint"):
if key in service:
if is_str(service[key]):
service[key] = shlex.split(service[key])
for key in ("env_file", "security_opt", "volumes"):
if key not in service:
continue
......@@ -1307,14 +1311,14 @@ def rec_merge_one(target, source):
if key not in source:
continue
value2 = source[key]
if key == "command":
if key in ("command", "entrypoint"):
target[key] = clone(value2)
continue
if not isinstance(value2, type(value)):
value_type = type(value)
value2_type = type(value2)
raise ValueError(
f"can't merge value of {key} of type {value_type} and {value2_type}"
f"can't merge value of [{key}] of type {value_type} and {value2_type}"
)
if is_list(value2):
if key == "volumes":
......
import copy
import os
import argparse
import yaml
from podman_compose import normalize_service, PodmanCompose
test_keys = ["command", "entrypoint"]
test_cases_normalise_pre_merge = [
({"$$$": []}, {"$$$": []}),
({"$$$": ["sh"]}, {"$$$": ["sh"]}),
({"$$$": ["sh", "-c", "date"]}, {"$$$": ["sh", "-c", "date"]}),
({"$$$": "sh"}, {"$$$": ["sh"]}),
({"$$$": "sleep infinity"}, {"$$$": ["sleep", "infinity"]}),
(
{"$$$": "bash -c 'sleep infinity'"},
{"$$$": ["bash", "-c", "sleep infinity"]},
),
]
test_cases_merges = [
({}, {"$$$": []}, {"$$$": []}),
({"$$$": []}, {}, {"$$$": []}),
({"$$$": []}, {"$$$": "sh-2"}, {"$$$": ["sh-2"]}),
({"$$$": "sh-2"}, {"$$$": []}, {"$$$": []}),
({}, {"$$$": "sh"}, {"$$$": ["sh"]}),
({"$$$": "sh"}, {}, {"$$$": ["sh"]}),
({"$$$": "sh-1"}, {"$$$": "sh-2"}, {"$$$": ["sh-2"]}),
({"$$$": ["sh-1"]}, {"$$$": "sh-2"}, {"$$$": ["sh-2"]}),
({"$$$": "sh-1"}, {"$$$": ["sh-2"]}, {"$$$": ["sh-2"]}),
({"$$$": "sh-1"}, {"$$$": ["sh-2", "sh-3"]}, {"$$$": ["sh-2", "sh-3"]}),
({"$$$": ["sh-1"]}, {"$$$": ["sh-2", "sh-3"]}, {"$$$": ["sh-2", "sh-3"]}),
({"$$$": ["sh-1", "sh-2"]}, {"$$$": ["sh-3", "sh-4"]}, {"$$$": ["sh-3", "sh-4"]}),
({}, {"$$$": ["sh-3", "sh 4"]}, {"$$$": ["sh-3", "sh 4"]}),
({"$$$": "sleep infinity"}, {"$$$": "sh"}, {"$$$": ["sh"]}),
({"$$$": "sh"}, {"$$$": "sleep infinity"}, {"$$$": ["sleep", "infinity"]}),
(
{},
{"$$$": "bash -c 'sleep infinity'"},
{"$$$": ["bash", "-c", "sleep infinity"]},
),
]
def template_to_expression(base, override, expected, key):
base_copy = copy.deepcopy(base)
override_copy = copy.deepcopy(override)
expected_copy = copy.deepcopy(expected)
expected_copy[key] = expected_copy.pop("$$$")
if "$$$" in base:
base_copy[key] = base_copy.pop("$$$")
if "$$$" in override:
override_copy[key] = override_copy.pop("$$$")
return base_copy, override_copy, expected_copy
def test_normalize_service():
for test_input_template, expected_template in test_cases_normalise_pre_merge:
for key in test_keys:
test_input, _, expected = template_to_expression(
test_input_template, {}, expected_template, key
)
test_input = normalize_service(test_input)
test_result = expected == test_input
if not test_result:
print("base_template: ", test_input_template)
print("expected: ", expected)
print("actual: ", test_input)
assert test_result
def test__parse_compose_file_when_multiple_composes() -> None:
for base_template, override_template, expected_template in copy.deepcopy(
test_cases_merges
):
for key in test_keys:
base, override, expected = template_to_expression(
base_template, override_template, expected_template, key
)
compose_test_1 = {"services": {"test-service": base}}
compose_test_2 = {"services": {"test-service": override}}
dump_yaml(compose_test_1, "test-compose-1.yaml")
dump_yaml(compose_test_2, "test-compose-2.yaml")
podman_compose = PodmanCompose()
set_args(podman_compose, ["test-compose-1.yaml", "test-compose-2.yaml"])
podman_compose._parse_compose_file() # pylint: disable=protected-access
actual = {}
if podman_compose.services:
podman_compose.services["test-service"].pop("_deps")
actual = podman_compose.services["test-service"]
if actual != expected:
print("compose: ", base)
print("override: ", override)
print("result: ", expected)
assert expected == actual
def set_args(podman_compose: PodmanCompose, file_names: list[str]) -> None:
podman_compose.global_args = argparse.Namespace()
podman_compose.global_args.file = file_names
podman_compose.global_args.project_name = None
podman_compose.global_args.env_file = None
podman_compose.global_args.profile = []
podman_compose.global_args.in_pod = True
def dump_yaml(compose: dict, name: str) -> None:
with open(name, "w", encoding="utf-8") as outfile:
yaml.safe_dump(compose, outfile, default_flow_style=False)
def test_clean_test_yamls() -> None:
test_files = ["test-compose-1.yaml", "test-compose-2.yaml"]
for file in test_files:
if os.path.exists(file):
os.remove(file)
......@@ -16,12 +16,11 @@ setup(
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Development Status :: 3 - Alpha",
......