feat(connection): support TLS docker hosts via DOCKER_CERT_PATH#258
Merged
Conversation
Extend DockerUrl.construct/1 to handle https:// URLs and to promote tcp:// URLs to https:// when DOCKER_TLS_VERIFY is truthy, mirroring the Docker CLI. When the resolved URL is https, the Tesla/hackney adapter is configured with :ssl_options loaded from DOCKER_CERT_PATH (falling back to ~/.docker). Missing cert files are skipped with a debug log; verify mode follows DOCKER_TLS_VERIFY. Fixes #202
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.
Summary
Testcontainers.DockerUrl.construct/1to recognizehttps://URLs (pass-through) and to promotetcp://URLs tohttps://whenDOCKER_TLS_VERIFYis truthy (1/true), mirroring Docker CLI behavior.Testcontainers.Connection.get_connection/1now configures the hackney adapter with:ssl_optionsbuilt fromDOCKER_CERT_PATH(falling back to~/.docker):ca.pem,cert.pem, andkey.pemare loaded when present; missing files are skipped with a debug log. Verify mode is:verify_peerwhenDOCKER_TLS_VERIFYis set, otherwise:verify_nonewith a warning log.unix://,http://, and non-TLStcp://flows are unchanged.Fixes #202
Test plan
mix compile— cleanmix credo --strict— no issuesmix dialyzer— no warningstest/connection/docker_url_test.exscovers URL construction across schemes andDOCKER_TLS_VERIFYvaluestest/connection/tls_test.exscovers SSL-option assembly with a fixture cert dir and with missing filesmix test— 211 tests, 0 failures