MCPcopy Index your code
hub / github.com/coder/coder / ParseSSHConfigOption

Function ParseSSHConfigOption

codersdk/deployment.go:710–723  ·  view source on GitHub ↗

ParseSSHConfigOption parses a single ssh config option into its key/value pair.

(opt string)

Source from the content-addressed store, hash-verified

708
709// ParseSSHConfigOption parses a single ssh config option into its key/value pair.
710func ParseSSHConfigOption(opt string) (key string, value string, err error) {
711 if strings.ContainsAny(opt, "\r\n\x00") {
712 return "", "", xerrors.Errorf("config-ssh option %q must not contain carriage return, newline, or NUL characters", opt)
713 }
714
715 // An equal sign or a space is the separator between the key and value.
716 idx := strings.IndexFunc(opt, func(r rune) bool {
717 return r == ' ' || r == '='
718 })
719 if idx == -1 {
720 return "", "", xerrors.Errorf("config-ssh option %q is missing a key/value separator ('=' or ' ')", opt)
721 }
722 return opt[:idx], opt[idx+1:], nil
723}
724
725// isSingleHostPatternToken reports whether s is safe to write as a single SSH
726// host pattern token. Whitespace or control characters could break out into

Callers 4

TestParseSSHConfigOptionFunction · 0.92
addOptionMethod · 0.92
configSSHMethod · 0.92
ParseOptionsMethod · 0.85

Calls 1

ErrorfMethod · 0.45

Tested by 1

TestParseSSHConfigOptionFunction · 0.74