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

feat: support reading DOCKER_HOST from testcontainers props file #373

Merged
merged 12 commits into from Nov 6, 2021

Conversation

mdelapenya
Copy link
Collaborator

What does this PR do?

It adds support for retrieving the Docker host (remote or local) reading the DOCKER_HOST value from Testcontainers' default properties file (which is used at testcontainers-java for quite some time).

That file is located at ~/.testcontainers.properties).

The PR includes unit tests for the new methods reading the props file.

Why is it important?

There are two main reasons:

  1. consistency across Testcontainers flavours
  2. support running the containers ina remote Docker Host

Follow-up concerns

I've not tested this feature with Docker Compose yet (hopefully I can get some feedback from you all first)

@mdelapenya mdelapenya added the feature New functionality or new behaviors on the existing one label Oct 31, 2021
@mdelapenya mdelapenya self-assigned this Oct 31, 2021
docker.go Outdated
return ""
}
tcProp := path.Join(home, ".testcontainers.properties")
content, err := os.ReadFile(tcProp)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We should use a backwards compatible way of reading files OR properly define a support matrix

docker.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Nov 2, 2021

Codecov Report

Merging #373 (59a295c) into master (1b9fe0b) will decrease coverage by 0.75%.
The diff coverage is 53.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #373      +/-   ##
==========================================
- Coverage   62.66%   61.90%   -0.76%     
==========================================
  Files          15       15              
  Lines        1015     1042      +27     
==========================================
+ Hits          636      645       +9     
- Misses        280      294      +14     
- Partials       99      103       +4     
Impacted Files Coverage Δ
docker.go 64.50% <53.33%> (-1.75%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1b9fe0b...59a295c. Read the comment docs.

docker.go Show resolved Hide resolved
@mdelapenya mdelapenya marked this pull request as draft November 4, 2021 17:48
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.

Looks great from the perspective of aligning more closely with testcontainers-java, thanks 👍

@mdelapenya mdelapenya marked this pull request as ready for review November 5, 2021 10:51
Copy link
Member

@bsideup bsideup left a comment

Choose a reason for hiding this comment

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

👍

docker.go Outdated Show resolved Hide resolved
@mdelapenya
Copy link
Collaborator Author

To fix the code coverage warnings in this PR, I think we should add a remote docker daemon, configure it with TLS, and create a DockerProvider struct with a TC properties pointing to that remote. Do you think we can live without that test?

@bsideup
Copy link
Member

bsideup commented Nov 5, 2021

@mdelapenya given the complexity of such test that would delay this PR by a significant amount of time, I suggest we stick to the manual testing of it. That's what we also do in testcontainers-java :)

docker.go Show resolved Hide resolved
@mdelapenya
Copy link
Collaborator Author

@gianarb if you agree, I'd like to merge this one by the end of today. Otherwise feel free to add your thoughts

Thanks!

@mdelapenya mdelapenya merged commit cad4370 into testcontainers:master Nov 6, 2021
@mdelapenya mdelapenya deleted the docker-host-support branch November 8, 2021 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or new behaviors on the existing one
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants