-
-
Notifications
You must be signed in to change notification settings - Fork 522
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 the current Docker context #2810
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick first pass with some question,.
internal/core/docker_host.go
Outdated
return dockerHost, nil | ||
} | ||
|
||
return "", ErrDockerSocketNotSetInDockerContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Is this discarding useful information from the actual error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Wdyt about this order: return "", errors.Join(ErrDockerSocketNotSetInDockerContext, err)?
return "", ErrDockerSocketNotSetInDockerContext | |
return "", errors.Join(ErrDockerSocketNotSetInDockerContext, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would be confusing, I would detect a specific "not found" error from the call and only translate that if needed. If that's not needed I would just return a wrapped straight wrapped error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wdyt a38a345 ?
No need to have podman-specific code, as it will be read from the docker context
Different container runtimes could produce "Step" or "STEP"
docker_test.go
Outdated
@@ -1701,7 +1639,7 @@ func TestContainerWithNoUserID(t *testing.T) { | |||
func TestGetGatewayIP(t *testing.T) { | |||
// When using docker compose with DinD mode, and using host port or http wait strategy | |||
// It's need to invoke GetGatewayIP for get the host | |||
provider, err := providerType.GetProvider(WithLogger(TestLogger(t))) | |||
provider, err := ProviderDocker.GetProvider(WithLogger(TestLogger(t))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: is the intent to just have one, if so should we rename, also could we avoid exporting this to avoid future breaking changes when we do the client update discussed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to rename here in this PR, but if we see it's related, I can deprecate the existing DockerProvider
type and use RuntimeProvider
instead.
internal/core/docker_context.go
Outdated
var result []string | ||
for _, fi := range fis { | ||
if fi.IsDir() { | ||
if isContextDir(filepath.Join(root, fi.Name())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Is this a duplicate check as if we start with root and fi is a directory it should not be possible that this could ever fail?
@@ -0,0 +1,328 @@ | |||
package core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: can we check this is all required, as it looks like some types don't seem to be referenced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only exposed function in this file is GetDockerHostFromCurrentContext
, which starts the call to the types and functions here.
* main: docs: better contribution guidelines (testcontainers#2893) fix(influxdb): Respect custom waitStrategy (testcontainers#2845)
* main: fix: container binds syntax (testcontainers#2899) refactor(cockroachdb): to use request driven options (testcontainers#2883) chore(deps): bump actions/setup-go from 5.0.0 to 5.1.0 (testcontainers#2904) chore(deps): bump ossf/scorecard-action from 2.3.1 to 2.4.0 (testcontainers#2903) chore(deps): bump test-summary/action from 2.3 to 2.4 (testcontainers#2902) feat(wait): strategy walk (testcontainers#2895) feat(wait): tls strategy (testcontainers#2896)
* main: (54 commits) deps: update go version from 1.22.0 to 1.23.0 (testcontainers#2985) feat(redpanda): add bootstrap user account option (testcontainers#2975) chore(ollama): bump default version to 0.5.7 (testcontainers#2966) feat!: log package for consistent output (testcontainers#2979) docs: remove duplicated options in the customisers lists (testcontainers#2989) chore: exclude "modules/k6" from the build (testcontainers#2987) chore: enable var-naming from revive (private vars only) (testcontainers#2978) chore(deps): bump actions/checkout from 4.1.7 to 4.2.2 (testcontainers#2971) chore(deps): bump release-drafter/release-drafter from 6.0.0 to 6.1.0 (testcontainers#2970) chore!: remove variadic arguments from nats ConnectionString (testcontainers#2967) fix(ci): use same condition for sonar steps (testcontainers#2974) fix: return unique modified modules (testcontainers#2973) chore(deps): bump golangci/golangci-lint-action from 6.2.0 to 6.3.0 (testcontainers#2969) chore(ci): run lint in a separate build before running the tests (testcontainers#2876) fix(deps): update to github.com/shirou/gopsutil/v4 (testcontainers#2964) fix(valkey): fix port race (testcontainers#2962) chore(deps): bump golang.org/x/net in /modules/pinecone (testcontainers#2963) chore(deps): bump golang.org/x/net from 0.26.0 to 0.33.0 (testcontainers#2961) deps(fix): include modulegen templates dir in dependabot updates (testcontainers#2956) chore(deps): bump docker/setup-docker-action from 4.0.0 to 4.1.0 (testcontainers#2959) ...
What does this PR do?
This PR adds a new step in the Docekr host discovery algorithm, extracting the Docker host from the current Docker context. To achieve that, we are copying code from the docker/cli project,
as we don't want to receive all the dependencies from that project (please see
docker_context.go
file). In the end, it just does the following:NOTE: The default docker config path lives in
$HOME/.docker
.This PR also reduces the complexity in discovering the default bridge network, so instead of having to detect if a network named Bridge exists, it simply delegates to the container runtime to detect it under the hood.
Why is it important?
It will simplify the experience using different container runtimes, as this change means that with just setting the current context, testcontainers-go will use that container runtime.