feat(compose): read stdin content from -f - - #61
Merged
Conversation
-f -
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this solve?
cat docker-compose.yml | mocker compose config -f -fails withError: no configuration file provided: not found: -and exit 1. Docker compose accepts stdin via-f -as documented in its CLI reference, so any user migrating a shell script or a CI/CD pipe hits a Docker-parity gap on their first invocation against mocker.The same trap exists for heredocs (
mocker compose -f - config <<'EOF' ... EOF), for piping templated output (gomplate ... | mocker compose -f - up), and for mixing a file with an override supplied via stdin (-f base.yml -f -to merge). Today every one of these paths lands on the samenot found: -error becauseloadCompose()callsComposeFile.load(from: "-", ...)which has no stdin-reading branch.What changed
ComposeFile.load(content:projectDir:)overload that takes an in-memory YAML string. The.envdiscovery and variable substitution pipeline are factored into a privateparseAndSubstitute(content:projectDir:)helper that the existingload(from:projectDir:)now delegates to (no behavior change to file loading).loadCompose(): when an entry in-fis"-", read withFileHandle.standardInput.readToEnd()(mirroringLogin.swift:30's established pattern) and route the bytes through the new overload. Absolute paths and the default-file path pass through unchanged.MockerError.composeParseError("compose file content is empty")— the existing case, not a new enum variant. Empty stdin and empty file are the same failure mode (input that cannot be parsed), so both paths share the error category; the detail message tells the user which one fired.-f - -f -in the same invocation) is undefined: the second read returns empty bytes and triggers the empty-stdin error. Use each-f -once per invocation, which is what the upstream compose reference documents.