Uh oh!
There was an error while loading. Please reload this page.
Support reading config from stdin - #1488
Conversation
There was a problem hiding this comment.
I think I'd find this bit of logic less confusing if it were moved into the function above. At that point, I think the functions' responsibilities are a bit better-separated, and they could also be renamed. Say:
defresolve_config_details(base_dir, filename):
iffilename=='-':
returnConfigDetails(yaml.safe_load(sys.stdin), os.getcwd(), None)
iffilenameisNone:
file_path=find_config_file(base_dir)
else:
file_path=os.path.join(base_dir, filename)
returnConfigDetails(load_yaml(file_path), os.path.dirname(file_path), file_path)
deffind_config_file(base_dir):
(candidates, path) =find_candidates_in_parent_dirs(SUPPORTED_FILENAMES, base_dir)
# ...There was a problem hiding this comment.
I had just copied the old get_config_path() from Command, but now that we have another place to move it, I think that makes sense.
aanm
commented
Jun 1, 2015
So it won't be possible to use a compose-file and stdin at the same time? This would be interesting when people want to overwrite stuff from compose-file without creating a new file. Such as: $cat my-compose.yml web:
ports: 1234:5000
$ docker-compose up -f my-compose.yml --stdin-extends '{web: {ports: 5000:5000}}'Which would result in running web with ports 5000:5000 instead of 1234. |
dnephin
commented
Jun 1, 2015
@aanm that's correct, the stdin would replace the file. I think this is pretty standard for unix utilities. If you need something from a file, it would be up to you to read the original file, and merge it into the final config you send to stdin. |
aanand
commented
Jun 1, 2015
@aanm What you describe is interesting (and partly covered by the @dnephin Come to think of it, what's the behaviour of |
dnephin
commented
Jun 1, 2015
True, I should add that with the small doc change I made about using |
aanm
commented
Jun 1, 2015
@aanand I thinking that could some some users problems when they want to scale count=0
whiletrue;let count=count+1
docker-compose up -f my-compose.yml --stdin-extends '{web: {ports: $count:5000}}'doMy point is too use environment variables has input for configuration in compose. I think that would solve some problems that users are getting. @dnephin Does docker itself has this feature that you are PR? |
aanand
commented
Jun 1, 2015
cb28737 to
4c0736eComparednephin
commented
Jun 14, 2015
Updated the docs, and cleaned up |
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
dnephin
commented
Jul 3, 2015
Rebased again! Should be ready |
aanand
commented
Jul 3, 2015
LGTM |
Support reading config from stdin
Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.66.1 to 0.67.2. - [Release notes](https://github.com/prometheus/common/releases) - [Changelog](https://github.com/prometheus/common/blob/main/CHANGELOG.md) - [Commits](prometheus/common@v0.66.1...v0.67.2) --- updated-dependencies: - dependency-name: github.com/prometheus/common dependency-version: 0.67.2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Related to #1377
By supporting configuration from stdin, it becomes a lot easier for users with complex templating requirements to use a separate tool for templating, and pass the final config into docker-compose directly.
I wanted to ensure that the
if filename == '-'check only happened in one place, so I had to refactor some ofcompose.cli.command.get_config_pathwas moved tocompose.configto support this.