feat(log): add context fields to lifecycle events (#1007)

This commit is contained in:
nils måsén 2021-09-19 18:07:32 +02:00 committed by GitHub
parent cd0ec88764
commit 697397f289
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 191 additions and 140 deletions

View file

@ -3,6 +3,7 @@ package mocks
import (
"encoding/json"
"fmt"
"github.com/onsi/ginkgo"
"io/ioutil"
"net/http"
"net/http/httptest"
@ -55,6 +56,22 @@ func NewMockAPIServer() *httptest.Server {
response = getMockJSONFromDisk("./mocks/data/image01.json")
} else if isRequestFor("sha256:4dbc5f9c07028a985e14d1393e849ea07f68804c4293050d5a641b138db72daa", r) {
response = getMockJSONFromDisk("./mocks/data/image02.json")
} else if isRequestFor("containers/ex-cont-id/exec", r) {
response = `{"Id": "ex-exec-id"}`
} else if isRequestFor("exec/ex-exec-id/start", r) {
response = `{"Id": "ex-exec-id"}`
} else if isRequestFor("exec/ex-exec-id/json", r) {
response = `{
"ExecID": "ex-exec-id",
"ContainerID": "ex-cont-id",
"Running": false,
"ExitCode": 0,
"Pid": 0
}`
} else {
// Allow ginkgo to correctly capture the failed assertion, even though this is called from a go func
defer ginkgo.GinkgoRecover()
ginkgo.Fail(fmt.Sprintf("mock API server endpoint not supported: %q", r.URL.String()))
}
_, _ = fmt.Fprintln(w, response)
},