-
Notifications
You must be signed in to change notification settings - Fork 162
/
runtime_configs.go
54 lines (40 loc) · 1.11 KB
/
runtime_configs.go
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
42
43
44
45
46
47
48
49
50
51
52
53
54
package director
import (
"net/http"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
)
type RuntimeConfig struct {
Properties string
}
func (d DirectorImpl) LatestRuntimeConfig() (RuntimeConfig, error) {
resps, err := d.client.RuntimeConfigs()
if err != nil {
return RuntimeConfig{}, err
}
if len(resps) == 0 {
return RuntimeConfig{}, bosherr.Error("No runtime config")
}
return resps[0], nil
}
func (d DirectorImpl) UpdateRuntimeConfig(manifest []byte) error {
return d.client.UpdateRuntimeConfig(manifest)
}
func (c Client) RuntimeConfigs() ([]RuntimeConfig, error) {
var resps []RuntimeConfig
err := c.clientRequest.Get("/runtime_configs?limit=1", &resps)
if err != nil {
return resps, bosherr.WrapErrorf(err, "Finding runtime configs")
}
return resps, nil
}
func (c Client) UpdateRuntimeConfig(manifest []byte) error {
path := "/runtime_configs"
setHeaders := func(req *http.Request) {
req.Header.Add("Content-Type", "text/yaml")
}
_, _, err := c.clientRequest.RawPost(path, manifest, setHeaders)
if err != nil {
return bosherr.WrapErrorf(err, "Updating runtime config")
}
return nil
}