mirror of
https://github.com/containers/podman-compose.git
synced 2025-04-25 18:09:02 +02:00
Merge pull request #966 from ArthoPacini/enhance/stdin-docker-compose-support
Add ability to input docker-compose.yaml via stdin
This commit is contained in:
commit
650a835eca
@ -1762,7 +1762,7 @@ class PodmanCompose:
|
|||||||
"pass files with -f"
|
"pass files with -f"
|
||||||
)
|
)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
ex = map(os.path.exists, files)
|
ex = map(lambda x: x == '-' or os.path.exists(x), files)
|
||||||
missing = [fn0 for ex0, fn0 in zip(ex, files) if not ex0]
|
missing = [fn0 for ex0, fn0 in zip(ex, files) if not ex0]
|
||||||
if missing:
|
if missing:
|
||||||
log.fatal("missing files: %s", missing)
|
log.fatal("missing files: %s", missing)
|
||||||
@ -1811,6 +1811,9 @@ class PodmanCompose:
|
|||||||
except StopIteration:
|
except StopIteration:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if filename.strip().split('/')[-1] == '-':
|
||||||
|
content = yaml.safe_load(sys.stdin)
|
||||||
|
else:
|
||||||
with open(filename, "r", encoding="utf-8") as f:
|
with open(filename, "r", encoding="utf-8") as f:
|
||||||
content = yaml.safe_load(f)
|
content = yaml.safe_load(f)
|
||||||
# log(filename, json.dumps(content, indent = 2))
|
# log(filename, json.dumps(content, indent = 2))
|
||||||
@ -2048,7 +2051,7 @@ class PodmanCompose:
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-f",
|
"-f",
|
||||||
"--file",
|
"--file",
|
||||||
help="Specify an alternate compose file (default: docker-compose.yml)",
|
help="Specify an compose file (default: docker-compose.yml) or '-' to read from stdin.",
|
||||||
metavar="file",
|
metavar="file",
|
||||||
action="append",
|
action="append",
|
||||||
default=[],
|
default=[],
|
||||||
|
Loading…
Reference in New Issue
Block a user