ParseHostURL parses a url string, validates the string is a host url, and returns the parsed URL
(host string)
| 378 | // ParseHostURL parses a url string, validates the string is a host url, and |
| 379 | // returns the parsed URL |
| 380 | func ParseHostURL(host string) (*url.URL, error) { |
| 381 | proto, addr, ok := strings.Cut(host, "://") |
| 382 | if !ok || addr == "" { |
| 383 | return nil, fmt.Errorf("unable to parse docker host `%s`", host) |
| 384 | } |
| 385 | |
| 386 | var basePath string |
| 387 | if proto == "tcp" { |
| 388 | parsed, err := url.Parse("tcp://" + addr) |
| 389 | if err != nil { |
| 390 | return nil, err |
| 391 | } |
| 392 | addr = parsed.Host |
| 393 | basePath = parsed.Path |
| 394 | } |
| 395 | return &url.URL{ |
| 396 | Scheme: proto, |
| 397 | Host: addr, |
| 398 | Path: basePath, |
| 399 | }, nil |
| 400 | } |
| 401 | |
| 402 | func (cli *Client) dialerFromTransport() func(context.Context, string, string) (net.Conn, error) { |
| 403 | if cli.baseTransport == nil || cli.baseTransport.DialContext == nil { |
searching dependent graphs…