Add quiet flag to podman-compose config

This skips printing and is useful for validating config files.

Signed-off-by: Ian Fijolek <ian@iamthefij.com>
This commit is contained in:
Ian Fijolek 2025-02-27 12:11:10 -08:00
parent 976847ef9b
commit 4cd1642be0
3 changed files with 28 additions and 2 deletions

View File

@ -0,0 +1 @@
- Add a `--quiet` flag to the `config` command to suppress output.

View File

@ -3136,9 +3136,11 @@ async def compose_logs(compose, args):
async def compose_config(compose, args):
if args.services:
for service in compose.services:
print(service)
if not args.quiet:
print(service)
return
print(compose.merged_yaml)
if not args.quiet:
print(compose.merged_yaml)
@cmd_run(podman_compose, "port", "Prints the public port for a port binding.")
@ -3672,6 +3674,12 @@ def compose_config_parse(parser):
parser.add_argument(
"--services", help="Print the service names, one per line.", action="store_true"
)
parser.add_argument(
"-q",
"--quiet",
help="Do not print config, only parse.",
action="store_true",
)
@cmd_parse(podman_compose, "port")

View File

@ -80,3 +80,20 @@ class TestComposeConfig(unittest.TestCase, RunSubprocessMixin):
actual_services[service] = service in actual_output
self.assertEqual(expected_services, actual_services)
def test_config_quiet(self):
"""
Tests podman-compose config command with the --quiet flag.
"""
config_cmd = [
"coverage",
"run",
podman_compose_path(),
"-f",
profile_compose_file(),
"config",
"--quiet",
]
out, _ = self.run_subprocess_assert_returncode(config_cmd)
self.assertEqual(out.decode("utf-8"), "")