MCPcopy Index your code
hub / github.com/koding/kite / KiteFromString

Function KiteFromString

protocol/protocol.go:95–112  ·  view source on GitHub ↗

KiteFromString returns a new Kite string from the given string representation in the form of "/username/environment/...". It's the inverse of k.String()

(s string)

Source from the content-addressed store, hash-verified

93// representation in the form of "/username/environment/...". It's the inverse
94// of k.String()
95func KiteFromString(s string) (*Kite, error) {
96 if s == "" || s[0] != '/' {
97 return nil, errors.New("invalid kite string")
98 }
99
100 fields := make([]string, 7)
101 copy(fields, strings.SplitN(s[1:], "/", 7))
102
103 return &Kite{
104 Username: fields[0],
105 Environment: fields[1],
106 Name: fields[2],
107 Version: fields[3],
108 Region: fields[4],
109 Hostname: fields[5],
110 ID: fields[6],
111 }, nil
112}
113
114// RegisterArgs is used as the function argument to the Kontrol's register
115// method.

Callers 1

TestKiteStringFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestKiteStringFunction · 0.68