Merge pull request #1152 from IamTheFij/config-quiet

Add quiet flag to podman-compose config
This commit is contained in:
Povilas Kanapickas 2025-03-01 16:42:20 +02:00 committed by GitHub
commit 3353697402
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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,8 +3136,10 @@ async def compose_logs(compose, args):
async def compose_config(compose, args): async def compose_config(compose, args):
if args.services: if args.services:
for service in compose.services: for service in compose.services:
if not args.quiet:
print(service) print(service)
return return
if not args.quiet:
print(compose.merged_yaml) print(compose.merged_yaml)
@ -3672,6 +3674,12 @@ def compose_config_parse(parser):
parser.add_argument( parser.add_argument(
"--services", help="Print the service names, one per line.", action="store_true" "--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") @cmd_parse(podman_compose, "port")

View File

@ -80,3 +80,20 @@ class TestComposeConfig(unittest.TestCase, RunSubprocessMixin):
actual_services[service] = service in actual_output actual_services[service] = service in actual_output
self.assertEqual(expected_services, actual_services) 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"), "")