mirror of
https://github.com/containers/podman-compose.git
synced 2025-04-24 17:39:01 +02:00
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:
parent
976847ef9b
commit
4cd1642be0
1
newsfragments/1152-config-quiet.feature
Normal file
1
newsfragments/1152-config-quiet.feature
Normal file
@ -0,0 +1 @@
|
|||||||
|
- Add a `--quiet` flag to the `config` command to suppress output.
|
@ -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")
|
||||||
|
@ -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"), "")
|
||||||
|
Loading…
Reference in New Issue
Block a user