diff options
author | Vladimir Kochnev <hashtable@yandex.ru> | 2022-08-17 03:07:01 +0300 |
---|---|---|
committer | Vladimir Kochnev <hashtable@yandex.ru> | 2022-08-18 23:48:43 +0300 |
commit | e48681e600e55718a9699006ac940738fa08f896 (patch) | |
tree | 7db176724b5e0e92ff1e85a3f2ff07d7cf8cdd34 /pkg/api/handlers/compat | |
parent | b9fb60c68acb57e56edae0b35dd408f454d32be5 (diff) | |
download | podman-e48681e600e55718a9699006ac940738fa08f896.tar.gz podman-e48681e600e55718a9699006ac940738fa08f896.tar.bz2 podman-e48681e600e55718a9699006ac940738fa08f896.zip |
Use request Context() in API handlers
Request object has its own context which must be used during a request
lifetime instead of just context.Background()
[NO NEW TESTS NEEDED]
Signed-off-by: Vladimir Kochnev <hashtable@yandex.ru>
Diffstat (limited to 'pkg/api/handlers/compat')
-rw-r--r-- | pkg/api/handlers/compat/auth.go | 3 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images_build.go | 2 |
2 files changed, 2 insertions, 3 deletions
diff --git a/pkg/api/handlers/compat/auth.go b/pkg/api/handlers/compat/auth.go index 37d2b784d..ee478b9e3 100644 --- a/pkg/api/handlers/compat/auth.go +++ b/pkg/api/handlers/compat/auth.go @@ -1,7 +1,6 @@ package compat import ( - "context" "encoding/json" "errors" "fmt" @@ -44,7 +43,7 @@ func Auth(w http.ResponseWriter, r *http.Request) { fmt.Println("Authenticating with existing credentials...") registry := stripAddressOfScheme(authConfig.ServerAddress) - if err := DockerClient.CheckAuth(context.Background(), sysCtx, authConfig.Username, authConfig.Password, registry); err == nil { + if err := DockerClient.CheckAuth(r.Context(), sysCtx, authConfig.Username, authConfig.Password, registry); err == nil { utils.WriteResponse(w, http.StatusOK, entities.AuthReport{ IdentityToken: "", Status: "Login Succeeded", diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index a00f0b089..020991cc7 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -694,7 +694,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { success bool ) - runCtx, cancel := context.WithCancel(context.Background()) + runCtx, cancel := context.WithCancel(r.Context()) go func() { defer cancel() imageID, _, err = runtime.Build(r.Context(), buildOptions, containerFiles...) |