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

Method KiteFromKey

kontrol/node.go:69–85  ·  view source on GitHub ↗

KiteFromKey returns a *protocol.Kite from an etcd key. etcd key is like: "/kites/devrim/env/mathworker/1/localhost/tardis.local/id"

()

Source from the content-addressed store, hash-verified

67// KiteFromKey returns a *protocol.Kite from an etcd key. etcd key is like:
68// "/kites/devrim/env/mathworker/1/localhost/tardis.local/id"
69func (n *Node) KiteFromKey() (*protocol.Kite, error) {
70 // TODO replace "kites" with KitesPrefix constant
71 fields := strings.Split(strings.TrimPrefix(n.Node.Key, "/"), "/")
72 if len(fields) != 8 || (len(fields) > 0 && fields[0] != "kites") {
73 return nil, fmt.Errorf("kontrol: invalid kite %s", n.Node.Key)
74 }
75
76 return &protocol.Kite{
77 Username: fields[1],
78 Environment: fields[2],
79 Name: fields[3],
80 Version: fields[4],
81 Region: fields[5],
82 Hostname: fields[6],
83 ID: fields[7],
84 }, nil
85}
86
87// Value returns the value associated with the current node.
88func (n *Node) Value() (kontrolprotocol.RegisterValue, error) {

Callers 2

KiteMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected