|
1 | | -/*Package etcd is a library for performing common Etcd tasks. |
2 | | - */ |
| 1 | +// Package etcd is a library for performing common Etcd tasks. |
3 | 2 | package etcd |
4 | 3 |
|
5 | 4 | import ( |
|
23 | 22 | retrySleep = 200 * time.Millisecond |
24 | 23 | ) |
25 | 24 |
|
| 25 | +const ( |
| 26 | + hostEnvVar = "DEIS_ETCD_1_SERVICE_HOST" |
| 27 | + portEnvVar = "DEIS_ETCD_1_SERVICE_PORT_CLIENT" |
| 28 | + defaultHost = "http://localhost" |
| 29 | +) |
| 30 | + |
26 | 31 | // Getter describes the Get behavior of an Etcd client. |
27 | 32 | // |
28 | 33 | // Usually you will want to use go-etcd/etcd.Client to satisfy this. |
@@ -65,7 +70,11 @@ type GetterSetter interface { |
65 | 70 | // Returns: |
66 | 71 | // This puts an *etcd.Client into the context. |
67 | 72 | func CreateClient(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) { |
68 | | - url := p.Get("url", "http://localhost:4001").(string) |
| 73 | + url, ok := p.Get("url", "http://localhost:4001").(string) |
| 74 | + if !ok { |
| 75 | + fmt.Println("ERROR: 'url' param was not a string") |
| 76 | + os.Exit(1) |
| 77 | + } |
69 | 78 |
|
70 | 79 | // Backed this out because it's unnecessary so far. |
71 | 80 | //hosts := p.Get("urls", []string{"http://localhost:4001"}).([]string) |
@@ -136,7 +145,7 @@ func IsRunning(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrup |
136 | 145 | time.Sleep(250 * time.Millisecond) |
137 | 146 | } |
138 | 147 | log.Errf(c, "Etcd is not answering after %d attempts.", count) |
139 | | - return false, &cookoo.FatalError{"Could not connect to Etcd."} |
| 148 | + return false, &cookoo.FatalError{Message: "Could not connect to Etcd."} |
140 | 149 | } |
141 | 150 |
|
142 | 151 | // Set sets a value in etcd. |
@@ -399,7 +408,7 @@ func MakeDir(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) |
399 | 408 |
|
400 | 409 | res, err := client.CreateDir(name, ttl) |
401 | 410 | if err != nil { |
402 | | - return res, &cookoo.RecoverableError{err.Error()} |
| 411 | + return res, &cookoo.RecoverableError{Message: err.Error()} |
403 | 412 | } |
404 | 413 |
|
405 | 414 | return res, nil |
|
0 commit comments