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

Fail fast if container_name is set in Docker Compose file #1581

Merged
merged 4 commits into from
Jul 19, 2019

Conversation

bsideup
Copy link
Member

@bsideup bsideup commented Jul 1, 2019

Fixes #1151. Submitting a new one since #1432 was closed by the author.

@bsideup bsideup added this to the next milestone Jul 1, 2019
@bsideup bsideup requested a review from a team July 1, 2019 09:45
@rnorth rnorth modified the milestone: next Jul 7, 2019
Copy link
Member

@rnorth rnorth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only have trivial comments, so feel free to respond/dismiss as you see fit, and merge after that.

Copy link
Member

@rnorth rnorth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only have trivial comments, so feel free to respond/dismiss as you see fit, and merge after that.

Copy link
Member

@kiview kiview left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions up for discussion.


@VisibleForTesting
static void validate(Object template, String identifier) {
if (!(template instanceof Map)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could extract 240-261 into a private function and then have

if (!hasKnownFormat(object)) {
  log.debug("Compose file {} has an unknown format", identifier);
  return
}
...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracted methods make it much harder to follow the structure IMO, especially when dealing with the format/structure validation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, since it makes the responsibility of the part of the code clearer (therefore also increasing maintainability).
But we don't need to fight over this 😉

servicesMap = map;
}

for (Map.Entry<String, ?> entry : servicesMap.entrySet()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (Map.Entry<String, ?> entry : servicesMap.entrySet()) {
  validateEntry(entry)
}

Just an idea?
We can't break in this case of course.

@bsideup bsideup merged commit 4373d1f into master Jul 19, 2019
@delete-merged-branch delete-merged-branch bot deleted the docker-compose_fail_fast_on_container_name branch July 19, 2019 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docker-compose entry container_name not supported
3 participants