mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-13 21:56:38 +01:00
Session report collection and report templates (#981)
* wip: notification stats * make report notifications optional * linting/documentation fixes * linting/documentation fixes * merge types.Container and container.Interface * smaller naming/format fixes * use typed image/container IDs * simplify notifier and update tests * add missed doc comments * lint fixes * remove unused constructors * rename old/new current/latest
This commit is contained in:
parent
d0ecc23d72
commit
e3dd8d688a
32 changed files with 853 additions and 598 deletions
|
|
@ -25,13 +25,13 @@ func NewMockAPIServer() *httptest.Server {
|
|||
|
||||
Filters := r.URL.Query().Get("filters")
|
||||
var result map[string]interface{}
|
||||
json.Unmarshal([]byte(Filters), &result)
|
||||
_ = json.Unmarshal([]byte(Filters), &result)
|
||||
status := result["status"].(map[string]interface{})
|
||||
|
||||
response = getMockJSONFromDisk("./mocks/data/containers.json")
|
||||
var x2 []types.Container
|
||||
var containers []types.Container
|
||||
json.Unmarshal([]byte(response), &containers)
|
||||
_ = json.Unmarshal([]byte(response), &containers)
|
||||
for _, v := range containers {
|
||||
for key := range status {
|
||||
if v.State == key {
|
||||
|
|
@ -56,7 +56,7 @@ func NewMockAPIServer() *httptest.Server {
|
|||
} else if isRequestFor("sha256:4dbc5f9c07028a985e14d1393e849ea07f68804c4293050d5a641b138db72daa", r) {
|
||||
response = getMockJSONFromDisk("./mocks/data/image02.json")
|
||||
}
|
||||
fmt.Fprintln(w, response)
|
||||
_, _ = fmt.Fprintln(w, response)
|
||||
},
|
||||
))
|
||||
}
|
||||
|
|
@ -67,10 +67,9 @@ func isRequestFor(urlPart string, r *http.Request) bool {
|
|||
|
||||
func getMockJSONFromDisk(relPath string) string {
|
||||
absPath, _ := filepath.Abs(relPath)
|
||||
logrus.Error(absPath)
|
||||
buf, err := ioutil.ReadFile(absPath)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
logrus.WithError(err).WithField("file", absPath).Error(err)
|
||||
return ""
|
||||
}
|
||||
return string(buf)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue