[FIX] Do not override hostIP when hostPort is missing (#693, @lukaszo)
This commit is contained in:
parent
3b8c877b43
commit
5d0d0acc77
@ -26,6 +26,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -390,10 +391,15 @@ func applyCLIOverrides(cfg conf.SimpleConfig) (conf.SimpleConfig, error) {
|
|||||||
|
|
||||||
// Set to random port if port is empty string
|
// Set to random port if port is empty string
|
||||||
if len(exposeAPI.Binding.HostPort) == 0 {
|
if len(exposeAPI.Binding.HostPort) == 0 {
|
||||||
exposeAPI, err = cliutil.ParsePortExposureSpec("random", k3d.DefaultAPIPort)
|
var freePort string
|
||||||
if err != nil {
|
port, err := cliutil.GetFreePort()
|
||||||
return cfg, err
|
freePort = strconv.Itoa(port)
|
||||||
|
if err != nil || port == 0 {
|
||||||
|
log.Warnf("Failed to get random free port: %+v", err)
|
||||||
|
log.Warnf("Falling back to internal port %s (may be blocked though)...", k3d.DefaultAPIPort)
|
||||||
|
freePort = k3d.DefaultAPIPort
|
||||||
}
|
}
|
||||||
|
exposeAPI.Binding.HostPort = freePort
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.ExposeAPI = conf.SimpleExposureOpts{
|
cfg.ExposeAPI = conf.SimpleExposureOpts{
|
||||||
|
Loading…
Reference in New Issue
Block a user