MCPcopy
hub / github.com/moby/moby / ParseHostURL

Function ParseHostURL

client/client.go:380–400  ·  view source on GitHub ↗

ParseHostURL parses a url string, validates the string is a host url, and returns the parsed URL

(host string)

Source from the content-addressed store, hash-verified

378// ParseHostURL parses a url string, validates the string is a host url, and
379// returns the parsed URL
380func 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
402func (cli *Client) dialerFromTransport() func(context.Context, string, string) (net.Conn, error) {
403 if cli.baseTransport == nil || cli.baseTransport.DialContext == nil {

Callers 3

TestParseHostURLFunction · 0.85
WithHostFunction · 0.85
NewFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by 1

TestParseHostURLFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…