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: Use exposed ports specified in image if it is not specified in ContainerRequest #468

Merged
merged 8 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func TestContainerWithHostNetworkOptions_UseExposePortsFromImageConfigs(t *testi
Image: "nginx",
Privileged: true,
SkipReaper: true,
WaitingFor: wait.ForListeningPort(""),
WaitingFor: wait.ForExposedPort(),
},
Started: true,
}
Expand Down
8 changes: 8 additions & 0 deletions wait/host_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
var _ Strategy = (*HostPortStrategy)(nil)

type HostPortStrategy struct {
// Port is a string containing port number and protocol in the format "80/tcp"
fiftin marked this conversation as resolved.
Show resolved Hide resolved
// which
Port nat.Port
// all WaitStrategies should have a startupTimeout to avoid waiting infinitely
startupTimeout time.Duration
Expand All @@ -39,6 +41,12 @@ func ForListeningPort(port nat.Port) *HostPortStrategy {
return NewHostPortStrategy(port)
}

// ForExposedPort constructs an exposed port strategy. Alias for `NewHostPortStrategy("")`.
// This strategy waits port exposed in Docker container.
fiftin marked this conversation as resolved.
Show resolved Hide resolved
func ForExposedPort() *HostPortStrategy {
return NewHostPortStrategy("")
}

func (hp *HostPortStrategy) WithStartupTimeout(startupTimeout time.Duration) *HostPortStrategy {
hp.startupTimeout = startupTimeout
return hp
Expand Down