Skip to content

Commit 27e27e9

Browse files
authored
Merge pull request #918 from p12tic/fix-in-pod
Fix handling of --in-pod argument
2 parents 58641f0 + 70a0e2d commit 27e27e9

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

podman_compose.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def norm_ulimit(inner_value):
346346

347347

348348
def transform(args, project_name, given_containers):
349-
if not args.in_pod:
349+
if not args.in_pod_bool:
350350
pod_name = None
351351
pods = []
352352
else:
@@ -1911,6 +1911,13 @@ def _parse_args(self):
19111911
for cmd_parser in cmd._parse_args: # pylint: disable=protected-access
19121912
cmd_parser(subparser)
19131913
self.global_args = parser.parse_args()
1914+
if self.global_args.in_pod.lower() not in ('', 'true', '1', 'false', '0'):
1915+
raise ValueError(
1916+
f'Invalid --in-pod value: \'{self.global_args.in_pod}\'. '
1917+
'It must be set to either of: empty value, true, 1, false, 0'
1918+
)
1919+
self.global_args.in_pod_bool = self.global_args.in_pod.lower() in ('', 'true', '1')
1920+
19141921
if self.global_args.version:
19151922
self.global_args.command = "version"
19161923
if not self.global_args.command or self.global_args.command == "help":
@@ -1927,8 +1934,8 @@ def _init_global_parser(parser):
19271934
"--in-pod",
19281935
help="pod creation",
19291936
metavar="in_pod",
1930-
type=bool,
1931-
default=True,
1937+
type=str,
1938+
default="true",
19321939
)
19331940
parser.add_argument(
19341941
"--pod-args",

pytests/test_can_merge_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def set_args(podman_compose: PodmanCompose, file_names: list[str]) -> None:
127127
podman_compose.global_args.project_name = None
128128
podman_compose.global_args.env_file = None
129129
podman_compose.global_args.profile = []
130-
podman_compose.global_args.in_pod = True
130+
podman_compose.global_args.in_pod_bool = True
131131
podman_compose.global_args.no_normalize = True
132132

133133

pytests/test_can_merge_cmd_ent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def set_args(podman_compose: PodmanCompose, file_names: list[str]) -> None:
9999
podman_compose.global_args.project_name = None
100100
podman_compose.global_args.env_file = None
101101
podman_compose.global_args.profile = []
102-
podman_compose.global_args.in_pod = True
102+
podman_compose.global_args.in_pod_bool = True
103103
podman_compose.global_args.no_normalize = None
104104

105105

pytests/test_normalize_final_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def set_args(podman_compose: PodmanCompose, file_names: list[str], no_normalize:
254254
podman_compose.global_args.project_name = None
255255
podman_compose.global_args.env_file = None
256256
podman_compose.global_args.profile = []
257-
podman_compose.global_args.in_pod = True
257+
podman_compose.global_args.in_pod_bool = True
258258
podman_compose.global_args.no_normalize = no_normalize
259259

260260

0 commit comments

Comments
 (0)