diff --git a/internal/view/container.go b/internal/view/container.go index 5d126494..81c3ba35 100644 --- a/internal/view/container.go +++ b/internal/view/container.go @@ -3,6 +3,7 @@ package view import ( "errors" "fmt" + "net" "strings" "github.com/derailed/k9s/internal/client" @@ -140,3 +141,11 @@ func (c *Container) isForwardable(path string) ([]string, bool) { return pp, true } + +func tryListenPort(port string) error { + server, err := net.Listen("tcp", fmt.Sprintf(":%s", port)) + if err != nil { + return err + } + return server.Close() +}