-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdiscovery.go
More file actions
41 lines (33 loc) · 939 Bytes
/
discovery.go
File metadata and controls
41 lines (33 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package discovery
import (
"bytes"
"io/ioutil"
"github.com/Masterminds/cookoo"
)
// TokenFile for etcd
var TokenFile = "/var/run/secrets/drycc/etcd/discovery/token"
// ClusterDiscoveryURL for drycc
const ClusterDiscoveryURL = "http://%s:%s/v2/keys/drycc/discovery/%s"
// ClusterSizeKey for discovery
const ClusterSizeKey = "drycc/discovery/%s/_config/size"
// ClusterStatusKey for drycc
const ClusterStatusKey = "drycc/status/%s/%s"
// Token reads the discovery token from the TokenFile and returns it.
func Token() ([]byte, error) {
data, err := ioutil.ReadFile(TokenFile)
if err != nil {
return data, err
}
data = bytes.TrimSpace(data)
return data, nil
}
// GetToken is a command to get a token.
//
// This is a convenience for calling Token in a route.
func GetToken(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {
t, err := Token()
if err != nil {
return "", err
}
return string(t), err
}