Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quiet flag to podman-compose config #1152

Merged
merged 1 commit into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/1152-config-quiet.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add a `--quiet` flag to the `config` command to suppress output.
12 changes: 10 additions & 2 deletions podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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")
Expand Down
17 changes: 17 additions & 0 deletions tests/integration/profile/test_podman_compose_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,20 @@ def test_config_profiles(self, profiles, expected_services):
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"), "")