-
Notifications
You must be signed in to change notification settings - Fork 9
refactor: Update Docker container configuration for Cassandra in tests #118
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import ( | |
| "github.com/jackc/pgx/v5" | ||
| "github.com/jackc/pgx/v5/stdlib" | ||
| "github.com/ory/dockertest/v3" | ||
| dc "github.com/ory/dockertest/v3/docker" | ||
| mysqlquery "github.com/percona/go-mysql/query" | ||
| ) | ||
|
|
||
|
|
@@ -100,7 +101,9 @@ func runPostgresDB(version string, certData *Cert) (string /*DB Connection Strin | |
| // | ||
| // fmt.Printf("\n\ncontainer logs: %v\n\n", string(bytes)) | ||
|
|
||
| pool.Purge(resource) | ||
| if resource != nil { | ||
| pool.Purge(resource) | ||
| } | ||
| } | ||
| // if function panics anywhere in further steps, | ||
| // cleanup resources. | ||
|
|
@@ -155,14 +158,20 @@ func runDockerContainer(repo string, tag string, mountOptions []string, envOptio | |
| } | ||
|
|
||
| o := &dockertest.RunOptions{ | ||
| Repository: repo, | ||
| Tag: tag, | ||
| Mounts: mountOptions, | ||
| Env: envOptions, | ||
| Cmd: cmdOptions, | ||
| Entrypoint: entrypointOverrides, | ||
| } | ||
| resource, err := pool.RunWithOptions(o) | ||
| Repository: repo, | ||
| Tag: tag, | ||
| Mounts: mountOptions, | ||
| Env: envOptions, | ||
| Cmd: cmdOptions, | ||
| Entrypoint: entrypointOverrides, | ||
| ExposedPorts: []string{postgresPort + "/tcp"}, | ||
| PortBindings: map[dc.Port][]dc.PortBinding{ | ||
| dc.Port(postgresPort + "/tcp"): {{HostIP: "", HostPort: ""}}, | ||
| }, | ||
|
Comment on lines
+167
to
+170
|
||
| } | ||
| resource, err := pool.RunWithOptions(o, func(hc *dc.HostConfig) { | ||
| hc.PublishAllPorts = false | ||
| }) | ||
|
|
||
| return resource, pool, 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.
Empty HostIP and HostPort values in PortBinding may lead to unexpected behavior. Consider documenting the intended behavior when these are empty strings, or explicitly set them to meaningful defaults if automatic assignment is not the desired outcome.