Skip to content

Commit 2284198

Browse files
committed
fixup
Signed-off-by: Matej Vašek <mvasek@redhat.com>
1 parent 5b20522 commit 2284198

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

pkg/functions/runner.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"os"
1212
"os/exec"
1313
"path/filepath"
14-
"strings"
1514
"time"
1615
)
1716

@@ -177,11 +176,7 @@ func runGo(ctx context.Context, job *Job) (err error) {
177176
// A Cmd with a non-empty Dir field and nil Env now implicitly sets the PWD environment variable for the subprocess to match Dir.
178177
// The new method Cmd.Environ reports the environment that would be used to run the command, including the implicitly set PWD variable.
179178
// cmd.Env = append(cmd.Environ(), "PORT="+job.Port) // requires go 1.19
180-
var host = job.Host
181-
if strings.Contains(host, ":") {
182-
host = fmt.Sprintf("[%s]", host)
183-
}
184-
cmd.Env = append(cmd.Env, "LISTEN_ADDRESS="+host+":"+job.Port, "PWD="+cmd.Dir)
179+
cmd.Env = append(cmd.Env, "LISTEN_ADDRESS="+net.JoinHostPort(job.Host, job.Port), "PWD="+cmd.Dir)
185180

186181
// Running asynchronously allows for the client Run method to return
187182
// metadata about the running function such as its chosen port.
@@ -273,7 +268,7 @@ func runPython(ctx context.Context, job *Job) (err error) {
273268

274269
func waitFor(ctx context.Context, job *Job, timeout time.Duration) error {
275270
var (
276-
uri = fmt.Sprintf("http://%s:%s%s", job.Host, job.Port, readinessEndpoint)
271+
uri = fmt.Sprintf("http://%s%s", net.JoinHostPort(job.Host, job.Port), readinessEndpoint)
277272
interval = 500 * time.Millisecond
278273
)
279274

0 commit comments

Comments
 (0)