diff --git a/integration/openshift.go b/integration/openshift.go index 68d33d13..635d010d 100644 --- a/integration/openshift.go +++ b/integration/openshift.go @@ -154,7 +154,7 @@ func (cluster *openshiftCluster) prepareRegistryConfig(c *check.C) { } // startRegistry starts the OpenShift registry with configPart on port, waits for it to be ready, and returns the process object, or terminates on failure. -func (cluster *openshiftCluster) startRegistryProcess(c *check.C, port int, configPath string) *exec.Cmd { +func (cluster *openshiftCluster) startRegistryProcess(c *check.C, port uint16, configPath string) *exec.Cmd { cmd := cluster.clusterCmd(map[string]string{ "KUBECONFIG": "openshift.local.registry/openshift-registry.kubeconfig", "DOCKER_REGISTRY_URL": fmt.Sprintf("127.0.0.1:%d", port), diff --git a/integration/utils.go b/integration/utils.go index 44fee496..b1b7f7b9 100644 --- a/integration/utils.go +++ b/integration/utils.go @@ -4,6 +4,7 @@ import ( "bytes" "io" "net" + "net/netip" "os" "os/exec" "path/filepath" @@ -105,8 +106,9 @@ func runExecCmdWithInput(c *check.C, cmd *exec.Cmd, input string) { } // isPortOpen returns true iff the specified port on localhost is open. -func isPortOpen(port int) bool { - conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: port}) +func isPortOpen(port uint16) bool { + ap := netip.AddrPortFrom(netip.AddrFrom4([4]byte{127, 0, 0, 1}), port) + conn, err := net.DialTCP("tcp", nil, net.TCPAddrFromAddrPort(ap)) if err != nil { return false } @@ -118,7 +120,7 @@ func isPortOpen(port int) bool { // The checking can be aborted by sending a value to the terminate channel, which the caller should // always do using // defer func() {terminate <- true}() -func newPortChecker(c *check.C, port int) (portOpen <-chan bool, terminate chan<- bool) { +func newPortChecker(c *check.C, port uint16) (portOpen <-chan bool, terminate chan<- bool) { portOpenBidi := make(chan bool) // Buffered, so that sending a terminate request after the goroutine has exited does not block. terminateBidi := make(chan bool, 1)