-
Notifications
You must be signed in to change notification settings - Fork 161
/
config_diff.go
43 lines (34 loc) · 996 Bytes
/
config_diff.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
package director
import (
"encoding/json"
"net/http"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
)
type ConfigDiff struct {
Diff [][]interface{}
}
type ConfigDiffResponse struct {
Diff [][]interface{} `json:"diff"`
}
func NewConfigDiff(diff [][]interface{}) ConfigDiff {
return ConfigDiff{
Diff: diff,
}
}
func (c Client) postConfigDiff(path string, manifest []byte, setHeaders func(*http.Request)) (ConfigDiffResponse, error) {
var resp ConfigDiffResponse
respBody, response, err := c.clientRequest.RawPost(path, manifest, setHeaders)
if err != nil {
if response != nil && response.StatusCode == http.StatusNotFound {
// return empty diff, just for compatibility with directors which don't have the endpoint
return resp, nil
} else {
return resp, bosherr.WrapErrorf(err, "Fetching diff result")
}
}
err = json.Unmarshal(respBody, &resp)
if err != nil {
return resp, bosherr.WrapError(err, "Unmarshaling Director response")
}
return resp, nil
}