Skip to content

Commit bc9168b

Browse files
Evedelmuayyad-alsadi
authored andcommitted
add no-normalize flag
Signed-off-by: Evedel <svbiriukov@gmail.com>
1 parent 57c527c commit bc9168b

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

podman_compose.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,8 @@ def _parse_compose_file(self):
16271627
compose.get("services", {}), set(args.profile)
16281628
)
16291629
compose["services"] = resolved_services
1630-
compose = normalize_final(compose, self.dirname)
1630+
if not args.no_normalize:
1631+
compose = normalize_final(compose, self.dirname)
16311632
self.merged_yaml = yaml.safe_dump(compose)
16321633
merged_json_b = json.dumps(compose, separators=(",", ":")).encode("utf-8")
16331634
self.yaml_hash = hashlib.sha256(merged_json_b).hexdigest()
@@ -3082,6 +3083,9 @@ def compose_build_parse(parser):
30823083

30833084
@cmd_parse(podman_compose, "config")
30843085
def compose_config_parse(parser):
3086+
parser.add_argument(
3087+
"--no-normalize", help="Don't normalize compose model.", action="store_true"
3088+
)
30853089
parser.add_argument(
30863090
"--services", help="Print the service names, one per line.", action="store_true"
30873091
)

pytests/test_can_merge_build.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ def test__parse_compose_file_when_multiple_composes() -> None:
138138
if actual_compose != expected_result:
139139
print("compose: ", test_input)
140140
print("override: ", test_override)
141-
print("result: ", expected_result)
141+
print("expected: ", expected_result)
142+
print("actual: ", actual_compose)
143+
142144
compose_expected = expected_result
143145

144146
assert compose_expected == actual_compose
@@ -151,6 +153,7 @@ def set_args(podman_compose: PodmanCompose, file_names: list[str]) -> None:
151153
podman_compose.global_args.env_file = None
152154
podman_compose.global_args.profile = []
153155
podman_compose.global_args.in_pod = True
156+
podman_compose.global_args.no_normalize = True
154157

155158

156159
def dump_yaml(compose: dict, name: str) -> None:

pytests/test_can_merge_cmd_ent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def set_args(podman_compose: PodmanCompose, file_names: list[str]) -> None:
107107
podman_compose.global_args.env_file = None
108108
podman_compose.global_args.profile = []
109109
podman_compose.global_args.in_pod = True
110+
podman_compose.global_args.no_normalize = None
110111

111112

112113
def dump_yaml(compose: dict, name: str) -> None:

pytests/test_normalize_final_build.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def test__parse_compose_file_when_single_compose() -> None:
146146
dump_yaml(compose_test, "test-compose.yaml")
147147

148148
podman_compose = PodmanCompose()
149-
set_args(podman_compose, ["test-compose.yaml"])
149+
set_args(podman_compose, ["test-compose.yaml"], no_normalize=None)
150150

151151
podman_compose._parse_compose_file()
152152

@@ -271,7 +271,11 @@ def test__parse_compose_file_when_multiple_composes() -> None:
271271
dump_yaml(compose_test_2, "test-compose-2.yaml")
272272

273273
podman_compose = PodmanCompose()
274-
set_args(podman_compose, ["test-compose-1.yaml", "test-compose-2.yaml"])
274+
set_args(
275+
podman_compose,
276+
["test-compose-1.yaml", "test-compose-2.yaml"],
277+
no_normalize=None,
278+
)
275279

276280
podman_compose._parse_compose_file()
277281

@@ -288,13 +292,16 @@ def test__parse_compose_file_when_multiple_composes() -> None:
288292
assert compose_expected == actual_compose
289293

290294

291-
def set_args(podman_compose: PodmanCompose, file_names: list[str]) -> None:
295+
def set_args(
296+
podman_compose: PodmanCompose, file_names: list[str], no_normalize: bool
297+
) -> None:
292298
podman_compose.global_args = argparse.Namespace()
293299
podman_compose.global_args.file = file_names
294300
podman_compose.global_args.project_name = None
295301
podman_compose.global_args.env_file = None
296302
podman_compose.global_args.profile = []
297303
podman_compose.global_args.in_pod = True
304+
podman_compose.global_args.no_normalize = no_normalize
298305

299306

300307
def dump_yaml(compose: dict, name: str) -> None:

0 commit comments

Comments
 (0)