MCPcopy Index your code
hub / github.com/docker/cli / newSpec

Function newSpec

cli/connhelper/ssh/ssh.go:38–71  ·  view source on GitHub ↗
(u *url.URL)

Source from the content-addressed store, hash-verified

36}
37
38func newSpec(u *url.URL) (*Spec, error) {
39 if u == nil {
40 return nil, errors.New("URL is nil")
41 }
42 if u.Scheme == "" {
43 return nil, errors.New("no scheme provided")
44 }
45 if u.Scheme != "ssh" {
46 return nil, errors.New("incorrect scheme: " + u.Scheme)
47 }
48
49 var sp Spec
50
51 if u.User != nil {
52 sp.User = u.User.Username()
53 if _, ok := u.User.Password(); ok {
54 return nil, errors.New("plain-text password is not supported")
55 }
56 }
57 sp.Host = u.Hostname()
58 if sp.Host == "" {
59 return nil, errors.New("hostname is empty")
60 }
61 sp.Port = u.Port()
62 sp.Path = u.Path
63 if u.RawQuery != "" {
64 return nil, fmt.Errorf("query parameters are not allowed: %q", u.RawQuery)
65 }
66 if u.Fragment != "" {
67 return nil, fmt.Errorf("fragments are not allowed: %q", u.Fragment)
68 }
69
70 return &sp, nil
71}
72
73// Spec of SSH URL
74type Spec struct {

Callers 1

NewSpecFunction · 0.85

Calls 1

HostnameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…