NewSpec creates a [Spec] from the given ssh URL's properties. It returns an error if the URL is using the wrong scheme, contains fragments, query-parameters, or contains a password.
(sshURL *url.URL)
| 28 | // an error if the URL is using the wrong scheme, contains fragments, |
| 29 | // query-parameters, or contains a password. |
| 30 | func NewSpec(sshURL *url.URL) (*Spec, error) { |
| 31 | s, err := newSpec(sshURL) |
| 32 | if err != nil { |
| 33 | return nil, fmt.Errorf("invalid SSH URL: %w", err) |
| 34 | } |
| 35 | return s, nil |
| 36 | } |
| 37 | |
| 38 | func newSpec(u *url.URL) (*Spec, error) { |
| 39 | if u == nil { |