github.com/openshift/installer@v1.4.17/pkg/asset/kubeconfig/remote.go (about) 1 package kubeconfig 2 3 import ( 4 "context" 5 "fmt" 6 "net" 7 ) 8 9 type dialer interface { 10 DialContext(ctx context.Context, network, address string) (net.Conn, error) 11 } 12 13 // CreateDialContext overrides the kubeconfig api server address with the provided ip address on the same port. 14 func CreateDialContext(d dialer, apiServerIPOverride string) func(ctx context.Context, network, address string) (net.Conn, error) { 15 return func(ctx context.Context, network, address string) (net.Conn, error) { 16 if network != "tcp" { 17 return nil, fmt.Errorf("unimplemented network %q", network) 18 } 19 20 _, port, err := net.SplitHostPort(address) 21 if err != nil { 22 return nil, err 23 } 24 25 return d.DialContext(ctx, network, net.JoinHostPort(apiServerIPOverride, port)) 26 } 27 }