diff --git a/podman_compose.py b/podman_compose.py index 581ca0b..399ccf4 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -346,7 +346,7 @@ def norm_ulimit(inner_value): def transform(args, project_name, given_containers): - if not args.in_pod: + if not args.in_pod_bool: pod_name = None pods = [] else: @@ -1911,6 +1911,13 @@ class PodmanCompose: for cmd_parser in cmd._parse_args: # pylint: disable=protected-access cmd_parser(subparser) self.global_args = parser.parse_args() + if self.global_args.in_pod.lower() not in ('', 'true', '1', 'false', '0'): + raise ValueError( + f'Invalid --in-pod value: \'{self.global_args.in_pod}\'. ' + 'It must be set to either of: empty value, true, 1, false, 0' + ) + self.global_args.in_pod_bool = self.global_args.in_pod.lower() in ('', 'true', '1') + if self.global_args.version: self.global_args.command = "version" if not self.global_args.command or self.global_args.command == "help": @@ -1927,8 +1934,8 @@ class PodmanCompose: "--in-pod", help="pod creation", metavar="in_pod", - type=bool, - default=True, + type=str, + default="true", ) parser.add_argument( "--pod-args", diff --git a/pytests/test_can_merge_build.py b/pytests/test_can_merge_build.py index 3b09482..b89c53e 100644 --- a/pytests/test_can_merge_build.py +++ b/pytests/test_can_merge_build.py @@ -127,7 +127,7 @@ def set_args(podman_compose: PodmanCompose, file_names: list[str]) -> None: 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 + podman_compose.global_args.in_pod_bool = True podman_compose.global_args.no_normalize = True diff --git a/pytests/test_can_merge_cmd_ent.py b/pytests/test_can_merge_cmd_ent.py index 6f50b9e..2fc7aa5 100644 --- a/pytests/test_can_merge_cmd_ent.py +++ b/pytests/test_can_merge_cmd_ent.py @@ -99,7 +99,7 @@ def set_args(podman_compose: PodmanCompose, file_names: list[str]) -> None: 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 + podman_compose.global_args.in_pod_bool = True podman_compose.global_args.no_normalize = None diff --git a/pytests/test_normalize_final_build.py b/pytests/test_normalize_final_build.py index 508c8ec..6356d3e 100644 --- a/pytests/test_normalize_final_build.py +++ b/pytests/test_normalize_final_build.py @@ -254,7 +254,7 @@ def set_args(podman_compose: PodmanCompose, file_names: list[str], no_normalize: 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 + podman_compose.global_args.in_pod_bool = True podman_compose.global_args.no_normalize = no_normalize